Skip to content

Commit

Permalink
txscript: add/group control op code tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
dnldd committed Jul 24, 2018
1 parent fb18a45 commit fec9578
Showing 1 changed file with 148 additions and 116 deletions.
264 changes: 148 additions & 116 deletions txscript/data/script_tests.json
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,153 @@
["OP_15", "15 EQUAL", "NONE", "OK", "Push 15"],
["OP_16", "16 EQUAL", "NONE", "OK", "Push 16"],

["Control opcode tests"],

["NOP test coverage"],
["NOP", "NOP 1", "NONE", "OK"],
["0","NOP", "NONE", "ERR_EVAL_FALSE"],
["1","NOP", "NONE", "OK"],

["VER test coverage"],
["1","VER", "NONE", "ERR_RESERVED_OPCODE", "OP_VER is reserved"],
["1", "IF VER ELSE 1 ENDIF", "NONE", "ERR_RESERVED_OPCODE", "VER non-functional"],

["IF test coverage"],
["1", "DUP IF ENDIF", "NONE", "OK"],
["1", "IF 1 ENDIF", "NONE", "OK"],
["1", "DUP IF ELSE ENDIF", "NONE", "OK"],
["1", "IF 1 ELSE ENDIF", "NONE", "OK"],
["0", "IF ELSE 1 ENDIF", "NONE", "OK"],
["1 1", "IF IF 1 ELSE 0 ENDIF ENDIF", "NONE", "OK"],
["1 0", "IF IF 1 ELSE 0 ENDIF ENDIF", "NONE", "OK"],
["1 1", "IF IF 1 ELSE 0 ENDIF ELSE IF 0 ELSE 1 ENDIF ENDIF", "NONE", "OK"],
["0 0", "IF IF 1 ELSE 0 ENDIF ELSE IF 0 ELSE 1 ENDIF ENDIF", "NONE", "OK"],
["0", "IF 0 ELSE 1 ELSE 0 ENDIF", "NONE", "OK", "Multiple ELSE's are valid and executed inverts on each ELSE encountered"],
["1", "IF 1 ELSE 0 ELSE ENDIF", "NONE", "OK"],
["1", "IF ELSE 0 ELSE 1 ENDIF", "NONE", "OK"],
["1", "IF 1 ELSE 0 ELSE 1 ENDIF ADD 2 EQUAL", "NONE", "OK"],
["1 2 0 IF AND ELSE 1 ENDIF", "NOP", "NONE", "OK"],
["1 2 0 IF OR ELSE 1 ENDIF", "NOP", "NONE", "OK"],
["1 2 0 IF XOR ELSE 1 ENDIF", "NOP", "NONE", "OK"],
["2 0 IF 2MUL ELSE 1 ENDIF", "NOP", "NONE", "OK"],
["2 0 IF 2DIV ELSE 1 ENDIF", "NOP", "NONE", "OK"],
["2 2 0 IF MUL ELSE 1 ENDIF", "NOP", "NONE", "OK"],
["2 2 0 IF DIV ELSE 1 ENDIF", "NOP", "NONE", "OK"],
["2 2 0 IF MOD ELSE 1 ENDIF", "NOP", "NONE", "OK"],
["2 2 0 IF LSHIFT ELSE 1 ENDIF", "NOP", "NONE", "OK"],
["2 2 0 IF RSHIFT ELSE 1 ENDIF", "NOP", "NONE", "OK"],
["'' 1", "IF SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ENDIF 0x14 0x68ca4fec736264c13b859bac43d5173df6871682 EQUAL", "NONE", "OK"],
["0", "IF 1 IF RETURN ELSE RETURN ELSE RETURN ENDIF ELSE 1 IF 1 ELSE RETURN ELSE 1 ENDIF ELSE RETURN ENDIF ADD 2 EQUAL", "NONE", "OK", "Nested ELSE ELSE"],
["1 0x01 0x80", "IF 0 ENDIF", "NONE", "OK", "negative 0 is false"],
["1", "IF 0x50 ENDIF 1", "NONE", "ERR_RESERVED_OPCODE", "0x50 is reserved"],
["0", "DUP IF ENDIF", "NONE", "ERR_EVAL_FALSE"],
["0", "IF 1 ENDIF", "NONE", "ERR_EMPTY_STACK"],
["0", "DUP IF ELSE ENDIF", "NONE", "ERR_EVAL_FALSE"],
["0", "IF 1 ELSE ENDIF", "NONE", "ERR_EMPTY_STACK"],
["1", "IF ELSE ENDIF ELSE", "NONE", "ERR_UNBALANCED_CONDITIONAL"],
["1", "IF ELSE ENDIF ELSE ENDIF", "NONE", "ERR_UNBALANCED_CONDITIONAL"],
["1", "IF ENDIF ENDIF", "NONE", "ERR_UNBALANCED_CONDITIONAL"],
["1", "IF ELSE ELSE ENDIF ENDIF", "NONE", "ERR_UNBALANCED_CONDITIONAL"],
["0 1", "IF IF 1 ELSE 0 ENDIF ENDIF", "NONE", "ERR_EVAL_FALSE"],
["0 0", "IF IF 1 ELSE 0 ENDIF ENDIF", "NONE", "ERR_EVAL_FALSE"],
["1 0", "IF IF 1 ELSE 0 ENDIF ELSE IF 0 ELSE 1 ENDIF ENDIF", "NONE", "ERR_EVAL_FALSE"],
["0 1", "IF IF 1 ELSE 0 ENDIF ELSE IF 0 ELSE 1 ENDIF ENDIF", "NONE", "ERR_EVAL_FALSE"],
["1", "IF 1", "NONE", "ERR_UNBALANCED_CONDITIONAL", "IF without ENDIF"],
["1 IF 1", "ENDIF", "NONE", "ERR_UNBALANCED_CONDITIONAL", "IFs don't carry over"],
["1 IF", "1 ENDIF", "NONE", "ERR_UNBALANCED_CONDITIONAL", "IF/ENDIF can't span scriptSig/scriptPubKey"],
["1 IF 0 ENDIF", "1 ENDIF", "NONE", "ERR_UNBALANCED_CONDITIONAL"],
["NOP", "IF 1 ENDIF", "NONE", "ERR_INVALID_STACK_OPERATION", "IF requires an input"],

["Unevaluated non-minimal pushes are ignored"],
["0 IF 0x4c 0x00 ENDIF 1", "", "NONE", "OK", "non-minimal PUSHDATA1 ignored"],
["0 IF 0x4d 0x0000 ENDIF 1", "", "NONE", "OK", "non-minimal PUSHDATA2 ignored"],
["0 IF 0x4c 0x00000000 ENDIF 1", "", "NONE", "OK", "non-minimal PUSHDATA4 ignored"],
["0 IF 0x01 0x81 ENDIF 1", "", "NONE", "OK", "1NEGATE equiv"],
["0 IF 0x01 0x01 ENDIF 1", "", "NONE", "OK", "OP_1 equiv"],
["0 IF 0x01 0x02 ENDIF 1", "", "NONE", "OK", "OP_2 equiv"],
["0 IF 0x01 0x03 ENDIF 1", "", "NONE", "OK", "OP_3 equiv"],
["0 IF 0x01 0x04 ENDIF 1", "", "NONE", "OK", "OP_4 equiv"],
["0 IF 0x01 0x05 ENDIF 1", "", "NONE", "OK", "OP_5 equiv"],
["0 IF 0x01 0x06 ENDIF 1", "", "NONE", "OK", "OP_6 equiv"],
["0 IF 0x01 0x07 ENDIF 1", "", "NONE", "OK", "OP_7 equiv"],
["0 IF 0x01 0x08 ENDIF 1", "", "NONE", "OK", "OP_8 equiv"],
["0 IF 0x01 0x09 ENDIF 1", "", "NONE", "OK", "OP_9 equiv"],
["0 IF 0x01 0x0a ENDIF 1", "", "NONE", "OK", "OP_10 equiv"],
["0 IF 0x01 0x0b ENDIF 1", "", "NONE", "OK", "OP_11 equiv"],
["0 IF 0x01 0x0c ENDIF 1", "", "NONE", "OK", "OP_12 equiv"],
["0 IF 0x01 0x0d ENDIF 1", "", "NONE", "OK", "OP_13 equiv"],
["0 IF 0x01 0x0e ENDIF 1", "", "NONE", "OK", "OP_14 equiv"],
["0 IF 0x01 0x0f ENDIF 1", "", "NONE", "OK", "OP_15 equiv"],
["0 IF 0x01 0x10 ENDIF 1", "", "NONE", "OK", "OP_16 equiv"],

["NOTIF test coverage"],
["1 0", "NOTIF IF 1 ELSE 0 ENDIF ENDIF", "NONE", "OK"],
["1 1", "NOTIF IF 1 ELSE 0 ENDIF ENDIF", "NONE", "OK"],
["1 0", "NOTIF IF 1 ELSE 0 ENDIF ELSE IF 0 ELSE 1 ENDIF ENDIF", "NONE", "OK"],
["0 1", "NOTIF IF 1 ELSE 0 ENDIF ELSE IF 0 ELSE 1 ENDIF ENDIF", "NONE", "OK"],
["1", "NOTIF 0 NOTIF RETURN ELSE RETURN ELSE RETURN ENDIF ELSE 0 NOTIF 1 ELSE RETURN ELSE 1 ENDIF ELSE RETURN ENDIF ADD 2 EQUAL", "NONE", "OK"],
["1", "NOTIF 0 ELSE 1 ELSE 0 ENDIF", "NONE", "OK", "Multiple ELSE's are valid and execution inverts on each ELSE encountered"],
["0", "NOTIF 1 ELSE 0 ELSE ENDIF", "NONE", "OK"],
["0", "NOTIF ELSE 0 ELSE 1 ENDIF", "NONE", "OK"],
["0", "NOTIF 1 ENDIF", "NONE", "OK"],
["0", "NOTIF 1 ELSE 0 ELSE 1 ENDIF ADD 2 EQUAL", "NONE", "OK"],
["'' 0", "NOTIF SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ENDIF 0x14 0x68ca4fec736264c13b859bac43d5173df6871682 EQUAL", "NONE", "OK"],
["0", "NOTIF ELSE 1 ENDIF", "NONE", "ERR_EMPTY_STACK"],
["0 0", "NOTIF IF 1 ELSE 0 ENDIF ENDIF", "NONE", "ERR_EVAL_FALSE"],
["0 1", "NOTIF IF 1 ELSE 0 ENDIF ENDIF", "NONE", "ERR_EVAL_FALSE"],
["1 1", "NOTIF IF 1 ELSE 0 ENDIF ELSE IF 0 ELSE 1 ENDIF ENDIF", "NONE", "ERR_EVAL_FALSE"],
["0 0", "NOTIF IF 1 ELSE 0 ENDIF ELSE IF 0 ELSE 1 ENDIF ENDIF", "NONE", "ERR_EVAL_FALSE"],
["0 NOTIF", "123", "NONE", "ERR_UNBALANCED_CONDITIONAL"],
["NOP", "NOTIF 1 ENDIF", "NONE", "ERR_INVALID_STACK_OPERATION", "NOTIF requires an input"],

["VERIF test coverage"],
["0", "IF ELSE 1 ELSE VERIF ENDIF", "NONE", "ERR_RESERVED_OPCODE", "VERIF illegal everywhere"],
["1","VERIF", "NONE", "ERR_RESERVED_OPCODE", "OP_VERIF is reserved"],
["0", "IF VERIF ELSE 1 ENDIF", "NONE", "ERR_RESERVED_OPCODE", "VERIF illegal everywhere"],

["VERNOTIF test coverage"],
["0", "IF ELSE 1 ELSE VERNOTIF ENDIF", "NONE", "ERR_RESERVED_OPCODE", "VERNOTIF illegal everywhere"],
["1","VERNOTIF", "NONE", "ERR_RESERVED_OPCODE", "OP_VERNOTIF is reserved"],
["0", "IF VERNOTIF ELSE 1 ENDIF", "NONE", "ERR_RESERVED_OPCODE", "VERNOTIF illegal everywhere"],

["ENDIF test coverage"],
["1", "1 ENDIF", "NONE", "ERR_UNBALANCED_CONDITIONAL", "ENDIF without IF"],
["1 ELSE 0 ENDIF", "1", "NONE", "ERR_UNBALANCED_CONDITIONAL"],
["1", "ELSE ENDIF", "NONE", "ERR_UNBALANCED_CONDITIONAL"],
["1", "ENDIF", "NONE", "ERR_UNBALANCED_CONDITIONAL", "Malformed IF/ELSE/ENDIF sequence"],
["1", "ENDIF ELSE", "NONE", "ERR_UNBALANCED_CONDITIONAL"],
["1", "ENDIF ELSE IF", "NONE", "ERR_UNBALANCED_CONDITIONAL"],

["VERIFY test coverage"],
["1 1", "VERIFY", "NONE", "OK"],
["1", "VERIFY 1", "NONE", "OK"],
["1 0x05 0x01 0x00 0x00 0x00 0x00", "VERIFY", "NONE", "OK", "values >4 bytes can be cast to boolean"],
["0", "VERIFY 1", "NONE", "ERR_VERIFY"],
["1", "VERIFY", "NONE", "ERR_EMPTY_STACK"],
["1", "VERIFY 0", "NONE", "ERR_EVAL_FALSE"],
["NOP", "VERIFY 1", "NONE", "ERR_INVALID_STACK_OPERATION", "VERIFY requires an input"],

["RETURN test coverage"],
["0", "IF RETURN ENDIF 1", "NONE", "OK", "RETURN only works if executed"],
["1", "IF RETURN ELSE ELSE 1 ENDIF", "NONE", "ERR_EARLY_RETURN", "Multiple ELSEs"],
["1", "IF 1 ELSE ELSE RETURN ENDIF", "NONE", "ERR_EARLY_RETURN"],
["1", "RETURN", "NONE", "ERR_EARLY_RETURN"],
["1", "DUP IF RETURN ENDIF", "NONE", "ERR_EARLY_RETURN"],
["1", "RETURN 'data'", "NONE", "ERR_EARLY_RETURN", "canonical prunable txout format"],
["0 IF", "RETURN ENDIF 1", "NONE", "ERR_UNBALANCED_CONDITIONAL", "still prunable because IF/ENDIF can't span scriptSig/scriptPubKey"],

["NOTE: most CHECKLOCKTIMEVERIFY tests reside in transaction tests"],
["since they rely on fields in a transaction"],

["CHECKLOCKTIMEVERIFY test coverage"],
["", "CHECKLOCKTIMEVERIFY", "NONE", "ERR_EMPTY_STACK", "CHECKLOCKTIMEVERIFY requires a transaction and a stack item"],

["NOTE: most CHECKSEQUENCEVERIFY tests reside in transaction tests"],
["since they rely on fields in a transaction"],

["CHECKSEQUENCEVERIFY test coverage"],
["", "CHECKSEQUENCEVERIFY", "NONE", "ERR_EMPTY_STACK", "CHECKSEQUENCEVERIFY requires a transaction and a stack item"],

["CAT related test coverage"],
["'a' 'b'", "CAT 'ab' EQUAL", "NONE", "OK", "CAT concatenates two input args"],
["'a' 2147483648", "CAT 0x06 0x610000008000 EQUAL", "NONE", "OK", "CAT must treat arguments as bytes as opposed to numeric"],
Expand Down Expand Up @@ -570,17 +717,6 @@
["2147483648 1", "ROTL 1 EQUAL", "NONE", "ERR_OUT_OF_RANGE", "ROTL must fail with input value >4 bytes"],
["1 2147483648", "ROTL TRUE", "NONE", "ERR_OUT_OF_RANGE", "ROTL must fail with rotation count >4 bytes"],

["1 2 0 IF AND ELSE 1 ENDIF", "NOP", "NONE", "OK"],
["1 2 0 IF OR ELSE 1 ENDIF", "NOP", "NONE", "OK"],
["1 2 0 IF XOR ELSE 1 ENDIF", "NOP", "NONE", "OK"],
["2 0 IF 2MUL ELSE 1 ENDIF", "NOP", "NONE", "OK"],
["2 0 IF 2DIV ELSE 1 ENDIF", "NOP", "NONE", "OK"],
["2 2 0 IF MUL ELSE 1 ENDIF", "NOP", "NONE", "OK"],
["2 2 0 IF DIV ELSE 1 ENDIF", "NOP", "NONE", "OK"],
["2 2 0 IF MOD ELSE 1 ENDIF", "NOP", "NONE", "OK"],
["2 2 0 IF LSHIFT ELSE 1 ENDIF", "NOP", "NONE", "OK"],
["2 2 0 IF RSHIFT ELSE 1 ENDIF", "NOP", "NONE", "OK"],

["2 DUP MUL", "4 EQUAL", "NONE", "OK"],

["Division related test coverage"],
Expand Down Expand Up @@ -715,42 +851,6 @@
["0", "IF VER ELSE 1 ENDIF", "NONE", "OK", "VER non-functional (ok if not executed)"],
["0", "IF RESERVED ELSE 1 ENDIF", "NONE", "OK", "RESERVED ok in un-executed IF"],

["1", "DUP IF ENDIF", "NONE", "OK"],
["1", "IF 1 ENDIF", "NONE", "OK"],
["1", "DUP IF ELSE ENDIF", "NONE", "OK"],
["1", "IF 1 ELSE ENDIF", "NONE", "OK"],
["0", "IF ELSE 1 ENDIF", "NONE", "OK"],

["1 1", "IF IF 1 ELSE 0 ENDIF ENDIF", "NONE", "OK"],
["1 0", "IF IF 1 ELSE 0 ENDIF ENDIF", "NONE", "OK"],
["1 1", "IF IF 1 ELSE 0 ENDIF ELSE IF 0 ELSE 1 ENDIF ENDIF", "NONE", "OK"],
["0 0", "IF IF 1 ELSE 0 ENDIF ELSE IF 0 ELSE 1 ENDIF ENDIF", "NONE", "OK"],

["1 0", "NOTIF IF 1 ELSE 0 ENDIF ENDIF", "NONE", "OK"],
["1 1", "NOTIF IF 1 ELSE 0 ENDIF ENDIF", "NONE", "OK"],
["1 0", "NOTIF IF 1 ELSE 0 ENDIF ELSE IF 0 ELSE 1 ENDIF ENDIF", "NONE", "OK"],
["0 1", "NOTIF IF 1 ELSE 0 ENDIF ELSE IF 0 ELSE 1 ENDIF ENDIF", "NONE", "OK"],

["0", "IF 0 ELSE 1 ELSE 0 ENDIF", "NONE", "OK", "Multiple ELSE's are valid and executed inverts on each ELSE encountered"],
["1", "IF 1 ELSE 0 ELSE ENDIF", "NONE", "OK"],
["1", "IF ELSE 0 ELSE 1 ENDIF", "NONE", "OK"],
["1", "IF 1 ELSE 0 ELSE 1 ENDIF ADD 2 EQUAL", "NONE", "OK"],
["'' 1", "IF SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ENDIF 0x14 0x68ca4fec736264c13b859bac43d5173df6871682 EQUAL", "NONE", "OK"],

["1", "NOTIF 0 ELSE 1 ELSE 0 ENDIF", "NONE", "OK", "Multiple ELSE's are valid and execution inverts on each ELSE encountered"],
["0", "NOTIF 1 ELSE 0 ELSE ENDIF", "NONE", "OK"],
["0", "NOTIF ELSE 0 ELSE 1 ENDIF", "NONE", "OK"],
["0", "NOTIF 1 ELSE 0 ELSE 1 ENDIF ADD 2 EQUAL", "NONE", "OK"],
["'' 0", "NOTIF SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ENDIF 0x14 0x68ca4fec736264c13b859bac43d5173df6871682 EQUAL", "NONE", "OK"],

["0", "IF 1 IF RETURN ELSE RETURN ELSE RETURN ENDIF ELSE 1 IF 1 ELSE RETURN ELSE 1 ENDIF ELSE RETURN ENDIF ADD 2 EQUAL", "NONE", "OK", "Nested ELSE ELSE"],
["1", "NOTIF 0 NOTIF RETURN ELSE RETURN ELSE RETURN ENDIF ELSE 0 NOTIF 1 ELSE RETURN ELSE 1 ENDIF ELSE RETURN ENDIF ADD 2 EQUAL", "NONE", "OK"],

["0", "IF RETURN ENDIF 1", "NONE", "OK", "RETURN only works if executed"],

["1 1", "VERIFY", "NONE", "OK"],
["1 0x05 0x01 0x00 0x00 0x00 0x00", "VERIFY", "NONE", "OK", "values >4 bytes can be cast to boolean"],
["1 0x01 0x80", "IF 0 ENDIF", "NONE", "OK", "negative 0 is false"],

["10 0 11 TOALTSTACK DROP FROMALTSTACK", "ADD 21 EQUAL", "NONE", "OK"],
["'gavin_was_here' TOALTSTACK 11 FROMALTSTACK", "'gavin_was_here' EQUALVERIFY 11 EQUAL", "NONE", "OK"],
Expand Down Expand Up @@ -1032,11 +1132,6 @@
["0x03 0x100080", "0x04 0x10000080 NUMEQUAL", "NONE", "ERR_MINIMAL_DATA"],
["0x03 0x100000", "0x04 0x10000000 NUMEQUAL", "NONE", "ERR_MINIMAL_DATA"],

["NOP", "NOP 1", "NONE", "OK", "The following tests check the if(stack.size() < N) tests in each opcode"],
["1", "IF 1 ENDIF", "NONE", "OK", "They are here to catch copy-and-paste errors"],
["0", "NOTIF 1 ENDIF", "NONE", "OK", "Most of them are duplicated elsewhere,"],
["1", "VERIFY 1", "NONE", "OK", "but, hey, more is always better, right?"],

["0", "TOALTSTACK 1", "NONE", "OK"],
["1", "TOALTSTACK FROMALTSTACK", "NONE", "OK"],
["0 0", "2DROP 1", "NONE", "OK"],
Expand Down Expand Up @@ -2006,57 +2101,6 @@
["", "0 <0>{19} 19 CHECKMULTISIGVERIFY DEPTH 0 EQUAL", "NONE", "OK", "CHECKMULTISIGVERIFY must allow 19 pubkeys"],
["", "0 <0>{20} 20 CHECKMULTISIGVERIFY DEPTH 0 EQUAL", "NONE", "OK", "CHECKMULTISIGVERIFY must allow 20 pubkeys"],

["1", "IF 0x50 ENDIF 1", "NONE", "ERR_RESERVED_OPCODE", "0x50 is reserved"],
["0x52", "0x5f ADD 0x60 EQUAL", "NONE", "ERR_EVAL_FALSE", "0x51 through 0x60 push 1 through 16 onto stack"],
["0","NOP", "NONE", "ERR_EVAL_FALSE"],
["1", "IF VER ELSE 1 ENDIF", "NONE", "ERR_RESERVED_OPCODE", "VER non-functional"],
["0", "IF VERIF ELSE 1 ENDIF", "NONE", "ERR_RESERVED_OPCODE", "VERIF illegal everywhere"],
["0", "IF ELSE 1 ELSE VERIF ENDIF", "NONE", "ERR_RESERVED_OPCODE", "VERIF illegal everywhere"],
["0", "IF VERNOTIF ELSE 1 ENDIF", "NONE", "ERR_RESERVED_OPCODE", "VERNOTIF illegal everywhere"],
["0", "IF ELSE 1 ELSE VERNOTIF ENDIF", "NONE", "ERR_RESERVED_OPCODE", "VERNOTIF illegal everywhere"],

["1 IF", "1 ENDIF", "NONE", "ERR_UNBALANCED_CONDITIONAL", "IF/ENDIF can't span scriptSig/scriptPubKey"],
["1 IF 0 ENDIF", "1 ENDIF", "NONE", "ERR_UNBALANCED_CONDITIONAL"],
["1 ELSE 0 ENDIF", "1", "NONE", "ERR_UNBALANCED_CONDITIONAL"],
["0 NOTIF", "123", "NONE", "ERR_UNBALANCED_CONDITIONAL"],

["0", "DUP IF ENDIF", "NONE", "ERR_EVAL_FALSE"],
["0", "IF 1 ENDIF", "NONE", "ERR_EMPTY_STACK"],
["0", "DUP IF ELSE ENDIF", "NONE", "ERR_EVAL_FALSE"],
["0", "IF 1 ELSE ENDIF", "NONE", "ERR_EMPTY_STACK"],
["0", "NOTIF ELSE 1 ENDIF", "NONE", "ERR_EMPTY_STACK"],

["0 1", "IF IF 1 ELSE 0 ENDIF ENDIF", "NONE", "ERR_EVAL_FALSE"],
["0 0", "IF IF 1 ELSE 0 ENDIF ENDIF", "NONE", "ERR_EVAL_FALSE"],
["1 0", "IF IF 1 ELSE 0 ENDIF ELSE IF 0 ELSE 1 ENDIF ENDIF", "NONE", "ERR_EVAL_FALSE"],
["0 1", "IF IF 1 ELSE 0 ENDIF ELSE IF 0 ELSE 1 ENDIF ENDIF", "NONE", "ERR_EVAL_FALSE"],

["0 0", "NOTIF IF 1 ELSE 0 ENDIF ENDIF", "NONE", "ERR_EVAL_FALSE"],
["0 1", "NOTIF IF 1 ELSE 0 ENDIF ENDIF", "NONE", "ERR_EVAL_FALSE"],
["1 1", "NOTIF IF 1 ELSE 0 ENDIF ELSE IF 0 ELSE 1 ENDIF ENDIF", "NONE", "ERR_EVAL_FALSE"],
["0 0", "NOTIF IF 1 ELSE 0 ENDIF ELSE IF 0 ELSE 1 ENDIF ENDIF", "NONE", "ERR_EVAL_FALSE"],

["1", "IF RETURN ELSE ELSE 1 ENDIF", "NONE", "ERR_EARLY_RETURN", "Multiple ELSEs"],
["1", "IF 1 ELSE ELSE RETURN ENDIF", "NONE", "ERR_EARLY_RETURN"],

["1", "ENDIF", "NONE", "ERR_UNBALANCED_CONDITIONAL", "Malformed IF/ELSE/ENDIF sequence"],
["1", "ELSE ENDIF", "NONE", "ERR_UNBALANCED_CONDITIONAL"],
["1", "ENDIF ELSE", "NONE", "ERR_UNBALANCED_CONDITIONAL"],
["1", "ENDIF ELSE IF", "NONE", "ERR_UNBALANCED_CONDITIONAL"],
["1", "IF ELSE ENDIF ELSE", "NONE", "ERR_UNBALANCED_CONDITIONAL"],
["1", "IF ELSE ENDIF ELSE ENDIF", "NONE", "ERR_UNBALANCED_CONDITIONAL"],
["1", "IF ENDIF ENDIF", "NONE", "ERR_UNBALANCED_CONDITIONAL"],
["1", "IF ELSE ELSE ENDIF ENDIF", "NONE", "ERR_UNBALANCED_CONDITIONAL"],

["1", "RETURN", "NONE", "ERR_EARLY_RETURN"],
["1", "DUP IF RETURN ENDIF", "NONE", "ERR_EARLY_RETURN"],

["1", "RETURN 'data'", "NONE", "ERR_EARLY_RETURN", "canonical prunable txout format"],
["0 IF", "RETURN ENDIF 1", "NONE", "ERR_UNBALANCED_CONDITIONAL", "still prunable because IF/ENDIF can't span scriptSig/scriptPubKey"],

["0", "VERIFY 1", "NONE", "ERR_VERIFY"],
["1", "VERIFY", "NONE", "ERR_EMPTY_STACK"],
["1", "VERIFY 0", "NONE", "ERR_EVAL_FALSE"],

["1 TOALTSTACK", "FROMALTSTACK 1", "NONE", "ERR_INVALID_ALTSTACK_OPERATION", "alt stack not shared between sig/pubkey"],

Expand Down Expand Up @@ -2228,11 +2272,6 @@

["NOP1","NOP10", "NONE", "ERR_EMPTY_STACK"],

["1","VER", "NONE", "ERR_RESERVED_OPCODE", "OP_VER is reserved"],
["1","VERIF", "NONE", "ERR_RESERVED_OPCODE", "OP_VERIF is reserved"],
["1","VERNOTIF", "NONE", "ERR_RESERVED_OPCODE", "OP_VERNOTIF is reserved"],
["1","RESERVED", "NONE", "ERR_RESERVED_OPCODE", "OP_RESERVED is reserved"],

["2147483648", "1ADD 1", "NONE", "ERR_OUT_OF_RANGE", "We cannot do math on 5-byte integers"],
["2147483648", "NEGATE 1", "NONE", "ERR_OUT_OF_RANGE", "We cannot do math on 5-byte integers"],
["-2147483648", "1ADD 1", "NONE", "ERR_OUT_OF_RANGE", "Because we use a sign bit, -2147483648 is also 5 bytes"],
Expand All @@ -2242,14 +2281,7 @@
["2147483648 1", "BOOLOR 1", "NONE", "ERR_OUT_OF_RANGE", "We cannot do BOOLOR on 5-byte integers (but we can still do IF etc)"],
["2147483648 1", "BOOLAND 1", "NONE", "ERR_OUT_OF_RANGE", "We cannot do BOOLAND on 5-byte integers"],

["1", "1 ENDIF", "NONE", "ERR_UNBALANCED_CONDITIONAL", "ENDIF without IF"],
["1", "IF 1", "NONE", "ERR_UNBALANCED_CONDITIONAL", "IF without ENDIF"],
["1 IF 1", "ENDIF", "NONE", "ERR_UNBALANCED_CONDITIONAL", "IFs don't carry over"],

["NOP", "IF 1 ENDIF", "NONE", "ERR_INVALID_STACK_OPERATION", "The following tests check the if(stack.size() < N) tests in each opcode"],
["NOP", "NOTIF 1 ENDIF", "NONE", "ERR_INVALID_STACK_OPERATION", "They are here to catch copy-and-paste errors"],
["NOP", "VERIFY 1", "NONE", "ERR_INVALID_STACK_OPERATION", "Most of them are duplicated elsewhere,"],
["NOP", "TOALTSTACK 1", "NONE", "ERR_INVALID_STACK_OPERATION", "but, hey, more is always better, right?"],
["NOP", "TOALTSTACK 1", "NONE", "ERR_INVALID_STACK_OPERATION", "TOALTSTACK requires an input"],

["1", "FROMALTSTACK", "NONE", "ERR_INVALID_STACK_OPERATION"],
["1", "2DROP 1", "NONE", "ERR_INVALID_STACK_OPERATION"],
Expand Down

0 comments on commit fec9578

Please sign in to comment.