Quick and dirty tests harnesses using some bitcoind test data.
Both the script tests (positive and negative) and tx texts (ditto) are present. Some of the tx tests in the negative section have been replaced by a comment line explaining why that test is elided, to add in diffing. The reasons were always that they test things handled by other parts of the btcd stack (normally chain). For example MAX_MONEY, number of outputs, coinbase sizes etc. Much of the inital test logic from @dajohi using hand transcribed tables for selected tests. The json parsers, script format parser and a lot of cleaning up/bugfixing from your truly. @davecgh had some input too.
This commit is contained in:
parent
5f6de02eb8
commit
8ec60d4678
7 changed files with 1508 additions and 101 deletions
8
data/LICENSE
Normal file
8
data/LICENSE
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
The json files in this directory come from the bitcoind project
|
||||||
|
(https://github.com/bitcoin/bitcoin) and is released under the following
|
||||||
|
license:
|
||||||
|
|
||||||
|
Copyright (c) 2012-2014 The Bitcoin Core developers
|
||||||
|
Distributed under the MIT/X11 software license, see the accompanying
|
||||||
|
file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
329
data/script_invalid.json
Normal file
329
data/script_invalid.json
Normal file
File diff suppressed because one or more lines are too long
415
data/script_valid.json
Normal file
415
data/script_valid.json
Normal file
File diff suppressed because one or more lines are too long
74
data/tx_invalid.json
Normal file
74
data/tx_invalid.json
Normal file
|
@ -0,0 +1,74 @@
|
||||||
|
[
|
||||||
|
["The following are deserialized transactions which are invalid."],
|
||||||
|
["They are in the form"],
|
||||||
|
["[[[prevout hash, prevout index, prevout scriptPubKey], [input 2], ...],"],
|
||||||
|
["serializedTransaction, enforceP2SH]"],
|
||||||
|
["Objects that are only a single string (like this one) are ignored"],
|
||||||
|
|
||||||
|
["0e1b5688cf179cd9f7cbda1fac0090f6e684bbf8cd946660120197c3f3681809 but with extra junk appended to the end of the scriptPubKey"],
|
||||||
|
[[["6ca7ec7b1847f6bdbd737176050e6a08d66ccd55bb94ad24f4018024107a5827", 0, "0x41 0x043b640e983c9690a14c039a2037ecc3467b27a0dcd58f19d76c7bc118d09fec45adc5370a1c5bf8067ca9f5557a4cf885fdb0fe0dcc9c3a7137226106fbc779a5 CHECKSIG VERIFY 1"]],
|
||||||
|
"010000000127587a10248001f424ad94bb55cd6cd6086a0e05767173bdbdf647187beca76c000000004948304502201b822ad10d6adc1a341ae8835be3f70a25201bbff31f59cbb9c5353a5f0eca18022100ea7b2f7074e9aa9cf70aa8d0ffee13e6b45dddabf1ab961bda378bcdb778fa4701ffffffff0100f2052a010000001976a914fc50c5907d86fed474ba5ce8b12a66e0a4c139d888ac00000000", true],
|
||||||
|
|
||||||
|
["This is the nearly-standard transaction with CHECKSIGVERIFY 1 instead of CHECKSIG from tx_valid.json"],
|
||||||
|
["but with the signature duplicated in the scriptPubKey with a non-standard pushdata prefix"],
|
||||||
|
["See FindAndDelete, which will only remove if it uses the same pushdata prefix as is standard"],
|
||||||
|
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "DUP HASH160 0x14 0x5b6462475454710f3c22f5fdf0b40704c92f25c3 EQUALVERIFY CHECKSIGVERIFY 1 0x4c 0x47 0x3044022067288ea50aa799543a536ff9306f8e1cba05b9c6b10951175b924f96732555ed022026d7b5265f38d21541519e4a1e55044d5b9e17e15cdbaf29ae3792e99e883e7a01"]],
|
||||||
|
"01000000010001000000000000000000000000000000000000000000000000000000000000000000006a473044022067288ea50aa799543a536ff9306f8e1cba05b9c6b10951175b924f96732555ed022026d7b5265f38d21541519e4a1e55044d5b9e17e15cdbaf29ae3792e99e883e7a012103ba8c8b86dea131c22ab967e6dd99bdae8eff7a1f75a2c35f1f944109e3fe5e22ffffffff010000000000000000015100000000", true],
|
||||||
|
|
||||||
|
["Same as above, but with the sig in the scriptSig also pushed with the same non-standard OP_PUSHDATA"],
|
||||||
|
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "DUP HASH160 0x14 0x5b6462475454710f3c22f5fdf0b40704c92f25c3 EQUALVERIFY CHECKSIGVERIFY 1 0x4c 0x47 0x3044022067288ea50aa799543a536ff9306f8e1cba05b9c6b10951175b924f96732555ed022026d7b5265f38d21541519e4a1e55044d5b9e17e15cdbaf29ae3792e99e883e7a01"]],
|
||||||
|
"01000000010001000000000000000000000000000000000000000000000000000000000000000000006b4c473044022067288ea50aa799543a536ff9306f8e1cba05b9c6b10951175b924f96732555ed022026d7b5265f38d21541519e4a1e55044d5b9e17e15cdbaf29ae3792e99e883e7a012103ba8c8b86dea131c22ab967e6dd99bdae8eff7a1f75a2c35f1f944109e3fe5e22ffffffff010000000000000000015100000000", true],
|
||||||
|
|
||||||
|
["An invalid P2SH Transaction"],
|
||||||
|
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "HASH160 0x14 0x7a052c840ba73af26755de42cf01cc9e0a49fef0 EQUAL"]],
|
||||||
|
"010000000100010000000000000000000000000000000000000000000000000000000000000000000009085768617420697320ffffffff010000000000000000015100000000", true],
|
||||||
|
|
||||||
|
["Tests for CheckTransaction()"],
|
||||||
|
["No inputs"],
|
||||||
|
["Skipped because this is not checked by btcscript, this is a problem for chain."],
|
||||||
|
|
||||||
|
["No outputs"],
|
||||||
|
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "HASH160 0x14 0x05ab9e14d983742513f0f451e105ffb4198d1dd4 EQUAL"]],
|
||||||
|
"01000000010001000000000000000000000000000000000000000000000000000000000000000000006d483045022100f16703104aab4e4088317c862daec83440242411b039d14280e03dd33b487ab802201318a7be236672c5c56083eb7a5a195bc57a40af7923ff8545016cd3b571e2a601232103c40e5d339df3f30bf753e7e04450ae4ef76c9e45587d1d993bdc4cd06f0651c7acffffffff0000000000", true],
|
||||||
|
|
||||||
|
["Negative output"],
|
||||||
|
["Removed because btcscript doesn't so tx sanity checking."],
|
||||||
|
|
||||||
|
["MAX_MONEY + 1 output"],
|
||||||
|
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "HASH160 0x14 0x32afac281462b822adbec5094b8d4d337dd5bd6a EQUAL"]],
|
||||||
|
"01000000010001000000000000000000000000000000000000000000000000000000000000000000006e493046022100e1eadba00d9296c743cb6ecc703fd9ddc9b3cd12906176a226ae4c18d6b00796022100a71aef7d2874deff681ba6080f1b278bac7bb99c61b08a85f4311970ffe7f63f012321030c0588dc44d92bdcbf8e72093466766fdc265ead8db64517b0c542275b70fffbacffffffff010140075af0750700015100000000", true],
|
||||||
|
|
||||||
|
["MAX_MONEY output + 1 output"],
|
||||||
|
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "HASH160 0x14 0xb558cbf4930954aa6a344363a15668d7477ae716 EQUAL"]],
|
||||||
|
"01000000010001000000000000000000000000000000000000000000000000000000000000000000006d483045022027deccc14aa6668e78a8c9da3484fbcd4f9dcc9bb7d1b85146314b21b9ae4d86022100d0b43dece8cfb07348de0ca8bc5b86276fa88f7f2138381128b7c36ab2e42264012321029bb13463ddd5d2cc05da6e84e37536cb9525703cfd8f43afdb414988987a92f6acffffffff020040075af075070001510001000000000000015100000000", true],
|
||||||
|
|
||||||
|
["Duplicate inputs"],
|
||||||
|
["Removed because btcscript doesn't check input duplication, btcchain does"],
|
||||||
|
|
||||||
|
["Coinbase of size 1"],
|
||||||
|
["Note the input is just required to make the tester happy"],
|
||||||
|
["Removed because btcscript dooesn't handle coinbase checking, btcchain does"],
|
||||||
|
|
||||||
|
["Coinbase of size 101"],
|
||||||
|
["Note the input is just required to make the tester happy"],
|
||||||
|
["Removed because btcscript dooesn't handle coinbase checking, btcchain does"],
|
||||||
|
|
||||||
|
["Null txin"],
|
||||||
|
["Removed because btcscript doesn't do tx sanity checking."],
|
||||||
|
|
||||||
|
["Same as the transactions in valid with one input SIGHASH_ALL and one SIGHASH_ANYONECANPAY, but we set the _ANYONECANPAY sequence number, invalidating the SIGHASH_ALL signature"],
|
||||||
|
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "0x21 0x035e7f0d4d0841bcd56c39337ed086b1a633ee770c1ffdd94ac552a95ac2ce0efc CHECKSIG"],
|
||||||
|
["0000000000000000000000000000000000000000000000000000000000000200", 0, "0x21 0x035e7f0d4d0841bcd56c39337ed086b1a633ee770c1ffdd94ac552a95ac2ce0efc CHECKSIG"]],
|
||||||
|
"01000000020001000000000000000000000000000000000000000000000000000000000000000000004948304502203a0f5f0e1f2bdbcd04db3061d18f3af70e07f4f467cbc1b8116f267025f5360b022100c792b6e215afc5afc721a351ec413e714305cb749aae3d7fee76621313418df10101000000000200000000000000000000000000000000000000000000000000000000000000000000484730440220201dc2d030e380e8f9cfb41b442d930fa5a685bb2c8db5906671f865507d0670022018d9e7a8d4c8d86a73c2a724ee38ef983ec249827e0e464841735955c707ece98101000000010100000000000000015100000000", true],
|
||||||
|
|
||||||
|
["Incorrect signature order"],
|
||||||
|
["Note the input is just required to make the tester happy"],
|
||||||
|
[[["b3da01dd4aae683c7aee4d5d8b52a540a508e1115f77cd7fa9a291243f501223", 0, "HASH160 0x14 0xb1ce99298d5f07364b57b1e5c9cc00be0b04a954 EQUAL"]],
|
||||||
|
"01000000012312503f2491a2a97fcd775f11e108a540a5528b5d4dee7a3c68ae4add01dab300000000fdfe000048304502207aacee820e08b0b174e248abd8d7a34ed63b5da3abedb99934df9fddd65c05c4022100dfe87896ab5ee3df476c2655f9fbe5bd089dccbef3e4ea05b5d121169fe7f5f401483045022100f6649b0eddfdfd4ad55426663385090d51ee86c3481bdc6b0c18ea6c0ece2c0b0220561c315b07cffa6f7dd9df96dbae9200c2dee09bf93cc35ca05e6cdf613340aa014c695221031d11db38972b712a9fe1fc023577c7ae3ddb4a3004187d41c45121eecfdbb5b7210207ec36911b6ad2382860d32989c7b8728e9489d7bbc94a6b5509ef0029be128821024ea9fac06f666a4adc3fc1357b7bec1fd0bdece2b9d08579226a8ebde53058e453aeffffffff0180380100000000001976a914c9b99cddf847d10685a4fabaa0baf505f7c3dfab88ac00000000", true],
|
||||||
|
|
||||||
|
["Empty stack when we try to run CHECKSIG"],
|
||||||
|
[[["ad503f72c18df5801ee64d76090afe4c607fb2b822e9b7b63c5826c50e22fc3b", 0, "0x21 0x027c3a97665bf283a102a587a62a30a0c102d4d3b141015e2cae6f64e2543113e5 CHECKSIG NOT"]],
|
||||||
|
"01000000013bfc220ec526583cb6b7e922b8b27f604cfe0a09764de61e80f58dc1723f50ad0000000000ffffffff0101000000000000002321027c3a97665bf283a102a587a62a30a0c102d4d3b141015e2cae6f64e2543113e5ac00000000", true],
|
||||||
|
|
||||||
|
["Make diffs cleaner by leaving a comment here without comma at the end"]
|
||||||
|
]
|
122
data/tx_valid.json
Normal file
122
data/tx_valid.json
Normal file
|
@ -0,0 +1,122 @@
|
||||||
|
[
|
||||||
|
["The following are deserialized transactions which are valid."],
|
||||||
|
["They are in the form"],
|
||||||
|
["[[[prevout hash, prevout index, prevout scriptPubKey], [input 2], ...],"],
|
||||||
|
["serializedTransaction, enforceP2SH]"],
|
||||||
|
["Objects that are only a single string (like this one) are ignored"],
|
||||||
|
|
||||||
|
["The following is 23b397edccd3740a74adb603c9756370fafcde9bcc4483eb271ecad09a94dd63"],
|
||||||
|
["It is of particular interest because it contains an invalidly-encoded signature which OpenSSL accepts"],
|
||||||
|
["See http://r6.ca/blog/20111119T211504Z.html"],
|
||||||
|
["It is also the first OP_CHECKMULTISIG transaction in standard form"],
|
||||||
|
[[["60a20bd93aa49ab4b28d514ec10b06e1829ce6818ec06cd3aabd013ebcdc4bb1", 0, "1 0x41 0x04cc71eb30d653c0c3163990c47b976f3fb3f37cccdcbedb169a1dfef58bbfbfaff7d8a473e7e2e6d317b87bafe8bde97e3cf8f065dec022b51d11fcdd0d348ac4 0x41 0x0461cbdcc5409fb4b4d42b51d33381354d80e550078cb532a34bfa2fcfdeb7d76519aecc62770f5b0e4ef8551946d8a540911abe3e7854a26f39f58b25c15342af 2 OP_CHECKMULTISIG"]],
|
||||||
|
"0100000001b14bdcbc3e01bdaad36cc08e81e69c82e1060bc14e518db2b49aa43ad90ba26000000000490047304402203f16c6f40162ab686621ef3000b04e75418a0c0cb2d8aebeac894ae360ac1e780220ddc15ecdfc3507ac48e1681a33eb60996631bf6bf5bc0a0682c4db743ce7ca2b01ffffffff0140420f00000000001976a914660d4ef3a743e3e696ad990364e555c271ad504b88ac00000000", true],
|
||||||
|
|
||||||
|
["The following is a tweaked form of 23b397edccd3740a74adb603c9756370fafcde9bcc4483eb271ecad09a94dd63"],
|
||||||
|
["It has an arbitrary extra byte stuffed into the signature at pos length - 2"],
|
||||||
|
[[["60a20bd93aa49ab4b28d514ec10b06e1829ce6818ec06cd3aabd013ebcdc4bb1", 0, "1 0x41 0x04cc71eb30d653c0c3163990c47b976f3fb3f37cccdcbedb169a1dfef58bbfbfaff7d8a473e7e2e6d317b87bafe8bde97e3cf8f065dec022b51d11fcdd0d348ac4 0x41 0x0461cbdcc5409fb4b4d42b51d33381354d80e550078cb532a34bfa2fcfdeb7d76519aecc62770f5b0e4ef8551946d8a540911abe3e7854a26f39f58b25c15342af 2 OP_CHECKMULTISIG"]],
|
||||||
|
"0100000001b14bdcbc3e01bdaad36cc08e81e69c82e1060bc14e518db2b49aa43ad90ba260000000004A0048304402203f16c6f40162ab686621ef3000b04e75418a0c0cb2d8aebeac894ae360ac1e780220ddc15ecdfc3507ac48e1681a33eb60996631bf6bf5bc0a0682c4db743ce7ca2bab01ffffffff0140420f00000000001976a914660d4ef3a743e3e696ad990364e555c271ad504b88ac00000000", true],
|
||||||
|
|
||||||
|
["The following is c99c49da4c38af669dea436d3e73780dfdb6c1ecf9958baa52960e8baee30e73"],
|
||||||
|
["It is of interest because it contains a 0-sequence as well as a signature of SIGHASH type 0 (which is not a real type)"],
|
||||||
|
[[["406b2b06bcd34d3c8733e6b79f7a394c8a431fbf4ff5ac705c93f4076bb77602", 0, "DUP HASH160 0x14 0xdc44b1164188067c3a32d4780f5996fa14a4f2d9 EQUALVERIFY CHECKSIG"]],
|
||||||
|
"01000000010276b76b07f4935c70acf54fbf1f438a4c397a9fb7e633873c4dd3bc062b6b40000000008c493046022100d23459d03ed7e9511a47d13292d3430a04627de6235b6e51a40f9cd386f2abe3022100e7d25b080f0bb8d8d5f878bba7d54ad2fda650ea8d158a33ee3cbd11768191fd004104b0e2c879e4daf7b9ab68350228c159766676a14f5815084ba166432aab46198d4cca98fa3e9981d0a90b2effc514b76279476550ba3663fdcaff94c38420e9d5000000000100093d00000000001976a9149a7b0f3b80c6baaeedce0a0842553800f832ba1f88ac00000000", true],
|
||||||
|
|
||||||
|
["A nearly-standard transaction with CHECKSIGVERIFY 1 instead of CHECKSIG"],
|
||||||
|
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "DUP HASH160 0x14 0x5b6462475454710f3c22f5fdf0b40704c92f25c3 EQUALVERIFY CHECKSIGVERIFY 1"]],
|
||||||
|
"01000000010001000000000000000000000000000000000000000000000000000000000000000000006a473044022067288ea50aa799543a536ff9306f8e1cba05b9c6b10951175b924f96732555ed022026d7b5265f38d21541519e4a1e55044d5b9e17e15cdbaf29ae3792e99e883e7a012103ba8c8b86dea131c22ab967e6dd99bdae8eff7a1f75a2c35f1f944109e3fe5e22ffffffff010000000000000000015100000000", true],
|
||||||
|
|
||||||
|
["Same as above, but with the signature duplicated in the scriptPubKey with the proper pushdata prefix"],
|
||||||
|
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "DUP HASH160 0x14 0x5b6462475454710f3c22f5fdf0b40704c92f25c3 EQUALVERIFY CHECKSIGVERIFY 1 0x47 0x3044022067288ea50aa799543a536ff9306f8e1cba05b9c6b10951175b924f96732555ed022026d7b5265f38d21541519e4a1e55044d5b9e17e15cdbaf29ae3792e99e883e7a01"]],
|
||||||
|
"01000000010001000000000000000000000000000000000000000000000000000000000000000000006a473044022067288ea50aa799543a536ff9306f8e1cba05b9c6b10951175b924f96732555ed022026d7b5265f38d21541519e4a1e55044d5b9e17e15cdbaf29ae3792e99e883e7a012103ba8c8b86dea131c22ab967e6dd99bdae8eff7a1f75a2c35f1f944109e3fe5e22ffffffff010000000000000000015100000000", true],
|
||||||
|
|
||||||
|
["The following is f7fdd091fa6d8f5e7a8c2458f5c38faffff2d3f1406b6e4fe2c99dcc0d2d1cbb"],
|
||||||
|
["It caught a bug in the workaround for 23b397edccd3740a74adb603c9756370fafcde9bcc4483eb271ecad09a94dd63 in an overly simple implementation"],
|
||||||
|
[[["b464e85df2a238416f8bdae11d120add610380ea07f4ef19c5f9dfd472f96c3d", 0, "DUP HASH160 0x14 0xbef80ecf3a44500fda1bc92176e442891662aed2 EQUALVERIFY CHECKSIG"],
|
||||||
|
["b7978cc96e59a8b13e0865d3f95657561a7f725be952438637475920bac9eb21", 1, "DUP HASH160 0x14 0xbef80ecf3a44500fda1bc92176e442891662aed2 EQUALVERIFY CHECKSIG"]],
|
||||||
|
"01000000023d6cf972d4dff9c519eff407ea800361dd0a121de1da8b6f4138a2f25de864b4000000008a4730440220ffda47bfc776bcd269da4832626ac332adfca6dd835e8ecd83cd1ebe7d709b0e022049cffa1cdc102a0b56e0e04913606c70af702a1149dc3b305ab9439288fee090014104266abb36d66eb4218a6dd31f09bb92cf3cfa803c7ea72c1fc80a50f919273e613f895b855fb7465ccbc8919ad1bd4a306c783f22cd3227327694c4fa4c1c439affffffff21ebc9ba20594737864352e95b727f1a565756f9d365083eb1a8596ec98c97b7010000008a4730440220503ff10e9f1e0de731407a4a245531c9ff17676eda461f8ceeb8c06049fa2c810220c008ac34694510298fa60b3f000df01caa244f165b727d4896eb84f81e46bcc4014104266abb36d66eb4218a6dd31f09bb92cf3cfa803c7ea72c1fc80a50f919273e613f895b855fb7465ccbc8919ad1bd4a306c783f22cd3227327694c4fa4c1c439affffffff01f0da5200000000001976a914857ccd42dded6df32949d4646dfa10a92458cfaa88ac00000000", true],
|
||||||
|
|
||||||
|
["The following tests for the presence of a bug in the handling of SIGHASH_SINGLE"],
|
||||||
|
["It results in signing the constant 1, instead of something generated based on the transaction,"],
|
||||||
|
["when the input doing the signing has an index greater than the maximum output index"],
|
||||||
|
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "DUP HASH160 0x14 0xe52b482f2faa8ecbf0db344f93c84ac908557f33 EQUALVERIFY CHECKSIG"], ["0000000000000000000000000000000000000000000000000000000000000200", 0, "1"]],
|
||||||
|
"01000000020002000000000000000000000000000000000000000000000000000000000000000000000151ffffffff0001000000000000000000000000000000000000000000000000000000000000000000006b483045022100c9cdd08798a28af9d1baf44a6c77bcc7e279f47dc487c8c899911bc48feaffcc0220503c5c50ae3998a733263c5c0f7061b483e2b56c4c41b456e7d2f5a78a74c077032102d5c25adb51b61339d2b05315791e21bbe80ea470a49db0135720983c905aace0ffffffff010000000000000000015100000000", true],
|
||||||
|
|
||||||
|
["An invalid P2SH Transaction"],
|
||||||
|
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "HASH160 0x14 0x7a052c840ba73af26755de42cf01cc9e0a49fef0 EQUAL"]],
|
||||||
|
"010000000100010000000000000000000000000000000000000000000000000000000000000000000009085768617420697320ffffffff010000000000000000015100000000", false],
|
||||||
|
|
||||||
|
["A valid P2SH Transaction using the standard transaction type put forth in BIP 16"],
|
||||||
|
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "HASH160 0x14 0x8febbed40483661de6958d957412f82deed8e2f7 EQUAL"]],
|
||||||
|
"01000000010001000000000000000000000000000000000000000000000000000000000000000000006e493046022100c66c9cdf4c43609586d15424c54707156e316d88b0a1534c9e6b0d4f311406310221009c0fe51dbc9c4ab7cc25d3fdbeccf6679fe6827f08edf2b4a9f16ee3eb0e438a0123210338e8034509af564c62644c07691942e0c056752008a173c89f60ab2a88ac2ebfacffffffff010000000000000000015100000000", true],
|
||||||
|
|
||||||
|
["Tests for CheckTransaction()"],
|
||||||
|
["MAX_MONEY output"],
|
||||||
|
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "HASH160 0x14 0x32afac281462b822adbec5094b8d4d337dd5bd6a EQUAL"]],
|
||||||
|
"01000000010001000000000000000000000000000000000000000000000000000000000000000000006e493046022100e1eadba00d9296c743cb6ecc703fd9ddc9b3cd12906176a226ae4c18d6b00796022100a71aef7d2874deff681ba6080f1b278bac7bb99c61b08a85f4311970ffe7f63f012321030c0588dc44d92bdcbf8e72093466766fdc265ead8db64517b0c542275b70fffbacffffffff010040075af0750700015100000000", true],
|
||||||
|
|
||||||
|
["MAX_MONEY output + 0 output"],
|
||||||
|
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "HASH160 0x14 0xb558cbf4930954aa6a344363a15668d7477ae716 EQUAL"]],
|
||||||
|
"01000000010001000000000000000000000000000000000000000000000000000000000000000000006d483045022027deccc14aa6668e78a8c9da3484fbcd4f9dcc9bb7d1b85146314b21b9ae4d86022100d0b43dece8cfb07348de0ca8bc5b86276fa88f7f2138381128b7c36ab2e42264012321029bb13463ddd5d2cc05da6e84e37536cb9525703cfd8f43afdb414988987a92f6acffffffff020040075af075070001510000000000000000015100000000", true],
|
||||||
|
|
||||||
|
["Coinbase of size 2"],
|
||||||
|
["Note the input is just required to make the tester happy"],
|
||||||
|
[[["0000000000000000000000000000000000000000000000000000000000000000", -1, "1"]],
|
||||||
|
"01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff025151ffffffff010000000000000000015100000000", true],
|
||||||
|
|
||||||
|
["Coinbase of size 100"],
|
||||||
|
["Note the input is just required to make the tester happy"],
|
||||||
|
[[["0000000000000000000000000000000000000000000000000000000000000000", -1, "1"]],
|
||||||
|
"01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff6451515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151ffffffff010000000000000000015100000000", true],
|
||||||
|
|
||||||
|
["Simple transaction with first input is signed with SIGHASH_ALL, second with SIGHASH_ANYONECANPAY"],
|
||||||
|
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "0x21 0x035e7f0d4d0841bcd56c39337ed086b1a633ee770c1ffdd94ac552a95ac2ce0efc CHECKSIG"],
|
||||||
|
["0000000000000000000000000000000000000000000000000000000000000200", 0, "0x21 0x035e7f0d4d0841bcd56c39337ed086b1a633ee770c1ffdd94ac552a95ac2ce0efc CHECKSIG"]],
|
||||||
|
"010000000200010000000000000000000000000000000000000000000000000000000000000000000049483045022100d180fd2eb9140aeb4210c9204d3f358766eb53842b2a9473db687fa24b12a3cc022079781799cd4f038b85135bbe49ec2b57f306b2bb17101b17f71f000fcab2b6fb01ffffffff0002000000000000000000000000000000000000000000000000000000000000000000004847304402205f7530653eea9b38699e476320ab135b74771e1c48b81a5d041e2ca84b9be7a802200ac8d1f40fb026674fe5a5edd3dea715c27baa9baca51ed45ea750ac9dc0a55e81ffffffff010100000000000000015100000000", true],
|
||||||
|
|
||||||
|
["Same as above, but we change the sequence number of the first input to check that SIGHASH_ANYONECANPAY is being followed"],
|
||||||
|
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "0x21 0x035e7f0d4d0841bcd56c39337ed086b1a633ee770c1ffdd94ac552a95ac2ce0efc CHECKSIG"],
|
||||||
|
["0000000000000000000000000000000000000000000000000000000000000200", 0, "0x21 0x035e7f0d4d0841bcd56c39337ed086b1a633ee770c1ffdd94ac552a95ac2ce0efc CHECKSIG"]],
|
||||||
|
"01000000020001000000000000000000000000000000000000000000000000000000000000000000004948304502203a0f5f0e1f2bdbcd04db3061d18f3af70e07f4f467cbc1b8116f267025f5360b022100c792b6e215afc5afc721a351ec413e714305cb749aae3d7fee76621313418df101010000000002000000000000000000000000000000000000000000000000000000000000000000004847304402205f7530653eea9b38699e476320ab135b74771e1c48b81a5d041e2ca84b9be7a802200ac8d1f40fb026674fe5a5edd3dea715c27baa9baca51ed45ea750ac9dc0a55e81ffffffff010100000000000000015100000000", true],
|
||||||
|
|
||||||
|
["afd9c17f8913577ec3509520bd6e5d63e9c0fd2a5f70c787993b097ba6ca9fae which has several SIGHASH_SINGLE signatures"],
|
||||||
|
[[["63cfa5a09dc540bf63e53713b82d9ea3692ca97cd608c384f2aa88e51a0aac70", 0, "DUP HASH160 0x14 0xdcf72c4fd02f5a987cf9b02f2fabfcac3341a87d EQUALVERIFY CHECKSIG"],
|
||||||
|
["04e8d0fcf3846c6734477b98f0f3d4badfb78f020ee097a0be5fe347645b817d", 1, "DUP HASH160 0x14 0xdcf72c4fd02f5a987cf9b02f2fabfcac3341a87d EQUALVERIFY CHECKSIG"],
|
||||||
|
["ee1377aff5d0579909e11782e1d2f5f7b84d26537be7f5516dd4e43373091f3f", 1, "DUP HASH160 0x14 0xdcf72c4fd02f5a987cf9b02f2fabfcac3341a87d EQUALVERIFY CHECKSIG"]],
|
||||||
|
"010000000370ac0a1ae588aaf284c308d67ca92c69a39e2db81337e563bf40c59da0a5cf63000000006a4730440220360d20baff382059040ba9be98947fd678fb08aab2bb0c172efa996fd8ece9b702201b4fb0de67f015c90e7ac8a193aeab486a1f587e0f54d0fb9552ef7f5ce6caec032103579ca2e6d107522f012cd00b52b9a65fb46f0c57b9b8b6e377c48f526a44741affffffff7d815b6447e35fbea097e00e028fb7dfbad4f3f0987b4734676c84f3fcd0e804010000006b483045022100c714310be1e3a9ff1c5f7cacc65c2d8e781fc3a88ceb063c6153bf950650802102200b2d0979c76e12bb480da635f192cc8dc6f905380dd4ac1ff35a4f68f462fffd032103579ca2e6d107522f012cd00b52b9a65fb46f0c57b9b8b6e377c48f526a44741affffffff3f1f097333e4d46d51f5e77b53264db8f7f5d2e18217e1099957d0f5af7713ee010000006c493046022100b663499ef73273a3788dea342717c2640ac43c5a1cf862c9e09b206fcb3f6bb8022100b09972e75972d9148f2bdd462e5cb69b57c1214b88fc55ca638676c07cfc10d8032103579ca2e6d107522f012cd00b52b9a65fb46f0c57b9b8b6e377c48f526a44741affffffff0380841e00000000001976a914bfb282c70c4191f45b5a6665cad1682f2c9cfdfb88ac80841e00000000001976a9149857cc07bed33a5cf12b9c5e0500b675d500c81188ace0fd1c00000000001976a91443c52850606c872403c0601e69fa34b26f62db4a88ac00000000", true],
|
||||||
|
|
||||||
|
["ddc454a1c0c35c188c98976b17670f69e586d9c0f3593ea879928332f0a069e7, which spends an input that pushes using a PUSHDATA1 that is negative when read as signed"],
|
||||||
|
[[["c5510a5dd97a25f43175af1fe649b707b1df8e1a41489bac33a23087027a2f48", 0, "0x4c 0xae 0x606563686f2022553246736447566b58312b5a536e587574356542793066794778625456415675534a6c376a6a334878416945325364667657734f53474f36633338584d7439435c6e543249584967306a486956304f376e775236644546673d3d22203e20743b206f70656e73736c20656e63202d7061737320706173733a5b314a564d7751432d707269766b65792d6865785d202d64202d6165732d3235362d636263202d61202d696e207460 DROP DUP HASH160 0x14 0xbfd7436b6265aa9de506f8a994f881ff08cc2872 EQUALVERIFY CHECKSIG"]],
|
||||||
|
"0100000001482f7a028730a233ac9b48411a8edfb107b749e61faf7531f4257ad95d0a51c5000000008b483045022100bf0bbae9bde51ad2b222e87fbf67530fbafc25c903519a1e5dcc52a32ff5844e022028c4d9ad49b006dd59974372a54291d5764be541574bb0c4dc208ec51f80b7190141049dd4aad62741dc27d5f267f7b70682eee22e7e9c1923b9c0957bdae0b96374569b460eb8d5b40d972e8c7c0ad441de3d94c4a29864b212d56050acb980b72b2bffffffff0180969800000000001976a914e336d0017a9d28de99d16472f6ca6d5a3a8ebc9988ac00000000", true],
|
||||||
|
|
||||||
|
["Correct signature order"],
|
||||||
|
["Note the input is just required to make the tester happy"],
|
||||||
|
[[["b3da01dd4aae683c7aee4d5d8b52a540a508e1115f77cd7fa9a291243f501223", 0, "HASH160 0x14 0xb1ce99298d5f07364b57b1e5c9cc00be0b04a954 EQUAL"]],
|
||||||
|
"01000000012312503f2491a2a97fcd775f11e108a540a5528b5d4dee7a3c68ae4add01dab300000000fdfe0000483045022100f6649b0eddfdfd4ad55426663385090d51ee86c3481bdc6b0c18ea6c0ece2c0b0220561c315b07cffa6f7dd9df96dbae9200c2dee09bf93cc35ca05e6cdf613340aa0148304502207aacee820e08b0b174e248abd8d7a34ed63b5da3abedb99934df9fddd65c05c4022100dfe87896ab5ee3df476c2655f9fbe5bd089dccbef3e4ea05b5d121169fe7f5f4014c695221031d11db38972b712a9fe1fc023577c7ae3ddb4a3004187d41c45121eecfdbb5b7210207ec36911b6ad2382860d32989c7b8728e9489d7bbc94a6b5509ef0029be128821024ea9fac06f666a4adc3fc1357b7bec1fd0bdece2b9d08579226a8ebde53058e453aeffffffff0180380100000000001976a914c9b99cddf847d10685a4fabaa0baf505f7c3dfab88ac00000000", true],
|
||||||
|
|
||||||
|
["cc60b1f899ec0a69b7c3f25ddf32c4524096a9c5b01cbd84c6d0312a0c478984, which is a fairly strange transaction which relies on OP_CHECKSIG returning 0 when checking a completely invalid sig of length 0"],
|
||||||
|
[[["cbebc4da731e8995fe97f6fadcd731b36ad40e5ecb31e38e904f6e5982fa09f7", 0, "0x2102085c6600657566acc2d6382a47bc3f324008d2aa10940dd7705a48aa2a5a5e33ac7c2103f5d0fb955f95dd6be6115ce85661db412ec6a08abcbfce7da0ba8297c6cc0ec4ac7c5379a820d68df9e32a147cffa36193c6f7c43a1c8c69cda530e1c6db354bfabdcfefaf3c875379a820f531f3041d3136701ea09067c53e7159c8f9b2746a56c3d82966c54bbc553226879a5479827701200122a59a5379827701200122a59a6353798277537982778779679a68"]],
|
||||||
|
"0100000001f709fa82596e4f908ee331cb5e0ed46ab331d7dcfaf697fe95891e73dac4ebcb000000008c20ca42095840735e89283fec298e62ac2ddea9b5f34a8cbb7097ad965b87568100201b1b01dc829177da4a14551d2fc96a9db00c6501edfa12f22cd9cefd335c227f483045022100a9df60536df5733dd0de6bc921fab0b3eee6426501b43a228afa2c90072eb5ca02201c78b74266fac7d1db5deff080d8a403743203f109fbcabf6d5a760bf87386d20100ffffffff01c075790000000000232103611f9a45c18f28f06f19076ad571c344c82ce8fcfe34464cf8085217a2d294a6ac00000000", true],
|
||||||
|
|
||||||
|
["Empty pubkey"],
|
||||||
|
[[["229257c295e7f555421c1bfec8538dd30a4b5c37c1c8810bbe83cafa7811652c", 0, "0x00 CHECKSIG NOT"]],
|
||||||
|
"01000000012c651178faca83be0b81c8c1375c4b0ad38d53c8fe1b1c4255f5e795c25792220000000049483045022100d6044562284ac76c985018fc4a90127847708c9edb280996c507b28babdc4b2a02203d74eca3f1a4d1eea7ff77b528fde6d5dc324ec2dbfdb964ba885f643b9704cd01ffffffff010100000000000000232102c2410f8891ae918cab4ffc4bb4a3b0881be67c7a1e7faa8b5acf9ab8932ec30cac00000000", true],
|
||||||
|
|
||||||
|
["Empty signature"],
|
||||||
|
[[["9ca93cfd8e3806b9d9e2ba1cf64e3cc6946ee0119670b1796a09928d14ea25f7", 0, "0x21 0x028a1d66975dbdf97897e3a4aef450ebeb5b5293e4a0b4a6d3a2daaa0b2b110e02 CHECKSIG NOT"]],
|
||||||
|
"0100000001f725ea148d92096a79b1709611e06e94c63c4ef61cbae2d9b906388efd3ca99c000000000100ffffffff0101000000000000002321028a1d66975dbdf97897e3a4aef450ebeb5b5293e4a0b4a6d3a2daaa0b2b110e02ac00000000", true],
|
||||||
|
|
||||||
|
[[["444e00ed7840d41f20ecd9c11d3f91982326c731a02f3c05748414a4fa9e59be", 0, "1 0x00 0x21 0x02136b04758b0b6e363e7a6fbe83aaf527a153db2b060d36cc29f7f8309ba6e458 2 CHECKMULTISIG"]],
|
||||||
|
"0100000001be599efaa4148474053c2fa031c7262398913f1dc1d9ec201fd44078ed004e44000000004900473044022022b29706cb2ed9ef0cb3c97b72677ca2dfd7b4160f7b4beb3ba806aa856c401502202d1e52582412eba2ed474f1f437a427640306fd3838725fab173ade7fe4eae4a01ffffffff010100000000000000232103ac4bba7e7ca3e873eea49e08132ad30c7f03640b6539e9b59903cf14fd016bbbac00000000", true],
|
||||||
|
|
||||||
|
[[["e16abbe80bf30c080f63830c8dbf669deaef08957446e95940227d8c5e6db612", 0, "1 0x21 0x03905380c7013e36e6e19d305311c1b81fce6581f5ee1c86ef0627c68c9362fc9f 0x00 2 CHECKMULTISIG"]],
|
||||||
|
"010000000112b66d5e8c7d224059e946749508efea9d66bf8d0c83630f080cf30be8bb6ae100000000490047304402206ffe3f14caf38ad5c1544428e99da76ffa5455675ec8d9780fac215ca17953520220779502985e194d84baa36b9bd40a0dbd981163fa191eb884ae83fc5bd1c86b1101ffffffff010100000000000000232103905380c7013e36e6e19d305311c1b81fce6581f5ee1c86ef0627c68c9362fc9fac00000000", true],
|
||||||
|
|
||||||
|
[[["ebbcf4bfce13292bd791d6a65a2a858d59adbf737e387e40370d4e64cc70efb0", 0, "2 0x21 0x033bcaa0a602f0d44cc9d5637c6e515b0471db514c020883830b7cefd73af04194 0x21 0x03a88b326f8767f4f192ce252afe33c94d25ab1d24f27f159b3cb3aa691ffe1423 2 CHECKMULTISIG NOT"]],
|
||||||
|
"0100000001b0ef70cc644e0d37407e387e73bfad598d852a5aa6d691d72b2913cebff4bceb000000004a00473044022068cd4851fc7f9a892ab910df7a24e616f293bcb5c5fbdfbc304a194b26b60fba022078e6da13d8cb881a22939b952c24f88b97afd06b4c47a47d7f804c9a352a6d6d0100ffffffff0101000000000000002321033bcaa0a602f0d44cc9d5637c6e515b0471db514c020883830b7cefd73af04194ac00000000", true],
|
||||||
|
|
||||||
|
[[["ba4cd7ae2ad4d4d13ebfc8ab1d93a63e4a6563f25089a18bf0fc68f282aa88c1", 0, "2 0x21 0x037c615d761e71d38903609bf4f46847266edc2fb37532047d747ba47eaae5ffe1 0x21 0x02edc823cd634f2c4033d94f5755207cb6b60c4b1f1f056ad7471c47de5f2e4d50 2 CHECKMULTISIG NOT"]],
|
||||||
|
"0100000001c188aa82f268fcf08ba18950f263654a3ea6931dabc8bf3ed1d4d42aaed74cba000000004b0000483045022100940378576e069aca261a6b26fb38344e4497ca6751bb10905c76bb689f4222b002204833806b014c26fd801727b792b1260003c55710f87c5adbd7a9cb57446dbc9801ffffffff0101000000000000002321037c615d761e71d38903609bf4f46847266edc2fb37532047d747ba47eaae5ffe1ac00000000", true],
|
||||||
|
|
||||||
|
["Make diffs cleaner by leaving a comment here without comma at the end"]
|
||||||
|
]
|
458
internal_test.go
458
internal_test.go
|
@ -6,8 +6,16 @@ package btcscript
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/ecdsa"
|
"crypto/ecdsa"
|
||||||
|
"encoding/hex"
|
||||||
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"github.com/conformal/btcutil"
|
||||||
"github.com/conformal/btcwire"
|
"github.com/conformal/btcwire"
|
||||||
"io"
|
"io"
|
||||||
|
"io/ioutil"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -3731,3 +3739,453 @@ func TestUnparsingInvalidOpcodes(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// parse hex string into a []byte.
|
||||||
|
func parseHex(tok string) ([]byte, error) {
|
||||||
|
if !strings.HasPrefix(tok, "0x") {
|
||||||
|
return nil, errors.New("not a hex number")
|
||||||
|
}
|
||||||
|
return hex.DecodeString(tok[2:])
|
||||||
|
}
|
||||||
|
|
||||||
|
// ParseShortForm parses a string as as used in the bitcoind reference tests
|
||||||
|
// into the script it came from.
|
||||||
|
func ParseShortForm(script string) ([]byte, error) {
|
||||||
|
ops := make(map[string]*opcode)
|
||||||
|
|
||||||
|
// the format used for these tests is pretty simple if ad-hoc:
|
||||||
|
// - opcodes other than the push opcodes and unknown are present as
|
||||||
|
// either OP_NAME or just NAME
|
||||||
|
// - plain numbers are made into push operations
|
||||||
|
// - numbers beginning with 0x are inserted into the []byte as-is (so
|
||||||
|
// 0x14 is OP_DATA_20)
|
||||||
|
// - single quoted strings are pushed as data.
|
||||||
|
// - anything else is an error.
|
||||||
|
for _, op := range opcodemap {
|
||||||
|
if op.value < OP_NOP && op.value != OP_RESERVED {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if strings.Contains(op.name, "OP_UNKNOWN") {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
ops[op.name] = op
|
||||||
|
ops[strings.TrimPrefix(op.name, "OP_")] = op
|
||||||
|
}
|
||||||
|
// do once, build map.
|
||||||
|
|
||||||
|
// Split only does one separator so convert all \n and tab into space.
|
||||||
|
script = strings.Replace(script, "\n", " ", -1)
|
||||||
|
script = strings.Replace(script, "\t", " ", -1)
|
||||||
|
tokens := strings.Split(script, " ")
|
||||||
|
builder := NewScriptBuilder()
|
||||||
|
|
||||||
|
for _, tok := range tokens {
|
||||||
|
if len(tok) == 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
// if parses as a plain number
|
||||||
|
if num, err := strconv.ParseInt(tok, 10, 64); err == nil {
|
||||||
|
builder.AddInt64(num)
|
||||||
|
continue
|
||||||
|
} else if bts, err := parseHex(tok); err == nil {
|
||||||
|
// naughty...
|
||||||
|
builder.script = append(builder.script, bts...)
|
||||||
|
} else if len(tok) >= 2 &&
|
||||||
|
tok[0] == '\'' && tok[len(tok)-1] == '\'' {
|
||||||
|
builder.AddData([]byte(tok[1 : len(tok)-1]))
|
||||||
|
} else if opcode, ok := ops[tok]; ok {
|
||||||
|
builder.AddOp(opcode.value)
|
||||||
|
} else {
|
||||||
|
return nil, fmt.Errorf("bad token \"%s\"", tok)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return builder.Script(), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestBitcoindInvalidTests(t *testing.T) {
|
||||||
|
file, err := ioutil.ReadFile("data/script_invalid.json")
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("TestBitcoindInvalidTests: %v\n", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var tests [][]string
|
||||||
|
err = json.Unmarshal(file, &tests)
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("TestBitcoindInvalidTests couldn't Unmarshal: %v\n",
|
||||||
|
err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
tx := btcwire.NewMsgTx()
|
||||||
|
for x, test := range tests {
|
||||||
|
if len(test) < 2 && len(test) > 3 {
|
||||||
|
t.Errorf("TestBitcoindInvalidTests: invalid test #%d\n",
|
||||||
|
x)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
name := ""
|
||||||
|
if len(test) == 3 {
|
||||||
|
name = fmt.Sprintf("test (%s)", test[2])
|
||||||
|
} else {
|
||||||
|
name = fmt.Sprintf("test ([%s, %s])", test[0], test[1])
|
||||||
|
}
|
||||||
|
|
||||||
|
scriptSig, err := ParseShortForm(test[0])
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("%s: can't parse scriptSig; %v", name, err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
scriptPubKey, err := ParseShortForm(test[1])
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("%s: can't parse scriptPubkey; %v", name, err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
s, err := NewScript(scriptSig, scriptPubKey, 0, tx, ScriptBip16)
|
||||||
|
if err == nil {
|
||||||
|
if err := s.Execute(); err == nil {
|
||||||
|
t.Errorf("%s test succeeded when it "+
|
||||||
|
"should have failed\n", name)
|
||||||
|
}
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestBitcoindValidTests(t *testing.T) {
|
||||||
|
file, err := ioutil.ReadFile("data/script_valid.json")
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("TestBitcoinValidTests: %v\n", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var tests [][]string
|
||||||
|
err = json.Unmarshal(file, &tests)
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("TestBitcoindInvalidTests couldn't Unmarshal: %v\n",
|
||||||
|
err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
tx := btcwire.NewMsgTx()
|
||||||
|
for x, test := range tests {
|
||||||
|
if len(test) < 2 && len(test) > 3 {
|
||||||
|
t.Errorf("TestBitcoindInvalidTests: invalid test #%d\n",
|
||||||
|
x)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
name := ""
|
||||||
|
if len(test) == 3 {
|
||||||
|
name = fmt.Sprintf("test (%s)", test[2])
|
||||||
|
} else {
|
||||||
|
name = fmt.Sprintf("test ([%s, %s])", test[0], test[1])
|
||||||
|
}
|
||||||
|
|
||||||
|
scriptSig, err := ParseShortForm(test[0])
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("%s: can't parse scriptSig; %v", name, err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
scriptPubKey, err := ParseShortForm(test[1])
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("%s: can't parse scriptPubkey; %v", name, err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
s, err := NewScript(scriptSig, scriptPubKey, 0, tx, ScriptBip16)
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("%s failed to create script: %v", name, err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
err = s.Execute()
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("%s failed to execute: %v", name, err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestBitcoindTxValidTests(t *testing.T) {
|
||||||
|
file, err := ioutil.ReadFile("data/tx_valid.json")
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("TestBitcoindInvalidTests: %v\n", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var tests [][]interface{}
|
||||||
|
err = json.Unmarshal(file, &tests)
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("TestBitcoindInvalidTests couldn't Unmarshal: %v\n",
|
||||||
|
err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// for ma is eaitehr a ["this is a comment "]
|
||||||
|
// or [[[previous hash, previous index, previous scripbPubKey]...,]
|
||||||
|
// serializedTransaction, enforceP2SH]
|
||||||
|
testloop:
|
||||||
|
for i, test := range tests {
|
||||||
|
inputs, ok := test[0].([]interface{})
|
||||||
|
if !ok {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(test) != 3 {
|
||||||
|
t.Errorf("bad test (bad lenggh) %d: %v", i, test)
|
||||||
|
continue
|
||||||
|
|
||||||
|
}
|
||||||
|
serializedhex, ok := test[1].(string)
|
||||||
|
if !ok {
|
||||||
|
t.Errorf("bad test (arg 2 not string) %d: %v", i, test)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
serializedTx, err := hex.DecodeString(serializedhex)
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("bad test (arg 2 not hex %v) %d: %v", err, i,
|
||||||
|
test)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
tx, err := btcutil.NewTxFromBytes(serializedTx)
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("bad test (arg 2 not msgtx %v) %d: %v", err,
|
||||||
|
i, test)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
enforceP2SH, ok := test[2].(bool)
|
||||||
|
if !ok {
|
||||||
|
t.Errorf("bad test (arg 3 not bool) %d: %v", i, test)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
var flags ScriptFlags
|
||||||
|
if enforceP2SH {
|
||||||
|
flags |= ScriptBip16
|
||||||
|
}
|
||||||
|
|
||||||
|
prevOuts := make(map[btcwire.OutPoint][]byte)
|
||||||
|
for j, iinput := range inputs {
|
||||||
|
input, ok := iinput.([]interface{})
|
||||||
|
if !ok {
|
||||||
|
t.Errorf("bad test (%dth input not array)"+
|
||||||
|
"%d: %v", j, i, test)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(input) != 3 {
|
||||||
|
t.Errorf("bad test (%dth input wrong length)"+
|
||||||
|
"%d: %v", j, i, test)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
previoustx, ok := input[0].(string)
|
||||||
|
if !ok {
|
||||||
|
t.Errorf("bad test (%dth input sha not string)"+
|
||||||
|
"%d: %v", j, i, test)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
prevhash, err := btcwire.NewShaHashFromStr(previoustx)
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("bad test (%dth input sha not sha %v)"+
|
||||||
|
"%d: %v", j, err, i, test)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
idxf, ok := input[1].(float64)
|
||||||
|
if !ok {
|
||||||
|
t.Errorf("bad test (%dth input idx not number)"+
|
||||||
|
"%d: %v", j, i, test)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
idx := uint32(idxf) // (floor(idxf) == idxf?)
|
||||||
|
|
||||||
|
oscript, ok := input[2].(string)
|
||||||
|
if !ok {
|
||||||
|
t.Errorf("bad test (%dth input script not "+
|
||||||
|
"string) %d: %v", j, i, test)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
script, err := ParseShortForm(oscript)
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("bad test (%dth input script doesn't "+
|
||||||
|
"parse %v) %d: %v", j, err, i, test)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
prevOuts[*btcwire.NewOutPoint(prevhash, idx)] = script
|
||||||
|
}
|
||||||
|
|
||||||
|
for k, txin := range tx.MsgTx().TxIn {
|
||||||
|
pkScript, ok := prevOuts[txin.PreviousOutpoint]
|
||||||
|
if !ok {
|
||||||
|
t.Errorf("bad test (missing %dth input) %d:%v",
|
||||||
|
k, i, test)
|
||||||
|
continue testloop
|
||||||
|
}
|
||||||
|
s, err := NewScript(txin.SignatureScript, pkScript, k,
|
||||||
|
tx.MsgTx(), flags)
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("test (%d:%v:%d) failed to create "+
|
||||||
|
"script: %v", i, test, k, err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
err = s.Execute()
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("test (%d:%v:%d) failed to execute: "+
|
||||||
|
"%v", i, test, k, err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestBitcoindTxInvalidTests(t *testing.T) {
|
||||||
|
file, err := ioutil.ReadFile("data/tx_invalid.json")
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("TestBitcoindInvalidTests: %v\n", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var tests [][]interface{}
|
||||||
|
err = json.Unmarshal(file, &tests)
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("TestBitcoindInvalidTests couldn't Unmarshal: %v\n",
|
||||||
|
err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// for ma is eaitehr a ["this is a comment "]
|
||||||
|
// or [[[previous hash, previous index, previous scripbPubKey]...,]
|
||||||
|
// serializedTransaction, enforceP2SH]
|
||||||
|
testloop:
|
||||||
|
for i, test := range tests {
|
||||||
|
inputs, ok := test[0].([]interface{})
|
||||||
|
if !ok {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(test) != 3 {
|
||||||
|
t.Errorf("bad test (bad lenggh) %d: %v", i, test)
|
||||||
|
continue
|
||||||
|
|
||||||
|
}
|
||||||
|
serializedhex, ok := test[1].(string)
|
||||||
|
if !ok {
|
||||||
|
t.Errorf("bad test (arg 2 not string) %d: %v", i, test)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
serializedTx, err := hex.DecodeString(serializedhex)
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("bad test (arg 2 not hex %v) %d: %v", err, i,
|
||||||
|
test)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
tx, err := btcutil.NewTxFromBytes(serializedTx)
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("bad test (arg 2 not msgtx %v) %d: %v", err,
|
||||||
|
i, test)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
enforceP2SH, ok := test[2].(bool)
|
||||||
|
if !ok {
|
||||||
|
t.Errorf("bad test (arg 3 not bool) %d: %v", i, test)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
var flags ScriptFlags
|
||||||
|
if enforceP2SH {
|
||||||
|
flags |= ScriptBip16
|
||||||
|
}
|
||||||
|
|
||||||
|
prevOuts := make(map[btcwire.OutPoint][]byte)
|
||||||
|
for j, iinput := range inputs {
|
||||||
|
input, ok := iinput.([]interface{})
|
||||||
|
if !ok {
|
||||||
|
t.Errorf("bad test (%dth input not array)"+
|
||||||
|
"%d: %v", j, i, test)
|
||||||
|
continue testloop
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(input) != 3 {
|
||||||
|
t.Errorf("bad test (%dth input wrong length)"+
|
||||||
|
"%d: %v", j, i, test)
|
||||||
|
continue testloop
|
||||||
|
}
|
||||||
|
|
||||||
|
previoustx, ok := input[0].(string)
|
||||||
|
if !ok {
|
||||||
|
t.Errorf("bad test (%dth input sha not string)"+
|
||||||
|
"%d: %v", j, i, test)
|
||||||
|
continue testloop
|
||||||
|
}
|
||||||
|
|
||||||
|
prevhash, err := btcwire.NewShaHashFromStr(previoustx)
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("bad test (%dth input sha not sha %v)"+
|
||||||
|
"%d: %v", j, err, i, test)
|
||||||
|
continue testloop
|
||||||
|
}
|
||||||
|
|
||||||
|
idxf, ok := input[1].(float64)
|
||||||
|
if !ok {
|
||||||
|
t.Errorf("bad test (%dth input idx not number)"+
|
||||||
|
"%d: %v", j, i, test)
|
||||||
|
continue testloop
|
||||||
|
}
|
||||||
|
|
||||||
|
idx := uint32(idxf) // (floor(idxf) == idxf?)
|
||||||
|
|
||||||
|
oscript, ok := input[2].(string)
|
||||||
|
if !ok {
|
||||||
|
t.Errorf("bad test (%dth input script not "+
|
||||||
|
"string) %d: %v", j, i, test)
|
||||||
|
continue testloop
|
||||||
|
}
|
||||||
|
|
||||||
|
script, err := ParseShortForm(oscript)
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("bad test (%dth input script doesn't "+
|
||||||
|
"parse %v) %d: %v", j, err, i, test)
|
||||||
|
continue testloop
|
||||||
|
}
|
||||||
|
|
||||||
|
prevOuts[*btcwire.NewOutPoint(prevhash, idx)] = script
|
||||||
|
}
|
||||||
|
|
||||||
|
for k, txin := range tx.MsgTx().TxIn {
|
||||||
|
pkScript, ok := prevOuts[txin.PreviousOutpoint]
|
||||||
|
if !ok {
|
||||||
|
t.Errorf("bad test (missing %dth input) %d:%v",
|
||||||
|
k, i, test)
|
||||||
|
continue testloop
|
||||||
|
}
|
||||||
|
// These are meant to fail, so as soon as the first
|
||||||
|
// input fails the transaction has failed. (some of the
|
||||||
|
// test txns have good inputs, too..
|
||||||
|
s, err := NewScript(txin.SignatureScript, pkScript, k,
|
||||||
|
tx.MsgTx(), flags)
|
||||||
|
if err != nil {
|
||||||
|
continue testloop
|
||||||
|
}
|
||||||
|
|
||||||
|
err = s.Execute()
|
||||||
|
if err != nil {
|
||||||
|
continue testloop
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
t.Errorf("test (%d:%v) succeeded when should fail",
|
||||||
|
i, test)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,170 +1,171 @@
|
||||||
|
|
||||||
github.com/conformal/btcscript/opcode.go opcodeCheckMultiSig 100.00% (58/58)
|
github.com/conformal/btcscript/opcode.go opcodeCheckMultiSig 100.00% (60/60)
|
||||||
|
github.com/conformal/btcscript/script.go Script.Step 100.00% (37/37)
|
||||||
|
github.com/conformal/btcscript/opcode.go opcodeCheckSig 100.00% (29/29)
|
||||||
github.com/conformal/btcscript/script.go parseScriptTemplate 100.00% (29/29)
|
github.com/conformal/btcscript/script.go parseScriptTemplate 100.00% (29/29)
|
||||||
github.com/conformal/btcscript/address.go ExtractPkScriptAddrs 100.00% (27/27)
|
github.com/conformal/btcscript/address.go ExtractPkScriptAddrs 100.00% (27/27)
|
||||||
github.com/conformal/btcscript/script.go CalcScriptInfo 100.00% (25/25)
|
github.com/conformal/btcscript/script.go CalcScriptInfo 100.00% (25/25)
|
||||||
|
github.com/conformal/btcscript/script.go NewScript 100.00% (23/23)
|
||||||
github.com/conformal/btcscript/stack.go asInt 100.00% (23/23)
|
github.com/conformal/btcscript/stack.go asInt 100.00% (23/23)
|
||||||
github.com/conformal/btcscript/opcode.go parsedOpcode.bytes 100.00% (23/23)
|
github.com/conformal/btcscript/opcode.go parsedOpcode.bytes 100.00% (23/23)
|
||||||
github.com/conformal/btcscript/scriptbuilder.go ScriptBuilder.AddData 100.00% (22/22)
|
github.com/conformal/btcscript/scriptbuilder.go ScriptBuilder.AddData 100.00% (22/22)
|
||||||
github.com/conformal/btcscript/opcode.go parsedOpcode.disabled 100.00% (17/17)
|
github.com/conformal/btcscript/opcode.go parsedOpcode.disabled 100.00% (17/17)
|
||||||
github.com/conformal/btcscript/opcode.go parsedOpcode.print 100.00% (16/16)
|
github.com/conformal/btcscript/opcode.go parsedOpcode.print 100.00% (16/16)
|
||||||
github.com/conformal/btcscript/script.go signatureScriptCustomReader 100.00% (15/15)
|
|
||||||
github.com/conformal/btcscript/stack.go Stack.nipN 100.00% (15/15)
|
github.com/conformal/btcscript/stack.go Stack.nipN 100.00% (15/15)
|
||||||
|
github.com/conformal/btcscript/script.go signatureScriptCustomReader 100.00% (15/15)
|
||||||
github.com/conformal/btcscript/stack.go fromInt 100.00% (14/14)
|
github.com/conformal/btcscript/stack.go fromInt 100.00% (14/14)
|
||||||
github.com/conformal/btcscript/opcode.go parsedOpcode.exec 100.00% (13/13)
|
|
||||||
github.com/conformal/btcscript/script.go GetPreciseSigOpCount 100.00% (13/13)
|
|
||||||
github.com/conformal/btcscript/opcode.go opcodeWithin 100.00% (13/13)
|
|
||||||
github.com/conformal/btcscript/script.go isMultiSig 100.00% (13/13)
|
github.com/conformal/btcscript/script.go isMultiSig 100.00% (13/13)
|
||||||
github.com/conformal/btcscript/opcode.go opcodeNotIf 100.00% (11/11)
|
github.com/conformal/btcscript/opcode.go parsedOpcode.exec 100.00% (13/13)
|
||||||
github.com/conformal/btcscript/script.go PayToAddrScript 100.00% (11/11)
|
github.com/conformal/btcscript/opcode.go opcodeWithin 100.00% (13/13)
|
||||||
github.com/conformal/btcscript/script.go typeOfScript 100.00% (11/11)
|
github.com/conformal/btcscript/script.go GetPreciseSigOpCount 100.00% (13/13)
|
||||||
github.com/conformal/btcscript/opcode.go opcodeIf 100.00% (11/11)
|
github.com/conformal/btcscript/opcode.go opcodeIf 100.00% (11/11)
|
||||||
github.com/conformal/btcscript/opcode.go opcodeMin 100.00% (10/10)
|
github.com/conformal/btcscript/opcode.go opcodeNotIf 100.00% (11/11)
|
||||||
|
github.com/conformal/btcscript/script.go typeOfScript 100.00% (11/11)
|
||||||
|
github.com/conformal/btcscript/script.go PayToAddrScript 100.00% (11/11)
|
||||||
|
github.com/conformal/btcscript/opcode.go opcodeMax 100.00% (10/10)
|
||||||
|
github.com/conformal/btcscript/opcode.go opcodeLessThanOrEqual 100.00% (10/10)
|
||||||
|
github.com/conformal/btcscript/opcode.go opcodeLessThan 100.00% (10/10)
|
||||||
|
github.com/conformal/btcscript/opcode.go opcodeNumEqual 100.00% (10/10)
|
||||||
|
github.com/conformal/btcscript/opcode.go opcodeBoolOr 100.00% (10/10)
|
||||||
|
github.com/conformal/btcscript/opcode.go opcodeBoolAnd 100.00% (10/10)
|
||||||
|
github.com/conformal/btcscript/opcode.go opcodeGreaterThanOrEqual 100.00% (10/10)
|
||||||
github.com/conformal/btcscript/stack.go Stack.Tuck 100.00% (10/10)
|
github.com/conformal/btcscript/stack.go Stack.Tuck 100.00% (10/10)
|
||||||
github.com/conformal/btcscript/script.go getSigOpCount 100.00% (10/10)
|
github.com/conformal/btcscript/script.go getSigOpCount 100.00% (10/10)
|
||||||
github.com/conformal/btcscript/opcode.go opcodeBoolAnd 100.00% (10/10)
|
|
||||||
github.com/conformal/btcscript/opcode.go opcodeBoolOr 100.00% (10/10)
|
|
||||||
github.com/conformal/btcscript/opcode.go opcodeNumEqual 100.00% (10/10)
|
|
||||||
github.com/conformal/btcscript/opcode.go opcodeNumNotEqual 100.00% (10/10)
|
|
||||||
github.com/conformal/btcscript/opcode.go opcodeLessThan 100.00% (10/10)
|
|
||||||
github.com/conformal/btcscript/opcode.go opcodeGreaterThan 100.00% (10/10)
|
github.com/conformal/btcscript/opcode.go opcodeGreaterThan 100.00% (10/10)
|
||||||
github.com/conformal/btcscript/opcode.go opcodeLessThanOrEqual 100.00% (10/10)
|
github.com/conformal/btcscript/opcode.go opcodeNumNotEqual 100.00% (10/10)
|
||||||
github.com/conformal/btcscript/opcode.go opcodeGreaterThanOrEqual 100.00% (10/10)
|
github.com/conformal/btcscript/opcode.go opcodeMin 100.00% (10/10)
|
||||||
github.com/conformal/btcscript/opcode.go opcodeMax 100.00% (10/10)
|
|
||||||
github.com/conformal/btcscript/stack.go Stack.OverN 100.00% (9/9)
|
github.com/conformal/btcscript/stack.go Stack.OverN 100.00% (9/9)
|
||||||
github.com/conformal/btcscript/stack.go Stack.RotN 100.00% (9/9)
|
|
||||||
github.com/conformal/btcscript/script.go Script.CheckErrorCondition 100.00% (9/9)
|
|
||||||
github.com/conformal/btcscript/script.go DisasmString 100.00% (9/9)
|
|
||||||
github.com/conformal/btcscript/stack.go Stack.SwapN 100.00% (9/9)
|
github.com/conformal/btcscript/stack.go Stack.SwapN 100.00% (9/9)
|
||||||
github.com/conformal/btcscript/opcode.go opcodeEqual 100.00% (8/8)
|
github.com/conformal/btcscript/script.go DisasmString 100.00% (9/9)
|
||||||
|
github.com/conformal/btcscript/script.go Script.CheckErrorCondition 100.00% (9/9)
|
||||||
|
github.com/conformal/btcscript/stack.go Stack.RotN 100.00% (9/9)
|
||||||
|
github.com/conformal/btcscript/script.go Script.Execute 100.00% (8/8)
|
||||||
github.com/conformal/btcscript/stack.go Stack.DupN 100.00% (8/8)
|
github.com/conformal/btcscript/stack.go Stack.DupN 100.00% (8/8)
|
||||||
github.com/conformal/btcscript/script.go MultiSigScript 100.00% (8/8)
|
github.com/conformal/btcscript/script.go MultiSigScript 100.00% (8/8)
|
||||||
github.com/conformal/btcscript/script.go Script.Execute 100.00% (8/8)
|
github.com/conformal/btcscript/opcode.go opcodeEqual 100.00% (8/8)
|
||||||
github.com/conformal/btcscript/opcode.go opcodeSub 100.00% (8/8)
|
github.com/conformal/btcscript/opcode.go opcodeSub 100.00% (8/8)
|
||||||
github.com/conformal/btcscript/opcode.go opcodeAdd 100.00% (8/8)
|
github.com/conformal/btcscript/opcode.go opcodeAdd 100.00% (8/8)
|
||||||
github.com/conformal/btcscript/scriptbuilder.go ScriptBuilder.AddInt64 100.00% (7/7)
|
github.com/conformal/btcscript/scriptbuilder.go ScriptBuilder.AddInt64 100.00% (7/7)
|
||||||
github.com/conformal/btcscript/opcode.go opcode0NotEqual 100.00% (7/7)
|
github.com/conformal/btcscript/opcode.go opcode0NotEqual 100.00% (7/7)
|
||||||
|
github.com/conformal/btcscript/scriptbuilder.go ScriptBuilder.AddUint64 100.00% (7/7)
|
||||||
github.com/conformal/btcscript/stack.go Stack.DropN 100.00% (7/7)
|
github.com/conformal/btcscript/stack.go Stack.DropN 100.00% (7/7)
|
||||||
github.com/conformal/btcscript/opcode.go opcodeNot 100.00% (7/7)
|
github.com/conformal/btcscript/opcode.go opcodeNot 100.00% (7/7)
|
||||||
github.com/conformal/btcscript/scriptbuilder.go ScriptBuilder.AddUint64 100.00% (7/7)
|
|
||||||
github.com/conformal/btcscript/opcode.go parsedOpcode.conditional 100.00% (6/6)
|
|
||||||
github.com/conformal/btcscript/opcode.go opcodeIfDup 100.00% (6/6)
|
|
||||||
github.com/conformal/btcscript/opcode.go opcodeElse 100.00% (6/6)
|
|
||||||
github.com/conformal/btcscript/opcode.go opcodeEndif 100.00% (6/6)
|
github.com/conformal/btcscript/opcode.go opcodeEndif 100.00% (6/6)
|
||||||
|
github.com/conformal/btcscript/opcode.go parsedOpcode.conditional 100.00% (6/6)
|
||||||
|
github.com/conformal/btcscript/opcode.go opcodeElse 100.00% (6/6)
|
||||||
github.com/conformal/btcscript/opcode.go opcodeVerify 100.00% (6/6)
|
github.com/conformal/btcscript/opcode.go opcodeVerify 100.00% (6/6)
|
||||||
github.com/conformal/btcscript/opcode.go opcodeNegate 100.00% (5/5)
|
github.com/conformal/btcscript/opcode.go opcodeIfDup 100.00% (6/6)
|
||||||
|
github.com/conformal/btcscript/stack.go Stack.RollN 100.00% (5/5)
|
||||||
|
github.com/conformal/btcscript/opcode.go opcodeToAltStack 100.00% (5/5)
|
||||||
|
github.com/conformal/btcscript/opcode.go opcodeFromAltStack 100.00% (5/5)
|
||||||
github.com/conformal/btcscript/opcode.go opcodeRoll 100.00% (5/5)
|
github.com/conformal/btcscript/opcode.go opcodeRoll 100.00% (5/5)
|
||||||
github.com/conformal/btcscript/opcode.go opcodePick 100.00% (5/5)
|
github.com/conformal/btcscript/opcode.go opcodeSize 100.00% (5/5)
|
||||||
github.com/conformal/btcscript/stack.go Stack.PickN 100.00% (5/5)
|
github.com/conformal/btcscript/opcode.go opcode1Add 100.00% (5/5)
|
||||||
github.com/conformal/btcscript/script.go Script.validPC 100.00% (5/5)
|
github.com/conformal/btcscript/opcode.go opcode1Sub 100.00% (5/5)
|
||||||
github.com/conformal/btcscript/script.go removeOpcode 100.00% (5/5)
|
github.com/conformal/btcscript/opcode.go opcodeNegate 100.00% (5/5)
|
||||||
github.com/conformal/btcscript/opcode.go opcodeAbs 100.00% (5/5)
|
github.com/conformal/btcscript/opcode.go opcodeAbs 100.00% (5/5)
|
||||||
github.com/conformal/btcscript/opcode.go opcodeRipemd160 100.00% (5/5)
|
github.com/conformal/btcscript/opcode.go opcodeRipemd160 100.00% (5/5)
|
||||||
github.com/conformal/btcscript/opcode.go opcodeSha1 100.00% (5/5)
|
github.com/conformal/btcscript/opcode.go opcodeSha1 100.00% (5/5)
|
||||||
github.com/conformal/btcscript/opcode.go opcodeSha256 100.00% (5/5)
|
github.com/conformal/btcscript/opcode.go opcodeSha256 100.00% (5/5)
|
||||||
github.com/conformal/btcscript/opcode.go opcodeHash256 100.00% (5/5)
|
|
||||||
github.com/conformal/btcscript/script.go Script.DisasmScript 100.00% (5/5)
|
|
||||||
github.com/conformal/btcscript/stack.go Stack.RollN 100.00% (5/5)
|
|
||||||
github.com/conformal/btcscript/opcode.go opcodeFromAltStack 100.00% (5/5)
|
|
||||||
github.com/conformal/btcscript/opcode.go opcodeHash160 100.00% (5/5)
|
github.com/conformal/btcscript/opcode.go opcodeHash160 100.00% (5/5)
|
||||||
github.com/conformal/btcscript/opcode.go opcodeToAltStack 100.00% (5/5)
|
github.com/conformal/btcscript/opcode.go opcodeHash256 100.00% (5/5)
|
||||||
github.com/conformal/btcscript/opcode.go opcode1Add 100.00% (5/5)
|
github.com/conformal/btcscript/opcode.go opcodePick 100.00% (5/5)
|
||||||
github.com/conformal/btcscript/opcode.go opcode1Sub 100.00% (5/5)
|
github.com/conformal/btcscript/script.go Script.validPC 100.00% (5/5)
|
||||||
github.com/conformal/btcscript/opcode.go opcodeSize 100.00% (5/5)
|
github.com/conformal/btcscript/script.go Script.DisasmScript 100.00% (5/5)
|
||||||
|
github.com/conformal/btcscript/script.go removeOpcode 100.00% (5/5)
|
||||||
github.com/conformal/btcscript/script.go removeOpcodeByData 100.00% (5/5)
|
github.com/conformal/btcscript/script.go removeOpcodeByData 100.00% (5/5)
|
||||||
github.com/conformal/btcscript/opcode.go opcodeEqualVerify 100.00% (4/4)
|
github.com/conformal/btcscript/stack.go Stack.PickN 100.00% (5/5)
|
||||||
github.com/conformal/btcscript/stack.go Stack.PeekByteArray 100.00% (4/4)
|
|
||||||
github.com/conformal/btcscript/script.go Script.curPC 100.00% (4/4)
|
|
||||||
github.com/conformal/btcscript/script.go getStack 100.00% (4/4)
|
|
||||||
github.com/conformal/btcscript/script.go isNullData 100.00% (4/4)
|
|
||||||
github.com/conformal/btcscript/opcode.go opcodeCheckMultiSigVerify 100.00% (4/4)
|
github.com/conformal/btcscript/opcode.go opcodeCheckMultiSigVerify 100.00% (4/4)
|
||||||
github.com/conformal/btcscript/script.go Script.DisasmPC 100.00% (4/4)
|
github.com/conformal/btcscript/script.go isNullData 100.00% (4/4)
|
||||||
github.com/conformal/btcscript/opcode.go parsedOpcode.alwaysIllegal 100.00% (4/4)
|
|
||||||
github.com/conformal/btcscript/stack.go Stack.PopBool 100.00% (4/4)
|
|
||||||
github.com/conformal/btcscript/stack.go Stack.PeekBool 100.00% (4/4)
|
|
||||||
github.com/conformal/btcscript/script.go isPushOnly 100.00% (4/4)
|
github.com/conformal/btcscript/script.go isPushOnly 100.00% (4/4)
|
||||||
github.com/conformal/btcscript/script.go GetScriptClass 100.00% (4/4)
|
github.com/conformal/btcscript/opcode.go opcodeEqualVerify 100.00% (4/4)
|
||||||
github.com/conformal/btcscript/script.go IsPayToScriptHash 100.00% (4/4)
|
github.com/conformal/btcscript/script.go getStack 100.00% (4/4)
|
||||||
github.com/conformal/btcscript/stack.go asBool 100.00% (4/4)
|
|
||||||
github.com/conformal/btcscript/opcode.go opcodeNumEqualVerify 100.00% (4/4)
|
github.com/conformal/btcscript/opcode.go opcodeNumEqualVerify 100.00% (4/4)
|
||||||
|
github.com/conformal/btcscript/stack.go Stack.PeekBool 100.00% (4/4)
|
||||||
|
github.com/conformal/btcscript/script.go GetScriptClass 100.00% (4/4)
|
||||||
|
github.com/conformal/btcscript/stack.go asBool 100.00% (4/4)
|
||||||
github.com/conformal/btcscript/stack.go Stack.PeekInt 100.00% (4/4)
|
github.com/conformal/btcscript/stack.go Stack.PeekInt 100.00% (4/4)
|
||||||
|
github.com/conformal/btcscript/stack.go Stack.PeekByteArray 100.00% (4/4)
|
||||||
|
github.com/conformal/btcscript/stack.go Stack.PopBool 100.00% (4/4)
|
||||||
github.com/conformal/btcscript/stack.go Stack.PopInt 100.00% (4/4)
|
github.com/conformal/btcscript/stack.go Stack.PopInt 100.00% (4/4)
|
||||||
github.com/conformal/btcscript/stack.go fromBool 100.00% (3/3)
|
github.com/conformal/btcscript/opcode.go opcodeCheckSigVerify 100.00% (4/4)
|
||||||
github.com/conformal/btcscript/script.go isSmallInt 100.00% (3/3)
|
github.com/conformal/btcscript/script.go Script.curPC 100.00% (4/4)
|
||||||
|
github.com/conformal/btcscript/opcode.go parsedOpcode.alwaysIllegal 100.00% (4/4)
|
||||||
|
github.com/conformal/btcscript/script.go IsPayToScriptHash 100.00% (4/4)
|
||||||
|
github.com/conformal/btcscript/script.go Script.DisasmPC 100.00% (4/4)
|
||||||
github.com/conformal/btcscript/script.go ScriptClass.String 100.00% (3/3)
|
github.com/conformal/btcscript/script.go ScriptClass.String 100.00% (3/3)
|
||||||
github.com/conformal/btcscript/script.go setStack 100.00% (3/3)
|
github.com/conformal/btcscript/stack.go fromBool 100.00% (3/3)
|
||||||
github.com/conformal/btcscript/script.go asSmallInt 100.00% (3/3)
|
github.com/conformal/btcscript/script.go asSmallInt 100.00% (3/3)
|
||||||
github.com/conformal/btcscript/opcode.go opcodePushData 100.00% (2/2)
|
github.com/conformal/btcscript/script.go setStack 100.00% (3/3)
|
||||||
github.com/conformal/btcscript/opcode.go opcode1Negate 100.00% (2/2)
|
github.com/conformal/btcscript/script.go isSmallInt 100.00% (3/3)
|
||||||
github.com/conformal/btcscript/opcode.go calcHash 100.00% (2/2)
|
github.com/conformal/btcscript/opcode.go opcodeFalse 100.00% (2/2)
|
||||||
github.com/conformal/btcscript/opcode.go opcodeDepth 100.00% (2/2)
|
|
||||||
github.com/conformal/btcscript/stack.go Stack.Depth 100.00% (2/2)
|
github.com/conformal/btcscript/stack.go Stack.Depth 100.00% (2/2)
|
||||||
github.com/conformal/btcscript/script.go GetSigOpCount 100.00% (2/2)
|
github.com/conformal/btcscript/script.go GetSigOpCount 100.00% (2/2)
|
||||||
github.com/conformal/btcscript/stack.go Stack.NipN 100.00% (2/2)
|
github.com/conformal/btcscript/opcode.go opcodePushData 100.00% (2/2)
|
||||||
github.com/conformal/btcscript/scriptbuilder.go ScriptBuilder.Reset 100.00% (2/2)
|
github.com/conformal/btcscript/opcode.go calcHash 100.00% (2/2)
|
||||||
github.com/conformal/btcscript/scriptbuilder.go ScriptBuilder.AddOp 100.00% (2/2)
|
github.com/conformal/btcscript/scriptbuilder.go ScriptBuilder.AddOp 100.00% (2/2)
|
||||||
github.com/conformal/btcscript/opcode.go opcodeN 100.00% (2/2)
|
github.com/conformal/btcscript/opcode.go opcodeDepth 100.00% (2/2)
|
||||||
|
github.com/conformal/btcscript/opcode.go opcode1Negate 100.00% (2/2)
|
||||||
|
github.com/conformal/btcscript/stack.go Stack.NipN 100.00% (2/2)
|
||||||
github.com/conformal/btcscript/opcode.go opcodeCodeSeparator 100.00% (2/2)
|
github.com/conformal/btcscript/opcode.go opcodeCodeSeparator 100.00% (2/2)
|
||||||
github.com/conformal/btcscript/opcode.go opcodeFalse 100.00% (2/2)
|
github.com/conformal/btcscript/scriptbuilder.go ScriptBuilder.Reset 100.00% (2/2)
|
||||||
github.com/conformal/btcscript/script.go Script.SetStack 100.00% (1/1)
|
github.com/conformal/btcscript/opcode.go opcodeN 100.00% (2/2)
|
||||||
github.com/conformal/btcscript/script.go Script.GetAltStack 100.00% (1/1)
|
|
||||||
github.com/conformal/btcscript/script.go Script.SetAltStack 100.00% (1/1)
|
github.com/conformal/btcscript/script.go Script.SetAltStack 100.00% (1/1)
|
||||||
github.com/conformal/btcscript/opcode.go opcodeTuck 100.00% (1/1)
|
github.com/conformal/btcscript/opcode.go opcodeNop 100.00% (1/1)
|
||||||
github.com/conformal/btcscript/script.go parseScript 100.00% (1/1)
|
github.com/conformal/btcscript/opcode.go opcodeOver 100.00% (1/1)
|
||||||
github.com/conformal/btcscript/script.go isPubkey 100.00% (1/1)
|
github.com/conformal/btcscript/script.go isPubkey 100.00% (1/1)
|
||||||
github.com/conformal/btcscript/log.go DisableLog 100.00% (1/1)
|
|
||||||
github.com/conformal/btcscript/script.go isPubkeyHash 100.00% (1/1)
|
github.com/conformal/btcscript/script.go isPubkeyHash 100.00% (1/1)
|
||||||
github.com/conformal/btcscript/opcode.go calcHash160 100.00% (1/1)
|
github.com/conformal/btcscript/script.go isScriptHash 100.00% (1/1)
|
||||||
github.com/conformal/btcscript/script.go Script.disasm 100.00% (1/1)
|
github.com/conformal/btcscript/opcode.go opcodeNip 100.00% (1/1)
|
||||||
github.com/conformal/btcscript/script.go Script.subScript 100.00% (1/1)
|
github.com/conformal/btcscript/opcode.go opcodeDup 100.00% (1/1)
|
||||||
github.com/conformal/btcscript/opcode.go opcodeSwap 100.00% (1/1)
|
github.com/conformal/btcscript/script.go parseScript 100.00% (1/1)
|
||||||
github.com/conformal/btcscript/opcode.go opcodeRot 100.00% (1/1)
|
github.com/conformal/btcscript/opcode.go opcode2Swap 100.00% (1/1)
|
||||||
github.com/conformal/btcscript/log.go init 100.00% (1/1)
|
|
||||||
github.com/conformal/btcscript/script.go Script.GetStack 100.00% (1/1)
|
|
||||||
github.com/conformal/btcscript/opcode.go opcode2Rot 100.00% (1/1)
|
github.com/conformal/btcscript/opcode.go opcode2Rot 100.00% (1/1)
|
||||||
github.com/conformal/btcscript/opcode.go opcode2Over 100.00% (1/1)
|
github.com/conformal/btcscript/opcode.go opcode2Over 100.00% (1/1)
|
||||||
|
github.com/conformal/btcscript/log.go DisableLog 100.00% (1/1)
|
||||||
|
github.com/conformal/btcscript/script.go Script.disasm 100.00% (1/1)
|
||||||
|
github.com/conformal/btcscript/script.go Script.subScript 100.00% (1/1)
|
||||||
|
github.com/conformal/btcscript/log.go init 100.00% (1/1)
|
||||||
github.com/conformal/btcscript/opcode.go opcode3Dup 100.00% (1/1)
|
github.com/conformal/btcscript/opcode.go opcode3Dup 100.00% (1/1)
|
||||||
github.com/conformal/btcscript/scriptbuilder.go ScriptBuilder.Script 100.00% (1/1)
|
github.com/conformal/btcscript/script.go Script.GetStack 100.00% (1/1)
|
||||||
github.com/conformal/btcscript/scriptbuilder.go NewScriptBuilder 100.00% (1/1)
|
github.com/conformal/btcscript/script.go Script.SetStack 100.00% (1/1)
|
||||||
|
github.com/conformal/btcscript/script.go Script.GetAltStack 100.00% (1/1)
|
||||||
github.com/conformal/btcscript/opcode.go opcode2Dup 100.00% (1/1)
|
github.com/conformal/btcscript/opcode.go opcode2Dup 100.00% (1/1)
|
||||||
|
github.com/conformal/btcscript/script.go payToPubKeyHashScript 100.00% (1/1)
|
||||||
|
github.com/conformal/btcscript/script.go payToScriptHashScript 100.00% (1/1)
|
||||||
|
github.com/conformal/btcscript/script.go payToPubKeyScript 100.00% (1/1)
|
||||||
github.com/conformal/btcscript/opcode.go opcode2Drop 100.00% (1/1)
|
github.com/conformal/btcscript/opcode.go opcode2Drop 100.00% (1/1)
|
||||||
github.com/conformal/btcscript/opcode.go opcodeReturn 100.00% (1/1)
|
github.com/conformal/btcscript/opcode.go opcodeReturn 100.00% (1/1)
|
||||||
github.com/conformal/btcscript/opcode.go opcodeNop 100.00% (1/1)
|
github.com/conformal/btcscript/script.go SignatureScript 100.00% (1/1)
|
||||||
|
github.com/conformal/btcscript/opcode.go opcodeInvalid 100.00% (1/1)
|
||||||
|
github.com/conformal/btcscript/scriptbuilder.go ScriptBuilder.Script 100.00% (1/1)
|
||||||
|
github.com/conformal/btcscript/scriptbuilder.go NewScriptBuilder 100.00% (1/1)
|
||||||
|
github.com/conformal/btcscript/opcode.go opcodeReserved 100.00% (1/1)
|
||||||
github.com/conformal/btcscript/stack.go Stack.PushByteArray 100.00% (1/1)
|
github.com/conformal/btcscript/stack.go Stack.PushByteArray 100.00% (1/1)
|
||||||
github.com/conformal/btcscript/stack.go Stack.PushInt 100.00% (1/1)
|
github.com/conformal/btcscript/stack.go Stack.PushInt 100.00% (1/1)
|
||||||
github.com/conformal/btcscript/stack.go Stack.PushBool 100.00% (1/1)
|
github.com/conformal/btcscript/stack.go Stack.PushBool 100.00% (1/1)
|
||||||
github.com/conformal/btcscript/stack.go Stack.PopByteArray 100.00% (1/1)
|
github.com/conformal/btcscript/stack.go Stack.PopByteArray 100.00% (1/1)
|
||||||
github.com/conformal/btcscript/opcode.go opcodeInvalid 100.00% (1/1)
|
github.com/conformal/btcscript/opcode.go opcodeTuck 100.00% (1/1)
|
||||||
github.com/conformal/btcscript/opcode.go opcodeReserved 100.00% (1/1)
|
github.com/conformal/btcscript/opcode.go opcodeSwap 100.00% (1/1)
|
||||||
|
github.com/conformal/btcscript/opcode.go opcodeRot 100.00% (1/1)
|
||||||
|
github.com/conformal/btcscript/opcode.go calcHash160 100.00% (1/1)
|
||||||
github.com/conformal/btcscript/opcode.go init 100.00% (1/1)
|
github.com/conformal/btcscript/opcode.go init 100.00% (1/1)
|
||||||
github.com/conformal/btcscript/log.go newLogClosure 100.00% (1/1)
|
github.com/conformal/btcscript/log.go newLogClosure 100.00% (1/1)
|
||||||
github.com/conformal/btcscript/script.go isScriptHash 100.00% (1/1)
|
|
||||||
github.com/conformal/btcscript/opcode.go opcodeOver 100.00% (1/1)
|
|
||||||
github.com/conformal/btcscript/opcode.go opcodeNip 100.00% (1/1)
|
|
||||||
github.com/conformal/btcscript/script.go payToPubKeyHashScript 100.00% (1/1)
|
|
||||||
github.com/conformal/btcscript/script.go payToScriptHashScript 100.00% (1/1)
|
|
||||||
github.com/conformal/btcscript/script.go payToPubKeyScript 100.00% (1/1)
|
|
||||||
github.com/conformal/btcscript/opcode.go opcodeDup 100.00% (1/1)
|
|
||||||
github.com/conformal/btcscript/opcode.go opcodeDrop 100.00% (1/1)
|
github.com/conformal/btcscript/opcode.go opcodeDrop 100.00% (1/1)
|
||||||
github.com/conformal/btcscript/script.go SignatureScript 100.00% (1/1)
|
github.com/conformal/btcscript/script.go calcScriptHash 97.44% (38/39)
|
||||||
github.com/conformal/btcscript/opcode.go opcode2Swap 100.00% (1/1)
|
github.com/conformal/btcscript/script.go canonicalPush 92.86% (13/14)
|
||||||
github.com/conformal/btcscript/script.go Script.Step 97.30% (36/37)
|
|
||||||
github.com/conformal/btcscript/script.go NewScript 95.65% (22/23)
|
|
||||||
github.com/conformal/btcscript/opcode.go opcodeCheckSig 93.10% (27/29)
|
|
||||||
github.com/conformal/btcscript/script.go expectedInputs 85.71% (6/7)
|
|
||||||
github.com/conformal/btcscript/script.go unparseScript 85.71% (6/7)
|
github.com/conformal/btcscript/script.go unparseScript 85.71% (6/7)
|
||||||
github.com/conformal/btcscript/script.go calcScriptHash 82.05% (32/39)
|
github.com/conformal/btcscript/script.go expectedInputs 85.71% (6/7)
|
||||||
github.com/conformal/btcscript/opcode.go opcodeCheckSigVerify 75.00% (3/4)
|
|
||||||
github.com/conformal/btcscript/script.go IsPushOnlyScript 75.00% (3/4)
|
github.com/conformal/btcscript/script.go IsPushOnlyScript 75.00% (3/4)
|
||||||
github.com/conformal/btcscript/script.go HasCanonicalPushes 66.67% (12/18)
|
github.com/conformal/btcscript/script.go HasCanonicalPushes 71.43% (5/7)
|
||||||
github.com/conformal/btcscript/log.go SetLogWriter 0.00% (0/10)
|
github.com/conformal/btcscript/log.go SetLogWriter 0.00% (0/10)
|
||||||
github.com/conformal/btcscript/script.go CalcMultiSigStats 0.00% (0/8)
|
github.com/conformal/btcscript/script.go CalcMultiSigStats 0.00% (0/8)
|
||||||
github.com/conformal/btcscript/script.go @566:34 0.00% (0/6)
|
github.com/conformal/btcscript/script.go @577:34 0.00% (0/6)
|
||||||
github.com/conformal/btcscript/script.go @554:34 0.00% (0/4)
|
github.com/conformal/btcscript/script.go @565:34 0.00% (0/4)
|
||||||
github.com/conformal/btcscript/script.go @599:34 0.00% (0/3)
|
github.com/conformal/btcscript/script.go @610:34 0.00% (0/3)
|
||||||
github.com/conformal/btcscript/opcode.go opcodeDisabled 0.00% (0/1)
|
|
||||||
github.com/conformal/btcscript/log.go UseLogger 0.00% (0/1)
|
github.com/conformal/btcscript/log.go UseLogger 0.00% (0/1)
|
||||||
github.com/conformal/btcscript/opcode.go @1803:33 0.00% (0/1)
|
|
||||||
github.com/conformal/btcscript/log.go logClosure.String 0.00% (0/1)
|
github.com/conformal/btcscript/log.go logClosure.String 0.00% (0/1)
|
||||||
github.com/conformal/btcscript --------------------------- 94.95% (1054/1110)
|
github.com/conformal/btcscript/opcode.go @1803:33 0.00% (0/1)
|
||||||
|
github.com/conformal/btcscript/opcode.go opcodeDisabled 0.00% (0/1)
|
||||||
|
github.com/conformal/btcscript --------------------------- 96.23% (1073/1115)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue