From 6cc773e13a6729a5456933410aac313f32754a59 Mon Sep 17 00:00:00 2001 From: Donald Adu-Poku Date: Sun, 22 Jul 2018 02:46:37 +0000 Subject: [PATCH] txscript: group splice opcode tests. --- txscript/data/script_tests.json | 69 ++++++++++++++++++--------------- 1 file changed, 37 insertions(+), 32 deletions(-) diff --git a/txscript/data/script_tests.json b/txscript/data/script_tests.json index dee38aa21c..739252904b 100644 --- a/txscript/data/script_tests.json +++ b/txscript/data/script_tests.json @@ -874,7 +874,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"], @@ -889,7 +891,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"], @@ -916,7 +918,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"], @@ -932,7 +934,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"], @@ -948,6 +950,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"], @@ -1170,34 +1202,7 @@ ["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"],