mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-03-05 14:06:27 -05:00
Merge #19631: test: Wait for 'cmpctblock' in p2p_compactblocks when it is expected
9e165d0de4
test: Wait for 'cmpctblock' in p2p_compactblocks when it is expected (Ben Woosley) Pull request description: This is a more narrowly-construed wait which eliminates the possibility of the wait being triggered by other messages. Note `received_block_announcement` reflect three possible messages:edec7f7c25/test/functional/p2p_compactblocks.py (L34-L53)
Prompted by looking into: #19449 ACKs for top commit: laanwj: Code review ACK9e165d0de4
theStack: ACK9e165d0de4
Tree-SHA512: bc4a9c8bf031c8a7efb40d9625feaa3fd1f56f3b75da7034944af71ccea44328a6c708ab0c13fea85fb7cf4fd9043fe90eb94a25e95b2d42be44c2962b4904ce
This commit is contained in:
commit
be11f94e95
1 changed files with 3 additions and 6 deletions
|
@ -294,12 +294,11 @@ class CompactBlocksTest(BitcoinTestFramework):
|
||||||
block.rehash()
|
block.rehash()
|
||||||
|
|
||||||
# Wait until the block was announced (via compact blocks)
|
# Wait until the block was announced (via compact blocks)
|
||||||
wait_until(test_node.received_block_announcement, timeout=30, lock=mininode_lock)
|
wait_until(lambda: "cmpctblock" in test_node.last_message, timeout=30, lock=mininode_lock)
|
||||||
|
|
||||||
# Now fetch and check the compact block
|
# Now fetch and check the compact block
|
||||||
header_and_shortids = None
|
header_and_shortids = None
|
||||||
with mininode_lock:
|
with mininode_lock:
|
||||||
assert "cmpctblock" in test_node.last_message
|
|
||||||
# Convert the on-the-wire representation to absolute indexes
|
# Convert the on-the-wire representation to absolute indexes
|
||||||
header_and_shortids = HeaderAndShortIDs(test_node.last_message["cmpctblock"].header_and_shortids)
|
header_and_shortids = HeaderAndShortIDs(test_node.last_message["cmpctblock"].header_and_shortids)
|
||||||
self.check_compactblock_construction_from_block(version, header_and_shortids, block_hash, block)
|
self.check_compactblock_construction_from_block(version, header_and_shortids, block_hash, block)
|
||||||
|
@ -309,12 +308,11 @@ class CompactBlocksTest(BitcoinTestFramework):
|
||||||
inv = CInv(MSG_CMPCT_BLOCK, block_hash)
|
inv = CInv(MSG_CMPCT_BLOCK, block_hash)
|
||||||
test_node.send_message(msg_getdata([inv]))
|
test_node.send_message(msg_getdata([inv]))
|
||||||
|
|
||||||
wait_until(test_node.received_block_announcement, timeout=30, lock=mininode_lock)
|
wait_until(lambda: "cmpctblock" in test_node.last_message, timeout=30, lock=mininode_lock)
|
||||||
|
|
||||||
# Now fetch and check the compact block
|
# Now fetch and check the compact block
|
||||||
header_and_shortids = None
|
header_and_shortids = None
|
||||||
with mininode_lock:
|
with mininode_lock:
|
||||||
assert "cmpctblock" in test_node.last_message
|
|
||||||
# Convert the on-the-wire representation to absolute indexes
|
# Convert the on-the-wire representation to absolute indexes
|
||||||
header_and_shortids = HeaderAndShortIDs(test_node.last_message["cmpctblock"].header_and_shortids)
|
header_and_shortids = HeaderAndShortIDs(test_node.last_message["cmpctblock"].header_and_shortids)
|
||||||
self.check_compactblock_construction_from_block(version, header_and_shortids, block_hash, block)
|
self.check_compactblock_construction_from_block(version, header_and_shortids, block_hash, block)
|
||||||
|
@ -691,10 +689,9 @@ class CompactBlocksTest(BitcoinTestFramework):
|
||||||
node.submitblock(ToHex(block))
|
node.submitblock(ToHex(block))
|
||||||
|
|
||||||
for l in listeners:
|
for l in listeners:
|
||||||
wait_until(lambda: l.received_block_announcement(), timeout=30, lock=mininode_lock)
|
wait_until(lambda: "cmpctblock" in l.last_message, timeout=30, lock=mininode_lock)
|
||||||
with mininode_lock:
|
with mininode_lock:
|
||||||
for l in listeners:
|
for l in listeners:
|
||||||
assert "cmpctblock" in l.last_message
|
|
||||||
l.last_message["cmpctblock"].header_and_shortids.header.calc_sha256()
|
l.last_message["cmpctblock"].header_and_shortids.header.calc_sha256()
|
||||||
assert_equal(l.last_message["cmpctblock"].header_and_shortids.header.sha256, block.sha256)
|
assert_equal(l.last_message["cmpctblock"].header_and_shortids.header.sha256, block.sha256)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue