Skip to content

Commit

Permalink
Merge bitcoin#19722: test: Add test for getblockheader verboseness
Browse files Browse the repository at this point in the history
5067c5a [test] Add test for getblockheader verboseness (Torhte Butler)

Pull request description:

  Improve test coverage by adding a test for getblockheader with verbose argument set to false.

ACKs for top commit:
  theStack:
    ACK bitcoin@5067c5a

Tree-SHA512: e55593f1026a89dc7b796fa985b4cbcdb596e91d80d42dfb0660bda1692aaa35749ec29f9cd7032803f6225afb323f085df1ef6a9982de87be8e098f7253cdd5
  • Loading branch information
MarcoFalke committed Aug 21, 2020
2 parents 0d9e14a + 5067c5a commit d254e6e
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions test/functional/rpc_blockchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
TIME_GENESIS_BLOCK,
)
from test_framework.messages import (
CBlockHeader,
FromHex,
msg_block,
)
from test_framework.mininode import (
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit d254e6e

Please sign in to comment.