Skip to content

Commit

Permalink
sync bitcoind script tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dajohi committed Aug 1, 2014
1 parent 24c3873 commit ef0ca7d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
6 changes: 6 additions & 0 deletions data/script_invalid.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand Down Expand Up @@ -349,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"],
Expand Down
4 changes: 4 additions & 0 deletions data/script_valid.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
[" 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"],
["0x02 0x417a", "'Az' EQUAL"],
Expand Down Expand Up @@ -64,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"],
Expand Down Expand Up @@ -126,6 +129,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"],
Expand Down
7 changes: 6 additions & 1 deletion opcode.go
Original file line number Diff line number Diff line change
Expand Up @@ -1858,9 +1858,14 @@ func opcodeCheckMultiSig(op *parsedOpcode, s *Script) error {
if err != nil {
return err
}

// PopInt promises that the int returned is 32 bit.
nsig := int(numSignatures.Int64())
if nsig < 0 {
return fmt.Errorf("number of signatures %d is less than 0", nsig)
}
if nsig > npk {
return fmt.Errorf("more signatures than pubkeys: %d > %d", nsig, npk)
}

sigStrings := make([][]byte, nsig)
signatures := make([]sig, 0, nsig)
Expand Down

0 comments on commit ef0ca7d

Please sign in to comment.