mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-10 22:18:54 +01:00
test: Extends wait_for_getheaders so a specific block hash can be checked
Previously, `wait_for_getheaders` would check whether a node had received **any** getheaders message. This implied that, if a test needed to check for a specific block hash within a headers message, it had to make sure that it was checking the desired message. This normally involved having to manually clear `last_message`. This method, apart from being too verbose, was error prone, given an undesired `getheaders` would make tests pass. This adds the ability to check for a specific block_hash within the last `getheaders` message.
This commit is contained in:
@@ -308,7 +308,7 @@ class MiningTest(BitcoinTestFramework):
|
||||
|
||||
# Should ask for the block from a p2p node, if they announce the header as well:
|
||||
peer = node.add_p2p_connection(P2PDataStore())
|
||||
peer.wait_for_getheaders(timeout=5) # Drop the first getheaders
|
||||
peer.wait_for_getheaders(timeout=5, block_hash=block.hashPrevBlock)
|
||||
peer.send_blocks_and_test(blocks=[block], node=node)
|
||||
# Must be active now:
|
||||
assert chain_tip(block.hash, status='active', branchlen=0) in node.getchaintips()
|
||||
|
||||
Reference in New Issue
Block a user