From 5067c5acc30c5cf87496c1bf8eb03712cc66b206 Mon Sep 17 00:00:00 2001 From: Torhte Butler Date: Fri, 14 Aug 2020 18:19:14 +0000 Subject: [PATCH] [test] Add test for getblockheader verboseness Add test for getblockheader with verbose argument set to false. --- test/functional/rpc_blockchain.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/functional/rpc_blockchain.py b/test/functional/rpc_blockchain.py index 7c70f30ca368d..7f4241fb5fd85 100755 --- a/test/functional/rpc_blockchain.py +++ b/test/functional/rpc_blockchain.py @@ -38,6 +38,8 @@ TIME_GENESIS_BLOCK, ) from test_framework.messages import ( + CBlockHeader, + FromHex, msg_block, ) from test_framework.mininode import ( @@ -280,6 +282,14 @@ def _test_getblockheader(self): assert isinstance(int(header['versionHex'], 16), int) 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): difficulty = self.nodes[0].getdifficulty() # 1 hash in 2 should be valid, so difficulty should be 1/2**31