Skip to content

Commit c4027e7

Browse files
committed
refactor: test: use wait_for_getdata() in p2p_compactblocks.py
1 parent d8ca51d commit c4027e7

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)