Skip to content

Commit e864f2e

Browse files
author
MacroFake
committed
Merge bitcoin/bitcoin#25976: QA: rpc_blockchain: Test output of getblock verbosity 0, False, and True
f663b43 QA: rpc_blockchain: Test output of getblock verbosity 0, False, and True (Luke Dashjr) Pull request description: Currently getblock's "verbosity" is documented as a NUM, though it has a fallback to Boolean for the (deprecated?) "verbose" alias. Since we've been doing more generic type-checking on RPC stuff, I think it would be a good idea to actually test the Boolean values work. I didn't see an existing test for verbosity=0, so this adds that too. ACKs for top commit: aureleoules: ACK f663b43. Tree-SHA512: 321a7795a2f32e469d28879dd323c85cb6b221828030e2a33ad9afd35a648191151a79b04e359b2f58314e43360f81c25f05be07deb42f61efdf556850a7266c
2 parents 0ebd4db + f663b43 commit e864f2e

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,
@@ -485,6 +486,10 @@ def _test_getblock(self):
485486
self.wallet.send_self_transfer(fee_rate=fee_per_kb, from_node=node)
486487
blockhash = self.generate(node, 1)[0]
487488

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

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

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

0 commit comments

Comments
 (0)