|
9 | 9 | - getdeploymentinfo |
10 | 10 | - getchaintxstats |
11 | 11 | - gettxoutsetinfo |
| 12 | + - gettxout |
12 | 13 | - getblockheader |
13 | 14 | - getdifficulty |
14 | 15 | - getnetworkhashps |
@@ -90,6 +91,7 @@ def run_test(self): |
90 | 91 | self._test_getblockchaininfo() |
91 | 92 | self._test_getchaintxstats() |
92 | 93 | self._test_gettxoutsetinfo() |
| 94 | + self._test_gettxout() |
93 | 95 | self._test_getblockheader() |
94 | 96 | self._test_getdifficulty() |
95 | 97 | self._test_getnetworkhashps() |
@@ -400,6 +402,33 @@ def _test_gettxoutsetinfo(self): |
400 | 402 | # Unknown hash_type raises an error |
401 | 403 | assert_raises_rpc_error(-8, "'foo hash' is not a valid hash_type", node.gettxoutsetinfo, "foo hash") |
402 | 404 |
|
| 405 | + def _test_gettxout(self): |
| 406 | + self.log.info("Validating gettxout RPC response") |
| 407 | + node = self.nodes[0] |
| 408 | + |
| 409 | + # Get the best block hash and the block, which |
| 410 | + # should only include the coinbase transaction. |
| 411 | + best_block_hash = node.getbestblockhash() |
| 412 | + block = node.getblock(best_block_hash) |
| 413 | + assert_equal(block['nTx'], 1) |
| 414 | + |
| 415 | + # Get the transaction ID of the coinbase tx and |
| 416 | + # the transaction output. |
| 417 | + txid = block['tx'][0] |
| 418 | + txout = node.gettxout(txid, 0) |
| 419 | + |
| 420 | + # Validate the gettxout response |
| 421 | + assert_equal(txout['bestblock'], best_block_hash) |
| 422 | + assert_equal(txout['confirmations'], 1) |
| 423 | + assert_equal(txout['value'], 25) |
| 424 | + assert_equal(txout['scriptPubKey']['address'], self.wallet.get_address()) |
| 425 | + assert_equal(txout['scriptPubKey']['hex'], self.wallet.get_scriptPubKey().hex()) |
| 426 | + decoded_script = node.decodescript(self.wallet.get_scriptPubKey().hex()) |
| 427 | + assert_equal(txout['scriptPubKey']['asm'], decoded_script['asm']) |
| 428 | + assert_equal(txout['scriptPubKey']['desc'], decoded_script['desc']) |
| 429 | + assert_equal(txout['scriptPubKey']['type'], decoded_script['type']) |
| 430 | + assert_equal(txout['coinbase'], True) |
| 431 | + |
403 | 432 | def _test_getblockheader(self): |
404 | 433 | self.log.info("Test getblockheader") |
405 | 434 | node = self.nodes[0] |
|
0 commit comments