Skip to content

Commit be11f94

Browse files
committed
Merge #19631: test: Wait for 'cmpctblock' in p2p_compactblocks when it is expected
9e165d0 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: https://github.com/bitcoin/bitcoin/blob/edec7f7c254294cd5c46ae5cf304353d458bb852/test/functional/p2p_compactblocks.py#L34-L53 Prompted by looking into: #19449 ACKs for top commit: laanwj: Code review ACK 9e165d0 theStack: ACK bitcoin/bitcoin@9e165d0 Tree-SHA512: bc4a9c8bf031c8a7efb40d9625feaa3fd1f56f3b75da7034944af71ccea44328a6c708ab0c13fea85fb7cf4fd9043fe90eb94a25e95b2d42be44c2962b4904ce
2 parents 5e4fed9 + 9e165d0 commit be11f94

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

test/functional/p2p_compactblocks.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -294,12 +294,11 @@ def test_compactblock_construction(self, test_node, use_witness_address=True):
294294
block.rehash()
295295

296296
# Wait until the block was announced (via compact blocks)
297-
wait_until(test_node.received_block_announcement, timeout=30, lock=mininode_lock)
297+
wait_until(lambda: "cmpctblock" in test_node.last_message, timeout=30, lock=mininode_lock)
298298

299299
# Now fetch and check the compact block
300300
header_and_shortids = None
301301
with mininode_lock:
302-
assert "cmpctblock" in test_node.last_message
303302
# Convert the on-the-wire representation to absolute indexes
304303
header_and_shortids = HeaderAndShortIDs(test_node.last_message["cmpctblock"].header_and_shortids)
305304
self.check_compactblock_construction_from_block(version, header_and_shortids, block_hash, block)
@@ -309,12 +308,11 @@ def test_compactblock_construction(self, test_node, use_witness_address=True):
309308
inv = CInv(MSG_CMPCT_BLOCK, block_hash)
310309
test_node.send_message(msg_getdata([inv]))
311310

312-
wait_until(test_node.received_block_announcement, timeout=30, lock=mininode_lock)
311+
wait_until(lambda: "cmpctblock" in test_node.last_message, timeout=30, lock=mininode_lock)
313312

314313
# Now fetch and check the compact block
315314
header_and_shortids = None
316315
with mininode_lock:
317-
assert "cmpctblock" in test_node.last_message
318316
# Convert the on-the-wire representation to absolute indexes
319317
header_and_shortids = HeaderAndShortIDs(test_node.last_message["cmpctblock"].header_and_shortids)
320318
self.check_compactblock_construction_from_block(version, header_and_shortids, block_hash, block)
@@ -691,10 +689,9 @@ def test_end_to_end_block_relay(self, listeners):
691689
node.submitblock(ToHex(block))
692690

693691
for l in listeners:
694-
wait_until(lambda: l.received_block_announcement(), timeout=30, lock=mininode_lock)
692+
wait_until(lambda: "cmpctblock" in l.last_message, timeout=30, lock=mininode_lock)
695693
with mininode_lock:
696694
for l in listeners:
697-
assert "cmpctblock" in l.last_message
698695
l.last_message["cmpctblock"].header_and_shortids.header.calc_sha256()
699696
assert_equal(l.last_message["cmpctblock"].header_and_shortids.header.sha256, block.sha256)
700697

0 commit comments

Comments
 (0)