Skip to content

Commit f663b43

Browse files
committed
QA: rpc_blockchain: Test output of getblock verbosity 0, False, and True
1 parent 30308cc commit f663b43

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

test/functional/rpc_blockchain.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
msg_block,
3939
)
4040
from test_framework.p2p import P2PInterface
41+
from test_framework.script import hash256
4142
from test_framework.test_framework import BitcoinTestFramework
4243
from test_framework.util import (
4344
assert_equal,
@@ -484,6 +485,10 @@ def _test_getblock(self):
484485
self.wallet.send_self_transfer(fee_rate=fee_per_kb, from_node=node)
485486
blockhash = self.generate(node, 1)[0]
486487

488+
def assert_hexblock_hashes(verbosity):
489+
block = node.getblock(blockhash, verbosity)
490+
assert_equal(blockhash, hash256(bytes.fromhex(block[:160]))[::-1].hex())
491+
487492
def assert_fee_not_in_block(verbosity):
488493
block = node.getblock(blockhash, verbosity)
489494
assert 'fee' not in block['tx'][1]
@@ -518,8 +523,13 @@ def assert_vin_does_not_contain_prevout(verbosity):
518523
for vin in tx["vin"]:
519524
assert "prevout" not in vin
520525

526+
self.log.info("Test that getblock with verbosity 0 hashes to expected value")
527+
assert_hexblock_hashes(0)
528+
assert_hexblock_hashes(False)
529+
521530
self.log.info("Test that getblock with verbosity 1 doesn't include fee")
522531
assert_fee_not_in_block(1)
532+
assert_fee_not_in_block(True)
523533

524534
self.log.info('Test that getblock with verbosity 2 and 3 includes expected fee')
525535
assert_fee_in_block(2)

0 commit comments

Comments
 (0)