mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-03-05 14:06:27 -05:00
test: add validation for gettxout RPC response
This commit is contained in:
parent
2d07384243
commit
fa0232a3e0
1 changed files with 29 additions and 0 deletions
|
@ -9,6 +9,7 @@ Test the following RPCs:
|
|||
- getdeploymentinfo
|
||||
- getchaintxstats
|
||||
- gettxoutsetinfo
|
||||
- gettxout
|
||||
- getblockheader
|
||||
- getdifficulty
|
||||
- getnetworkhashps
|
||||
|
@ -90,6 +91,7 @@ class BlockchainTest(BitcoinTestFramework):
|
|||
self._test_getblockchaininfo()
|
||||
self._test_getchaintxstats()
|
||||
self._test_gettxoutsetinfo()
|
||||
self._test_gettxout()
|
||||
self._test_getblockheader()
|
||||
self._test_getdifficulty()
|
||||
self._test_getnetworkhashps()
|
||||
|
@ -400,6 +402,33 @@ class BlockchainTest(BitcoinTestFramework):
|
|||
# Unknown hash_type raises an error
|
||||
assert_raises_rpc_error(-8, "'foo hash' is not a valid hash_type", node.gettxoutsetinfo, "foo hash")
|
||||
|
||||
def _test_gettxout(self):
|
||||
self.log.info("Validating gettxout RPC response")
|
||||
node = self.nodes[0]
|
||||
|
||||
# Get the best block hash and the block, which
|
||||
# should only include the coinbase transaction.
|
||||
best_block_hash = node.getbestblockhash()
|
||||
block = node.getblock(best_block_hash)
|
||||
assert_equal(block['nTx'], 1)
|
||||
|
||||
# Get the transaction ID of the coinbase tx and
|
||||
# the transaction output.
|
||||
txid = block['tx'][0]
|
||||
txout = node.gettxout(txid, 0)
|
||||
|
||||
# Validate the gettxout response
|
||||
assert_equal(txout['bestblock'], best_block_hash)
|
||||
assert_equal(txout['confirmations'], 1)
|
||||
assert_equal(txout['value'], 25)
|
||||
assert_equal(txout['scriptPubKey']['address'], self.wallet.get_address())
|
||||
assert_equal(txout['scriptPubKey']['hex'], self.wallet.get_scriptPubKey().hex())
|
||||
decoded_script = node.decodescript(self.wallet.get_scriptPubKey().hex())
|
||||
assert_equal(txout['scriptPubKey']['asm'], decoded_script['asm'])
|
||||
assert_equal(txout['scriptPubKey']['desc'], decoded_script['desc'])
|
||||
assert_equal(txout['scriptPubKey']['type'], decoded_script['type'])
|
||||
assert_equal(txout['coinbase'], True)
|
||||
|
||||
def _test_getblockheader(self):
|
||||
self.log.info("Test getblockheader")
|
||||
node = self.nodes[0]
|
||||
|
|
Loading…
Add table
Reference in a new issue