diff --git a/src/test/data/script_invalid.json b/src/test/data/script_invalid.json index c05d3ba5..f06c3bee 100644 --- a/src/test/data/script_invalid.json +++ b/src/test/data/script_invalid.json @@ -10,7 +10,7 @@ ["2147483648 0 ADD", "NOP", "arithmetic operands must be in range [-2^31...2^31] "], ["-2147483648 0 ADD", "NOP", "arithmetic operands must be in range [-2^31...2^31] "], ["2147483647 DUP ADD", "4294967294 NUMEQUAL", "NUMEQUAL must be in numeric range"], -["0xaabbccddeeff NOT", "0 EQUAL", "NOT is an arithmetic operand"], +["'abcdef' NOT", "0 EQUAL", "NOT is an arithmetic operand"], ["2 DUP MUL", "4 EQUAL", "disabled"], ["2 DUP DIV", "1 EQUAL", "disabled"], @@ -20,6 +20,10 @@ ["2 2 LSHIFT", "8 EQUAL", "disabled"], ["2 1 RSHIFT", "1 EQUAL", "disabled"], +["1","NOP1 NOP2 NOP3 NOP4 NOP5 NOP6 NOP7 NOP8 NOP9 NOP10 2 EQUAL"], +["'NOP_1_to_10' NOP1 NOP2 NOP3 NOP4 NOP5 NOP6 NOP7 NOP8 NOP9 NOP10","'NOP_1_to_11' EQUAL"], + +["0x50","1", "opcode 0x50 is reserved"], ["NOP1","NOP10"] ] diff --git a/src/test/data/script_valid.json b/src/test/data/script_valid.json index e7ad6d9c..f59d8b72 100644 --- a/src/test/data/script_valid.json +++ b/src/test/data/script_valid.json @@ -1,4 +1,12 @@ [ +["0x4c0107","7 EQUAL", "0x4c is OP_PUSHDATA1"], +["0x4d010008","8 EQUAL", "0x4d is OP_PUSHDATA2"], +["0x4e0100000009","9 EQUAL", "0x4e is OP_PUSHDATA4"], + +["0x4c00","0 EQUAL"], +["0x4d0000","0 EQUAL"], +["0x4e00000000","0 EQUAL"], + ["2 -2 ADD", "0 EQUAL"], ["2147483647 -2147483647 ADD", "0 EQUAL"], ["-1 -1 ADD", "-2 EQUAL"], @@ -73,6 +81,8 @@ ["2147483647 DUP ADD", "4294967294 EQUAL", ">32 bit EQUAL is valid"], ["2147483647 NEGATE DUP ADD", "-4294967294 EQUAL"], +["1","NOP1 NOP2 NOP3 NOP4 NOP5 NOP6 NOP7 NOP8 NOP9 NOP10 1 EQUAL"], +["'NOP_1_to_10' NOP1 NOP2 NOP3 NOP4 NOP5 NOP6 NOP7 NOP8 NOP9 NOP10","'NOP_1_to_10' EQUAL"], ["NOP","1"] ] diff --git a/src/test/script_tests.cpp b/src/test/script_tests.cpp index 745df4bd..a5fdaaa4 100644 --- a/src/test/script_tests.cpp +++ b/src/test/script_tests.cpp @@ -59,13 +59,15 @@ ParseScript(string s) } else if (starts_with(w, "0x") && IsHex(string(w.begin()+2, w.end()))) { - // Hex data: - result << ParseHex(string(w.begin()+2, w.end())); + // Raw hex data, inserted NOT pushed onto stack: + std::vector raw = ParseHex(string(w.begin()+2, w.end())); + result.insert(result.end(), raw.begin(), raw.end()); } - else if (s.size() >= 2 && starts_with(w, "'") && ends_with(w, "'")) + else if (w.size() >= 2 && starts_with(w, "'") && ends_with(w, "'")) { - // Single-quoted string, pushed as data: - std::vector value(s.begin()+1, s.end()-1); + // Single-quoted string, pushed as data. NOTE: this is poor-man's + // parsing, spaces/tabs/newlines in single-quoted strings won't work. + std::vector value(w.begin()+1, w.end()-1); result << value; } else if (mapOpNames.count(w))