From f663b43df041da7777e6f45a8df04fa852f79106 Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Thu, 1 Sep 2022 18:47:36 +0000 Subject: QA: rpc_blockchain: Test output of getblock verbosity 0, False, and True --- test/functional/rpc_blockchain.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'test/functional') diff --git a/test/functional/rpc_blockchain.py b/test/functional/rpc_blockchain.py index b264f23fb5..90148f4c7c 100755 --- a/test/functional/rpc_blockchain.py +++ b/test/functional/rpc_blockchain.py @@ -38,6 +38,7 @@ from test_framework.messages import ( msg_block, ) from test_framework.p2p import P2PInterface +from test_framework.script import hash256 from test_framework.test_framework import BitcoinTestFramework from test_framework.util import ( assert_equal, @@ -484,6 +485,10 @@ class BlockchainTest(BitcoinTestFramework): self.wallet.send_self_transfer(fee_rate=fee_per_kb, from_node=node) blockhash = self.generate(node, 1)[0] + def assert_hexblock_hashes(verbosity): + block = node.getblock(blockhash, verbosity) + assert_equal(blockhash, hash256(bytes.fromhex(block[:160]))[::-1].hex()) + def assert_fee_not_in_block(verbosity): block = node.getblock(blockhash, verbosity) assert 'fee' not in block['tx'][1] @@ -518,8 +523,13 @@ class BlockchainTest(BitcoinTestFramework): for vin in tx["vin"]: assert "prevout" not in vin + self.log.info("Test that getblock with verbosity 0 hashes to expected value") + assert_hexblock_hashes(0) + assert_hexblock_hashes(False) + self.log.info("Test that getblock with verbosity 1 doesn't include fee") assert_fee_not_in_block(1) + assert_fee_not_in_block(True) self.log.info('Test that getblock with verbosity 2 and 3 includes expected fee') assert_fee_in_block(2) -- cgit v1.2.3