mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-09-18 19:31:06 +02:00
Merge bitcoin/bitcoin#25976: QA: rpc_blockchain: Test output of getblock verbosity 0, False, and True
f663b43df0
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: ACKf663b43df0
. Tree-SHA512: 321a7795a2f32e469d28879dd323c85cb6b221828030e2a33ad9afd35a648191151a79b04e359b2f58314e43360f81c25f05be07deb42f61efdf556850a7266c
This commit is contained in:
@@ -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,
|
||||
@@ -485,6 +486,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]
|
||||
@@ -519,8 +524,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)
|
||||
|
Reference in New Issue
Block a user