diff options
author | Dimitri <kvaciral@protonmail.com> | 2021-12-03 21:42:52 +0100 |
---|---|---|
committer | Dimitri <kvaciral@protonmail.com> | 2021-12-05 22:07:04 +0100 |
commit | b35942e500159ce601e909375fdafd8497f23b36 (patch) | |
tree | c8305c345c62d389b7be32d8a31d2f723938d56c /test | |
parent | 26a1147ce56083d7aa820ac115c16b01e47d911c (diff) |
tests: Add data-driven testcases to rpc_decodescript.py
Diffstat (limited to 'test')
-rw-r--r-- | test/functional/data/rpc_decodescript.json | 120 | ||||
-rwxr-xr-x | test/functional/rpc_decodescript.py | 13 |
2 files changed, 133 insertions, 0 deletions
diff --git a/test/functional/data/rpc_decodescript.json b/test/functional/data/rpc_decodescript.json new file mode 100644 index 0000000000..12f3c92230 --- /dev/null +++ b/test/functional/data/rpc_decodescript.json @@ -0,0 +1,120 @@ +[ + [ + "5120eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee", + { + "asm": "1 eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee", + "address": "bcrt1pamhwamhwamhwamhwamhwamhwamhwamhwamhwamhwamhwamhwamhqz6nvlh", + "type": "witness_v1_taproot", + "p2sh": "2Mt5gBng2UVL3xX4FUQinSBthq8gWQqs37g" + } + ], + [ + "5102eeee", + { + "asm": "1 -28398", + "address": "bcrt1pamhqk96edn", + "type": "witness_unknown", + "p2sh": "2ND89Zqxi19tq7AjL5Y3un8fDWRwpwrk4tf" + } + ], + [ + "0020eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee", + { + "asm": "0 eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee", + "address": "bcrt1qamhwamhwamhwamhwamhwamhwamhwamhwamhwamhwamhwamhwamhqgdn98t", + "type": "witness_v0_scripthash", + "p2sh": "2MwGk8mw1GBP6U9D5X8gTvgvXpuknmAK3fo" + } + ], + [ + "a914eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee87", + { + "asm": "OP_HASH160 eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee OP_EQUAL", + "address": "2NF2b3KS8xXb9XHvbRMXdZh8s5g92rUZHtp", + "type": "scripthash" + } + ], + [ + "6a00", + { + "asm": "OP_RETURN 0", + "type": "nulldata", + "p2sh": "2NG8CqGyR16jkZU5H7J9WM5xpCT6Fpw6bww" + } + ], + [ + "6aee", + { + "asm": "OP_RETURN OP_UNKNOWN", + "type": "nonstandard", + "p2sh": "2NGU1bmCBhSooc3vkPYdea2ngDcwhNx8CeF", + "segwit": { + "asm": "0 44358a3abb4cc9f635f459edffb2a1210f849857aaf12106a1af645e034faa95", + "hex": "002044358a3abb4cc9f635f459edffb2a1210f849857aaf12106a1af645e034faa95", + "address": "bcrt1qgs6c5w4mfnylvd05t8kllv4pyy8cfxzh4tcjzp4p4aj9uq60422sw9mgmf", + "type": "witness_v0_scripthash", + "p2sh-segwit": "2N9xFeGJC4Z2BQcVEq7vyeNUZiVoANFbrX1" + } + } + ], + [ + "6a02ee", + { + "asm": "OP_RETURN [error]", + "type": "nonstandard", + "p2sh": "2N9JFV56rrkTYVnrJTMFSpKNsq6j5NbAdQr", + "segwit": { + "asm": "0 6f3d493995bda1f72a8f4de96663be22b583623a05f5ae98f38c45b8e03ca5da", + "hex": "00206f3d493995bda1f72a8f4de96663be22b583623a05f5ae98f38c45b8e03ca5da", + "address": "bcrt1qdu75jwv4hkslw250fh5kvca7y26cxc36qh66ax8n33zm3cpu5hdqdtm4gp", + "type": "witness_v0_scripthash", + "p2sh-segwit": "2N3TqW8vuVr987Z695CmLNmLLXobBRMmqho" + } + } + ], + [ + "02eeee", + { + "asm": "-28398", + "type": "nonstandard", + "p2sh": "2N34iiGoUUkVSPiaaTFpJjB1FR9TXQu3PGM", + "segwit": { + "asm": "0 96c2368fc30514a438a8bd909f93c49a1549d77198ccbdb792043b666cb24f42", + "hex": "002096c2368fc30514a438a8bd909f93c49a1549d77198ccbdb792043b666cb24f42", + "address": "bcrt1qjmprdr7rq522gw9ghkgfly7yng25n4m3nrxtmdujqsakvm9jfapqk795l5", + "type": "witness_v0_scripthash", + "p2sh-segwit": "2MtoejEictTQ6XtmHYzoYttt35Ec6krqFKN" + } + } + ], + [ + "ba", + { + "asm": "OP_CHECKSIGADD", + "type": "nonstandard", + "p2sh": "2MyX11u6v747zcKHTJMjXFgkj1vYZgHr4i1", + "segwit": { + "asm": "0 281c93990bac2c69cf372c9a3b66c406c86cca826d6407b68e644da22eef8186", + "hex": "0020281c93990bac2c69cf372c9a3b66c406c86cca826d6407b68e644da22eef8186", + "address": "bcrt1q9qwf8xgt4skxnneh9jdrkekyqmyxej5zd4jq0d5wv3x6yth0sxrqe2wl7r", + "type": "witness_v0_scripthash", + "p2sh-segwit": "2NBoeWVFMmZdEhLzP5kpvjnJ8c1GucsCbFK" + } + } + ], + [ + "50", + { + "asm": "OP_RESERVED", + "type": "nonstandard", + "p2sh": "2NEqnmDnSWcfTRBG2t6M53ey6mjc8ncHesN", + "segwit": { + "asm": "0 5c62e091b8c0565f1bafad0dad5934276143ae2ccef7a5381e8ada5b1a8d26d2", + "hex": "00205c62e091b8c0565f1bafad0dad5934276143ae2ccef7a5381e8ada5b1a8d26d2", + "address": "bcrt1qt33wpydccpt97xa045x66kf5yas58t3vemm62wq73td9kx5dymfqknplwh", + "type": "witness_v0_scripthash", + "p2sh-segwit": "2NEtjT3ku2KjZo53bnwKX2v928Mzx5sjdUh" + } + } + ] +]
\ No newline at end of file diff --git a/test/functional/rpc_decodescript.py b/test/functional/rpc_decodescript.py index 8c0f48129a..56f596d419 100755 --- a/test/functional/rpc_decodescript.py +++ b/test/functional/rpc_decodescript.py @@ -4,6 +4,9 @@ # file COPYING or http://www.opensource.org/licenses/mit-license.php. """Test decoding scripts via decodescript RPC command.""" +import json +import os + from test_framework.messages import ( sha256, tx_from_hex, @@ -252,6 +255,14 @@ class DecodeScriptTest(BitcoinTestFramework): rpc_result = self.nodes[0].decoderawtransaction(txSave.serialize().hex()) assert_equal('OP_RETURN 3011020701010101010101020601010101010101', rpc_result['vin'][0]['scriptSig']['asm']) + def decodescript_datadriven_tests(self): + with open(os.path.join(os.path.dirname(os.path.realpath(__file__)), 'data/rpc_decodescript.json'), encoding='utf-8') as f: + dd_tests = json.load(f) + + for script, result in dd_tests: + rpc_result = self.nodes[0].decodescript(script) + assert_equal(result, rpc_result) + def run_test(self): self.log.info("Test decoding of standard input scripts [scriptSig]") self.decodescript_script_sig() @@ -259,6 +270,8 @@ class DecodeScriptTest(BitcoinTestFramework): self.decodescript_script_pub_key() self.log.info("Test 'asm' script decoding of transactions") self.decoderawtransaction_asm_sighashtype() + self.log.info("Data-driven tests") + self.decodescript_datadriven_tests() if __name__ == '__main__': DecodeScriptTest().main() |