Skip to content

Commit 9e165d0

Browse files
Empactbillygarrison
andcommitted
test: Wait for 'cmpctblock' in p2p_compactblocks when it is expected
This is a more narrowly-construed wait which eliminates the possibility of the wait being triggered by other messages. Co-authored-by: Billy Garrison <[email protected]>
1 parent edec7f7 commit 9e165d0

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)