Skip to content

Commit

Permalink
txscript: group splice opcode tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
dnldd committed Jul 20, 2018
1 parent 8053c7c commit d9e2434
Showing 1 changed file with 36 additions and 33 deletions.
69 changes: 36 additions & 33 deletions txscript/data/script_tests.json
Original file line number Diff line number Diff line change
Expand Up @@ -854,7 +854,9 @@
["", "TUCK 1", "NONE", "ERR_INVALID_STACK_OPERATION", "TUCK requires two inputs"],
["0 'z'{2049}", "TUCK", "NONE", "ERR_PUSH_SIZE", "Exceed max allowed input size"],

["CAT related test coverage"],
["SPLICE opcode tests"],

["CAT 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"],
["'' ''", "CAT '' EQUAL", "NONE", "OK", "CAT with two empty args must result in a single empty item on the stack"],
Expand All @@ -869,7 +871,7 @@
["'ab'", "CAT TRUE", "NONE", "ERR_INVALID_STACK_OPERATION", "CAT requires a second input arg"],
["'a' 'abcdefghijklmnop' DUP CAT DUP CAT DUP CAT DUP CAT DUP CAT DUP CAT DUP CAT", "CAT", "NONE", "ERR_PUSH_SIZE", "CAT must fail if the result would exceed max allowed stack item size"],

["Substring related test coverage"],
["SUBSTR test coverage"],
["'abcd' 1 0", "SUBSTR 'a' EQUAL", "NONE", "OK", "SUBSTR uses 0-based indices"],
["'abcd' 3 1", "SUBSTR 'bc' EQUAL", "NONE", "OK", "SUBSTR end index is exclusive"],
["'abcd' 1 1", "SUBSTR NOT", "NONE", "OK", "SUBSTR same index must produce empty byte push which is equivalent to FALSE"],
Expand All @@ -896,7 +898,7 @@
["'' 4 2147483648", "SUBSTR NOT", "NONE", "ERR_OUT_OF_RANGE", "SUBSTR with empty string must fail with start index >4 bytes"],
["'' 2147483648 4", "SUBSTR NOT", "NONE", "ERR_OUT_OF_RANGE", "SUBSTR with empty string must fail with end index >4 bytes"],

["Left substring related test coverage"],
["LEFT test coverage"],
["'abcd' 0", "LEFT NOT", "NONE", "OK", "LEFT index of zero must produce empty byte push which is equivalent to FALSE"],
["'abcd' 1", "LEFT 'a' EQUAL", "NONE", "OK", "LEFT uses 0-based end index"],
["'abcd' 4", "LEFT 'abcd' EQUAL", "NONE", "OK", "LEFT produces entire string when end index equals string length"],
Expand All @@ -912,7 +914,7 @@
["'abc' 4", "LEFT NOT", "NONE", "ERR_OVERFLOW_SUBSTR_INDEX", "LEFT must fail with index too large"],
["'' 2147483648", "LEFT NOT", "NONE", "ERR_OUT_OF_RANGE", "LEFT with empty string must fail with index >4 bytes"],

["Right substring related test coverage"],
["RIGHT test coverage"],
["'abcd' 4", "RIGHT NOT", "NONE", "OK", "RIGHT index equal to length must produce empty byte push which is equivalent to FALSE"],
["'abcd' 3", "RIGHT 'd' EQUAL", "NONE", "OK", "RIGHT uses 0-based start index"],
["'abcd' 0", "RIGHT 'abcd' EQUAL", "NONE", "OK", "RIGHT produces entire string when start index is zero"],
Expand All @@ -928,6 +930,36 @@
["'abc' 4", "RIGHT NOT", "NONE", "ERR_OVERFLOW_SUBSTR_INDEX", "RIGHT must fail with index too large"],
["'' 2147483648", "RIGHT NOT", "NONE", "ERR_OUT_OF_RANGE", "RIGHT with empty string must fail with index >4 bytes"],

["SIZE test coverage"],
["0", "SIZE 0 EQUAL", "NONE", "OK"],
["1", "SIZE 1 EQUAL", "NONE", "OK"],
["127", "SIZE 1 EQUAL", "NONE", "OK"],
["128", "SIZE 2 EQUAL", "NONE", "OK"],
["32767", "SIZE 2 EQUAL", "NONE", "OK"],
["32768", "SIZE 3 EQUAL", "NONE", "OK"],
["8388607", "SIZE 3 EQUAL", "NONE", "OK"],
["8388608", "SIZE 4 EQUAL", "NONE", "OK"],
["2147483647", "SIZE 4 EQUAL", "NONE", "OK"],
["2147483648", "SIZE 5 EQUAL", "NONE", "OK"],
["549755813887", "SIZE 5 EQUAL", "NONE", "OK"],
["549755813888", "SIZE 6 EQUAL", "NONE", "OK"],
["9223372036854775807", "SIZE 8 EQUAL", "NONE", "OK"],
["-1", "SIZE 1 EQUAL", "NONE", "OK"],
["-127", "SIZE 1 EQUAL", "NONE", "OK"],
["-128", "SIZE 2 EQUAL", "NONE", "OK"],
["-32767", "SIZE 2 EQUAL", "NONE", "OK"],
["-32768", "SIZE 3 EQUAL", "NONE", "OK"],
["-8388607", "SIZE 3 EQUAL", "NONE", "OK"],
["-8388608", "SIZE 4 EQUAL", "NONE", "OK"],
["-2147483647", "SIZE 4 EQUAL", "NONE", "OK"],
["-2147483648", "SIZE 5 EQUAL", "NONE", "OK"],
["-549755813887", "SIZE 5 EQUAL", "NONE", "OK"],
["-549755813888", "SIZE 6 EQUAL", "NONE", "OK"],
["-9223372036854775807", "SIZE 8 EQUAL", "NONE", "OK"],
["'abcdefghijklmnopqrstuvwxyz'", "SIZE 26 EQUAL", "NONE", "OK"],
["42", "SIZE 1 EQUALVERIFY 42 EQUAL", "NONE", "OK", "SIZE does not consume argument"],
["NOP", "SIZE 1", "NONE", "ERR_INVALID_STACK_OPERATION"],

["Right bit rotation related test coverage"],
["-2147483647 1", "ROTR -1073741824 EQUAL", "NONE", "OK", "ROTR 0x80000001 >>> 1"],
["-2147483647 2", "ROTR 1610612736 EQUAL", "NONE", "OK", "ROTR 0x80000001 >>> 2"],
Expand Down Expand Up @@ -1161,35 +1193,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"],

["0", "SIZE 0 EQUAL", "NONE", "OK"],
["1", "SIZE 1 EQUAL", "NONE", "OK"],
["127", "SIZE 1 EQUAL", "NONE", "OK"],
["128", "SIZE 2 EQUAL", "NONE", "OK"],
["32767", "SIZE 2 EQUAL", "NONE", "OK"],
["32768", "SIZE 3 EQUAL", "NONE", "OK"],
["8388607", "SIZE 3 EQUAL", "NONE", "OK"],
["8388608", "SIZE 4 EQUAL", "NONE", "OK"],
["2147483647", "SIZE 4 EQUAL", "NONE", "OK"],
["2147483648", "SIZE 5 EQUAL", "NONE", "OK"],
["549755813887", "SIZE 5 EQUAL", "NONE", "OK"],
["549755813888", "SIZE 6 EQUAL", "NONE", "OK"],
["9223372036854775807", "SIZE 8 EQUAL", "NONE", "OK"],
["-1", "SIZE 1 EQUAL", "NONE", "OK"],
["-127", "SIZE 1 EQUAL", "NONE", "OK"],
["-128", "SIZE 2 EQUAL", "NONE", "OK"],
["-32767", "SIZE 2 EQUAL", "NONE", "OK"],
["-32768", "SIZE 3 EQUAL", "NONE", "OK"],
["-8388607", "SIZE 3 EQUAL", "NONE", "OK"],
["-8388608", "SIZE 4 EQUAL", "NONE", "OK"],
["-2147483647", "SIZE 4 EQUAL", "NONE", "OK"],
["-2147483648", "SIZE 5 EQUAL", "NONE", "OK"],
["-549755813887", "SIZE 5 EQUAL", "NONE", "OK"],
["-549755813888", "SIZE 6 EQUAL", "NONE", "OK"],
["-9223372036854775807", "SIZE 8 EQUAL", "NONE", "OK"],
["'abcdefghijklmnopqrstuvwxyz'", "SIZE 26 EQUAL", "NONE", "OK"],
["42", "SIZE 1 EQUALVERIFY 42 EQUAL", "NONE", "OK", "SIZE does not consume argument"],
["NOP", "SIZE 1", "NONE", "ERR_INVALID_STACK_OPERATION"],

["2 -2 ADD", "0 EQUAL", "NONE", "OK"],
["2147483647 -2147483647 ADD", "0 EQUAL", "NONE", "OK"],
["-1 -1 ADD", "-2 EQUAL", "NONE", "OK"],
Expand Down

0 comments on commit d9e2434

Please sign in to comment.