Skip to content

Commit a215c61

Browse files
author
MarcoFalke
committed
Merge #18756: refactor: test: use wait_for_getdata() in p2p_compactblocks.py
c4027e7 refactor: test: use wait_for_getdata() in p2p_compactblocks.py (Sebastian Falbesoner) Pull request description: The method `wait_for_getdata()` was recently changed to be more precise by waiting for a specified list of hashes, instead of only matching _any_ `getdata` message (see Issue #18614 and PR #18690). This PR replaces the remaining occurences of manual inspection of `last_messages` with this call. ACKs for top commit: robot-visions: ACK c4027e7 Tree-SHA512: e10b346742f235b6ee2ef1f32f7fd74406c1a277389f020fb9913a93e94cc9530e1e9414872b83c9d2ae652ebce2b09b2c8c8372260c1afb4e0e54fbf7a935b0
2 parents 29637a5 + c4027e7 commit a215c61

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

test/functional/p2p_compactblocks.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -378,19 +378,15 @@ def test_compactblock_requests(self, test_node, segwit=True):
378378
# request
379379
for announce in ["inv", "header"]:
380380
block = self.build_block_on_tip(node, segwit=segwit)
381-
with mininode_lock:
382-
test_node.last_message.pop("getdata", None)
383381

384382
if announce == "inv":
385383
test_node.send_message(msg_inv([CInv(2, block.sha256)]))
386384
wait_until(lambda: "getheaders" in test_node.last_message, timeout=30, lock=mininode_lock)
387385
test_node.send_header_for_blocks([block])
388386
else:
389387
test_node.send_header_for_blocks([block])
390-
wait_until(lambda: "getdata" in test_node.last_message, timeout=30, lock=mininode_lock)
391-
assert_equal(len(test_node.last_message["getdata"].inv), 1)
388+
test_node.wait_for_getdata([block.sha256], timeout=30)
392389
assert_equal(test_node.last_message["getdata"].inv[0].type, 4)
393-
assert_equal(test_node.last_message["getdata"].inv[0].hash, block.sha256)
394390

395391
# Send back a compactblock message that omits the coinbase
396392
comp_block = HeaderAndShortIDs()
@@ -567,10 +563,8 @@ def test_incorrect_blocktxn_response(self, test_node):
567563
assert_equal(int(node.getbestblockhash(), 16), block.hashPrevBlock)
568564

569565
# We should receive a getdata request
570-
wait_until(lambda: "getdata" in test_node.last_message, timeout=10, lock=mininode_lock)
571-
assert_equal(len(test_node.last_message["getdata"].inv), 1)
566+
test_node.wait_for_getdata([block.sha256], timeout=10)
572567
assert test_node.last_message["getdata"].inv[0].type == 2 or test_node.last_message["getdata"].inv[0].type == 2 | MSG_WITNESS_FLAG
573-
assert_equal(test_node.last_message["getdata"].inv[0].hash, block.sha256)
574568

575569
# Deliver the block
576570
if version == 2:

0 commit comments

Comments
 (0)