Changeset View
Changeset View
Standalone View
Standalone View
test/functional/rpc_decodescript.py
#!/usr/bin/env python3 | #!/usr/bin/env python3 | ||||
# Copyright (c) 2015-2016 The Bitcoin Core developers | # Copyright (c) 2015-2016 The Bitcoin Core developers | ||||
# Distributed under the MIT software license, see the accompanying | # Distributed under the MIT software license, see the accompanying | ||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php. | # file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
"""Test decoding scripts via decodescript RPC command.""" | |||||
from test_framework.messages import CTransaction, FromHex, ToHex | from test_framework.messages import CTransaction, FromHex, ToHex | ||||
from test_framework.test_framework import BitcoinTestFramework | from test_framework.test_framework import BitcoinTestFramework | ||||
from test_framework.util import assert_equal, bytes_to_hex_str, hex_str_to_bytes | from test_framework.util import assert_equal, bytes_to_hex_str, hex_str_to_bytes | ||||
class DecodeScriptTest(BitcoinTestFramework): | class DecodeScriptTest(BitcoinTestFramework): | ||||
def set_test_params(self): | def set_test_params(self): | ||||
▲ Show 20 Lines • Show All 99 Lines • ▼ Show 20 Lines | def decodescript_script_pub_key(self): | ||||
# | # | ||||
# lock until block 500,000 | # lock until block 500,000 | ||||
rpc_result = self.nodes[0].decodescript( | rpc_result = self.nodes[0].decodescript( | ||||
'63' + push_public_key + 'ad670320a107b17568' + push_public_key + 'ac') | '63' + push_public_key + 'ad670320a107b17568' + push_public_key + 'ac') | ||||
assert_equal('OP_IF ' + public_key + ' OP_CHECKSIGVERIFY OP_ELSE 500000 OP_CHECKLOCKTIMEVERIFY OP_DROP OP_ENDIF ' + | assert_equal('OP_IF ' + public_key + ' OP_CHECKSIGVERIFY OP_ELSE 500000 OP_CHECKLOCKTIMEVERIFY OP_DROP OP_ENDIF ' + | ||||
public_key + ' OP_CHECKSIG', rpc_result['asm']) | public_key + ' OP_CHECKSIG', rpc_result['asm']) | ||||
def decoderawtransaction_asm_sighashtype(self): | def decoderawtransaction_asm_sighashtype(self): | ||||
"""Tests decoding scripts via RPC command "decoderawtransaction". | """Test decoding scripts via RPC command "decoderawtransaction". | ||||
This test is in with the "decodescript" tests because they are testing the same "asm" script decodes. | This test is in with the "decodescript" tests because they are testing the same "asm" script decodes. | ||||
""" | """ | ||||
# this test case uses a random plain vanilla mainnet transaction with a | # this test case uses a random plain vanilla mainnet transaction with a | ||||
# single P2PKH input and output | # single P2PKH input and output | ||||
tx = '0100000001696a20784a2c70143f634e95227dbdfdf0ecd51647052e70854512235f5986ca010000008a47304402207174775824bec6c2700023309a168231ec80b82c6069282f5133e6f11cbb04460220570edc55c7c5da2ca687ebd0372d3546ebc3f810516a002350cac72dfe192dfb014104d3f898e6487787910a690410b7a917ef198905c27fb9d3b0a42da12aceae0544fc7088d239d9a48f2828a15a09e84043001f27cc80d162cb95404e1210161536ffffffff0100e1f505000000001976a914eb6c6e0cdb2d256a32d97b8df1fc75d1920d9bca88ac00000000' | tx = '0100000001696a20784a2c70143f634e95227dbdfdf0ecd51647052e70854512235f5986ca010000008a47304402207174775824bec6c2700023309a168231ec80b82c6069282f5133e6f11cbb04460220570edc55c7c5da2ca687ebd0372d3546ebc3f810516a002350cac72dfe192dfb014104d3f898e6487787910a690410b7a917ef198905c27fb9d3b0a42da12aceae0544fc7088d239d9a48f2828a15a09e84043001f27cc80d162cb95404e1210161536ffffffff0100e1f505000000001976a914eb6c6e0cdb2d256a32d97b8df1fc75d1920d9bca88ac00000000' | ||||
rpc_result = self.nodes[0].decoderawtransaction(tx) | rpc_result = self.nodes[0].decoderawtransaction(tx) | ||||
▲ Show 20 Lines • Show All 88 Lines • Show Last 20 Lines |