Skip to content

Commit 312e438

Browse files
MacroFakeknst
authored andcommitted
Merge 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
1 parent aba4757 commit 312e438

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
@@ -35,6 +35,7 @@
3535
from test_framework.governance import EXPECTED_STDERR_NO_GOV_PRUNE
3636
from test_framework.messages import (
3737
CBlockHeader,
38+
dashhash,
3839
from_hex,
3940
msg_block,
4041
)
@@ -491,6 +492,10 @@ def _test_getblock(self):
491492
self.wallet.send_self_transfer(fee_rate=fee_per_kb, from_node=node)
492493
blockhash = self.generate(node, 1)[0]
493494

495+
def assert_hexblock_hashes(verbosity):
496+
block = node.getblock(blockhash, verbosity)
497+
assert_equal(blockhash, dashhash(bytes.fromhex(block[:160]))[::-1].hex())
498+
494499
def assert_fee_not_in_block(verbosity):
495500
block = node.getblock(blockhash, verbosity)
496501
assert 'fee' not in block['tx'][1]
@@ -525,8 +530,13 @@ def assert_vin_does_not_contain_prevout(verbosity):
525530
for vin in tx["vin"]:
526531
assert "prevout" not in vin
527532

533+
self.log.info("Test that getblock with verbosity 0 hashes to expected value")
534+
assert_hexblock_hashes(0)
535+
assert_hexblock_hashes(False)
536+
528537
self.log.info("Test that getblock with verbosity 1 doesn't include fee")
529538
assert_fee_not_in_block(1)
539+
assert_fee_not_in_block(True)
530540

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

0 commit comments

Comments
 (0)