Changeset View
Changeset View
Standalone View
Standalone View
test/functional/rpc_txoutproof.py
Show First 20 Lines • Show All 76 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
txid3 = self.nodes[0].sendrawtransaction( | txid3 = self.nodes[0].sendrawtransaction( | ||||
self.nodes[1].signrawtransactionwithwallet(tx3)["hex"]) | self.nodes[1].signrawtransactionwithwallet(tx3)["hex"]) | ||||
self.nodes[0].generate(1) | self.nodes[0].generate(1) | ||||
self.sync_all() | self.sync_all() | ||||
txid_spent = txin_spent["txid"] | txid_spent = txin_spent["txid"] | ||||
txid_unspent = txid1 if txin_spent["txid"] != txid1 else txid2 | txid_unspent = txid1 if txin_spent["txid"] != txid1 else txid2 | ||||
# Invalid txids | |||||
assert_raises_rpc_error( | |||||
-8, | |||||
"txid must be of length 64 (not 32, for '00000000000000000000000000000000')", | |||||
self.nodes[2].gettxoutproof, | |||||
["00000000000000000000000000000000"], | |||||
blockhash) | |||||
assert_raises_rpc_error( | |||||
-8, | |||||
"txid must be hexadecimal string (not 'ZZZ0000000000000000000000000000000000000000000000000000000000000')", | |||||
self.nodes[2].gettxoutproof, | |||||
["ZZZ0000000000000000000000000000000000000000000000000000000000000"], | |||||
blockhash) | |||||
# Invalid blockhashes | |||||
assert_raises_rpc_error( | |||||
-8, | |||||
"blockhash must be of length 64 (not 32, for '00000000000000000000000000000000')", | |||||
self.nodes[2].gettxoutproof, | |||||
[txid_spent], | |||||
"00000000000000000000000000000000") | |||||
assert_raises_rpc_error( | |||||
-8, | |||||
"blockhash must be hexadecimal string (not 'ZZZ0000000000000000000000000000000000000000000000000000000000000')", | |||||
self.nodes[2].gettxoutproof, | |||||
[txid_spent], | |||||
"ZZZ0000000000000000000000000000000000000000000000000000000000000") | |||||
# We can't find the block from a fully-spent tx | # We can't find the block from a fully-spent tx | ||||
assert_raises_rpc_error(-5, "Transaction not yet in block", | assert_raises_rpc_error(-5, "Transaction not yet in block", | ||||
self.nodes[2].gettxoutproof, [txid_spent]) | self.nodes[2].gettxoutproof, [txid_spent]) | ||||
# We can get the proof if we specify the block | # We can get the proof if we specify the block | ||||
assert_equal(self.nodes[2].verifytxoutproof( | assert_equal(self.nodes[2].verifytxoutproof( | ||||
self.nodes[2].gettxoutproof([txid_spent], blockhash)), [txid_spent]) | self.nodes[2].gettxoutproof([txid_spent], blockhash)), [txid_spent]) | ||||
# We can't get the proof if we specify a non-existent block | # We can't get the proof if we specify a non-existent block | ||||
assert_raises_rpc_error(-5, "Block not found", self.nodes[2].gettxoutproof, [ | assert_raises_rpc_error(-5, "Block not found", self.nodes[2].gettxoutproof, [ | ||||
txid_spent], "00000000000000000000000000000000") | txid_spent], "0000000000000000000000000000000000000000000000000000000000000000") | ||||
# We can get the proof if the transaction is unspent | # We can get the proof if the transaction is unspent | ||||
assert_equal(self.nodes[2].verifytxoutproof( | assert_equal(self.nodes[2].verifytxoutproof( | ||||
self.nodes[2].gettxoutproof([txid_unspent])), [txid_unspent]) | self.nodes[2].gettxoutproof([txid_unspent])), [txid_unspent]) | ||||
# We can get the proof if we provide a list of transactions and one of | # We can get the proof if we provide a list of transactions and one of | ||||
# them is unspent. The ordering of the list should not matter. | # them is unspent. The ordering of the list should not matter. | ||||
assert_equal(sorted(self.nodes[2].verifytxoutproof( | assert_equal(sorted(self.nodes[2].verifytxoutproof( | ||||
self.nodes[2].gettxoutproof([txid1, txid2]))), sorted(txlist)) | self.nodes[2].gettxoutproof([txid1, txid2]))), sorted(txlist)) | ||||
assert_equal(sorted(self.nodes[2].verifytxoutproof( | assert_equal(sorted(self.nodes[2].verifytxoutproof( | ||||
Show All 33 Lines |