From ed02282bba468ec7224b7e836d3fe4543bf5ba1e Mon Sep 17 00:00:00 2001 From: Otto Allmendinger Date: Fri, 18 Jul 2014 10:29:49 +0200 Subject: [PATCH 1/6] additional test for OP_SIZE in script_valid.json --- src/test/data/script_valid.json | 1 + 1 file changed, 1 insertion(+) diff --git a/src/test/data/script_valid.json b/src/test/data/script_valid.json index 7546a3b1fe..2827126f29 100644 --- a/src/test/data/script_valid.json +++ b/src/test/data/script_valid.json @@ -126,6 +126,7 @@ ["-9223372036854775807", "SIZE 8 EQUAL"], ["'abcdefghijklmnopqrstuvwxyz'", "SIZE 26 EQUAL"], +["42", "SIZE 1 EQUALVERIFY 42 EQUAL", "SIZE does not consume argument"], ["2 -2 ADD", "0 EQUAL"], ["2147483647 -2147483647 ADD", "0 EQUAL"], From 0072d98849dd12de1599af894edbeee271fceb76 Mon Sep 17 00:00:00 2001 From: Otto Allmendinger Date: Fri, 18 Jul 2014 10:53:09 +0200 Subject: [PATCH 2/6] script tests: BOOLAND, BOOLOR decode to integer unlike other boolean checks, arguments >5 bytes invalidate the script --- src/test/data/script_invalid.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/test/data/script_invalid.json b/src/test/data/script_invalid.json index d623e974b8..eaac747fd2 100644 --- a/src/test/data/script_invalid.json +++ b/src/test/data/script_invalid.json @@ -272,6 +272,9 @@ ["2147483647", "1ADD 1SUB 1", "We cannot do math on 5-byte integers, even if the result is 4-bytes"], ["2147483648", "1SUB 1", "We cannot do math on 5-byte integers, even if the result is 4-bytes"], +["2147483648 1", "BOOLOR 1", "We cannot do BOOLOR on 5-byte integers (but we can still do IF etc)"], +["2147483648 1", "BOOLAND 1", "We cannot do BOOLAND on 5-byte integers"], + ["1", "1 ENDIF", "ENDIF without IF"], ["1", "IF 1", "IF without ENDIF"], ["1 IF 1", "ENDIF", "IFs don't carry over"], From 833ff161bc5e44ce59b16e0ce316818f8ae69d8a Mon Sep 17 00:00:00 2001 From: Otto Allmendinger Date: Fri, 18 Jul 2014 10:54:04 +0200 Subject: [PATCH 3/6] script tests: values that overflow to 0 are true --- src/test/data/script_valid.json | 1 + 1 file changed, 1 insertion(+) diff --git a/src/test/data/script_valid.json b/src/test/data/script_valid.json index 2827126f29..27778fb1d4 100644 --- a/src/test/data/script_valid.json +++ b/src/test/data/script_valid.json @@ -10,6 +10,7 @@ [" 1 2 ", "2 EQUALVERIFY 1 EQUAL"], ["1", ""], +["0x09 0x00000000 0x00000000 0x10", "", "equals zero when cast to Int64"], ["0x01 0x0b", "11 EQUAL", "push 1 byte"], ["0x02 0x417a", "'Az' EQUAL"], From 4cac5dbf83a3069e9d25051f4c832c537a527495 Mon Sep 17 00:00:00 2001 From: Otto Allmendinger Date: Fri, 18 Jul 2014 12:55:46 +0200 Subject: [PATCH 4/6] script tests: value with trailing 0x00 is true --- src/test/data/script_valid.json | 1 + 1 file changed, 1 insertion(+) diff --git a/src/test/data/script_valid.json b/src/test/data/script_valid.json index 27778fb1d4..af0326ad92 100644 --- a/src/test/data/script_valid.json +++ b/src/test/data/script_valid.json @@ -10,6 +10,7 @@ [" 1 2 ", "2 EQUALVERIFY 1 EQUAL"], ["1", ""], +["0x02 0x01 0x00", "", "all bytes are significant, not only the last one"], ["0x09 0x00000000 0x00000000 0x10", "", "equals zero when cast to Int64"], ["0x01 0x0b", "11 EQUAL", "push 1 byte"], From 89101c6e78d1640dae06a2b978b752e69aa504a0 Mon Sep 17 00:00:00 2001 From: Otto Allmendinger Date: Fri, 18 Jul 2014 15:41:45 +0200 Subject: [PATCH 5/6] script test: test case for 5-byte bools --- src/test/data/script_valid.json | 1 + 1 file changed, 1 insertion(+) diff --git a/src/test/data/script_valid.json b/src/test/data/script_valid.json index af0326ad92..082c65efed 100644 --- a/src/test/data/script_valid.json +++ b/src/test/data/script_valid.json @@ -66,6 +66,7 @@ ["0", "IF RETURN ENDIF 1", "RETURN only works if executed"], ["1 1", "VERIFY"], +["1 0x05 0x01 0x00 0x00 0x00 0x00", "VERIFY", "values >4 bytes can be cast to boolean"], ["10 0 11 TOALTSTACK DROP FROMALTSTACK", "ADD 21 EQUAL"], ["'gavin_was_here' TOALTSTACK 11 FROMALTSTACK", "'gavin_was_here' EQUALVERIFY 11 EQUAL"], From d2d9dc063f8da87e02e588064f8ea9253e201907 Mon Sep 17 00:00:00 2001 From: Otto Allmendinger Date: Fri, 18 Jul 2014 17:55:06 +0200 Subject: [PATCH 6/6] script tests: add tests for CHECKMULTISIG limits --- src/test/data/script_invalid.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/test/data/script_invalid.json b/src/test/data/script_invalid.json index eaac747fd2..e3e1ccbf3c 100644 --- a/src/test/data/script_invalid.json +++ b/src/test/data/script_invalid.json @@ -352,6 +352,9 @@ "NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP 0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p' 'q' 'r' 's' 't' 20 CHECKMULTISIGVERIFY 0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p' 'q' 'r' 's' 't' 20 CHECKMULTISIGVERIFY 0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p' 'q' 'r' 's' 't' 20 CHECKMULTISIGVERIFY 0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p' 'q' 'r' 's' 't' 20 CHECKMULTISIGVERIFY 0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p' 'q' 'r' 's' 't' 20 CHECKMULTISIGVERIFY 0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p' 'q' 'r' 's' 't' 20 CHECKMULTISIGVERIFY 0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p' 'q' 'r' 's' 't' 20 CHECKMULTISIGVERIFY 0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p' 'q' 'r' 's' 't' 20 CHECKMULTISIGVERIFY 0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p' 'q' 'r' 's' 't' 20 CHECKMULTISIGVERIFY"], +["0 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21", "21 CHECKMULTISIG 1", "nPubKeys > 20"], +["0 'sig' 1 0", "CHECKMULTISIG 1", "nSigs > nPubKeys"], + ["NOP 0x01 1", "HASH160 0x14 0xda1745e9b549bd0bfa1a569971c77eba30cd5a4b EQUAL", "Tests for Script.IsPushOnly()"], ["NOP1 0x01 1", "HASH160 0x14 0xda1745e9b549bd0bfa1a569971c77eba30cd5a4b EQUAL"],