mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-07-02 03:31:35 +02:00
[test] Add test for getblockheader verboseness
Add test for getblockheader with verbose argument set to false.
This commit is contained in:
@ -38,6 +38,8 @@ from test_framework.blocktools import (
|
|||||||
TIME_GENESIS_BLOCK,
|
TIME_GENESIS_BLOCK,
|
||||||
)
|
)
|
||||||
from test_framework.messages import (
|
from test_framework.messages import (
|
||||||
|
CBlockHeader,
|
||||||
|
FromHex,
|
||||||
msg_block,
|
msg_block,
|
||||||
)
|
)
|
||||||
from test_framework.mininode import (
|
from test_framework.mininode import (
|
||||||
@ -280,6 +282,14 @@ class BlockchainTest(BitcoinTestFramework):
|
|||||||
assert isinstance(int(header['versionHex'], 16), int)
|
assert isinstance(int(header['versionHex'], 16), int)
|
||||||
assert isinstance(header['difficulty'], Decimal)
|
assert isinstance(header['difficulty'], Decimal)
|
||||||
|
|
||||||
|
# Test with verbose=False, which should return the header as hex.
|
||||||
|
header_hex = node.getblockheader(blockhash=besthash, verbose=False)
|
||||||
|
assert_is_hex_string(header_hex)
|
||||||
|
|
||||||
|
header = FromHex(CBlockHeader(), header_hex)
|
||||||
|
header.calc_sha256()
|
||||||
|
assert_equal(header.hash, besthash)
|
||||||
|
|
||||||
def _test_getdifficulty(self):
|
def _test_getdifficulty(self):
|
||||||
difficulty = self.nodes[0].getdifficulty()
|
difficulty = self.nodes[0].getdifficulty()
|
||||||
# 1 hash in 2 should be valid, so difficulty should be 1/2**31
|
# 1 hash in 2 should be valid, so difficulty should be 1/2**31
|
||||||
|
Reference in New Issue
Block a user