Skip to content

Commit 5067c5a

Browse files
committed
[test] Add test for getblockheader verboseness
Add test for getblockheader with verbose argument set to false.
1 parent 30dd562 commit 5067c5a

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,8 @@
3838
TIME_GENESIS_BLOCK,
3939
)
4040
from test_framework.messages import (
41+
CBlockHeader,
42+
FromHex,
4143
msg_block,
4244
)
4345
from test_framework.mininode import (
@@ -280,6 +282,14 @@ def _test_getblockheader(self):
280282
assert isinstance(int(header['versionHex'], 16), int)
281283
assert isinstance(header['difficulty'], Decimal)
282284

285+
# Test with verbose=False, which should return the header as hex.
286+
header_hex = node.getblockheader(blockhash=besthash, verbose=False)
287+
assert_is_hex_string(header_hex)
288+
289+
header = FromHex(CBlockHeader(), header_hex)
290+
header.calc_sha256()
291+
assert_equal(header.hash, besthash)
292+
283293
def _test_getdifficulty(self):
284294
difficulty = self.nodes[0].getdifficulty()
285295
# 1 hash in 2 should be valid, so difficulty should be 1/2**31

0 commit comments

Comments
 (0)