mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-15 11:36:00 -05:00
QA: rpc_blockchain: Test output of getblock verbosity 0, False, and True
This commit is contained in:
parent
30308cc380
commit
f663b43df0
1 changed files with 10 additions and 0 deletions
|
@ -38,6 +38,7 @@ from test_framework.messages import (
|
||||||
msg_block,
|
msg_block,
|
||||||
)
|
)
|
||||||
from test_framework.p2p import P2PInterface
|
from test_framework.p2p import P2PInterface
|
||||||
|
from test_framework.script import hash256
|
||||||
from test_framework.test_framework import BitcoinTestFramework
|
from test_framework.test_framework import BitcoinTestFramework
|
||||||
from test_framework.util import (
|
from test_framework.util import (
|
||||||
assert_equal,
|
assert_equal,
|
||||||
|
@ -484,6 +485,10 @@ class BlockchainTest(BitcoinTestFramework):
|
||||||
self.wallet.send_self_transfer(fee_rate=fee_per_kb, from_node=node)
|
self.wallet.send_self_transfer(fee_rate=fee_per_kb, from_node=node)
|
||||||
blockhash = self.generate(node, 1)[0]
|
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):
|
def assert_fee_not_in_block(verbosity):
|
||||||
block = node.getblock(blockhash, verbosity)
|
block = node.getblock(blockhash, verbosity)
|
||||||
assert 'fee' not in block['tx'][1]
|
assert 'fee' not in block['tx'][1]
|
||||||
|
@ -518,8 +523,13 @@ class BlockchainTest(BitcoinTestFramework):
|
||||||
for vin in tx["vin"]:
|
for vin in tx["vin"]:
|
||||||
assert "prevout" not in 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")
|
self.log.info("Test that getblock with verbosity 1 doesn't include fee")
|
||||||
assert_fee_not_in_block(1)
|
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')
|
self.log.info('Test that getblock with verbosity 2 and 3 includes expected fee')
|
||||||
assert_fee_in_block(2)
|
assert_fee_in_block(2)
|
||||||
|
|
Loading…
Add table
Reference in a new issue