HomePhabricator

Add a NUM2BIN test with a 5 byte operand

Description

Add a NUM2BIN test with a 5 byte operand

Summary:
The first operand to OP_NUM2BIN (the number that is to be converted into a binary) is special. It is numeric but can be larger than 4 bytes long and minimal encoding is not required. This revision adds a few tests that confirm this behavior.

  • Try to squeeze a 3 byte number into a 2 byte binary vector - should generate IMPOSSIBLE_ENCODING error
  • Convert a 5 byte number into a 5 byte binary - should pass
  • Convert a 5 byte number into a 6 byte binary - should pass and pad properly
  • Convert a 5 byte number into a 4 byte binary - should generate IMPOSSIBLE_ENCODING error
  • Convert a 520 byte number into a binary - should pass
  • Convert a number that is not minimally encoded - should pass, minimal encoding does not apply to the first operand
  • Shrink a number that is not minimally encoded - should pass
  • Use non-minimally encoded number for second operand - should fail, must be minimally encoded
  • Use 5 byte second operand - should fail with UNKNOWN_ERROR, second operand must be <= 4 bytes long, result too long would generate PUSH_SIZE error

Test Plan: make test

Reviewers: O1 Bitcoin ABC, #bitcoin_abc, jasonbcox, deadalnix, danconnolly

Reviewed By: O1 Bitcoin ABC, #bitcoin_abc, jasonbcox, deadalnix

Subscribers: deadalnix, jasonbcox, teamcity

Differential Revision: https://reviews.bitcoinabc.org/D1438

Details

Provenance
danconnollyAuthored on Jun 4 2018, 23:30
schancelCommitted on Jun 4 2018, 23:34
schancelPushed on Jun 4 2018, 23:34
Reviewer
Restricted Owners Package
Differential Revision
D1438: Add a NUM2BIN test with a 5 byte operand
Parents
rABCb983ebdcaba0: Use a modified size for transaction minimum fee calculation.
Branches
Unknown
Tags
Unknown