aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2020-04-24 16:35:39 -0400
committerMarcoFalke <falke.marco@gmail.com>2020-04-24 16:37:17 -0400
commita215c6133323cc9f27bc9ea12299f3a907329545 (patch)
tree15362866c22d311f692984e9aa79e0a249d811ec
parent29637a5c56fd8dc8b55c385b2c56a291fe3a70a5 (diff)
parentc4027e735072c3de4b4ffb20eecd7187ff36bad7 (diff)
downloadbitcoin-a215c6133323cc9f27bc9ea12299f3a907329545.tar.xz
Merge #18756: refactor: test: use wait_for_getdata() in p2p_compactblocks.py
c4027e735072c3de4b4ffb20eecd7187ff36bad7 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 c4027e735072c3de4b4ffb20eecd7187ff36bad7 Tree-SHA512: e10b346742f235b6ee2ef1f32f7fd74406c1a277389f020fb9913a93e94cc9530e1e9414872b83c9d2ae652ebce2b09b2c8c8372260c1afb4e0e54fbf7a935b0
-rwxr-xr-xtest/functional/p2p_compactblocks.py10
1 files changed, 2 insertions, 8 deletions
diff --git a/test/functional/p2p_compactblocks.py b/test/functional/p2p_compactblocks.py
index 7905cf5018..66e6f8c424 100755
--- a/test/functional/p2p_compactblocks.py
+++ b/test/functional/p2p_compactblocks.py
@@ -378,8 +378,6 @@ class CompactBlocksTest(BitcoinTestFramework):
# request
for announce in ["inv", "header"]:
block = self.build_block_on_tip(node, segwit=segwit)
- with mininode_lock:
- test_node.last_message.pop("getdata", None)
if announce == "inv":
test_node.send_message(msg_inv([CInv(2, block.sha256)]))
@@ -387,10 +385,8 @@ class CompactBlocksTest(BitcoinTestFramework):
test_node.send_header_for_blocks([block])
else:
test_node.send_header_for_blocks([block])
- wait_until(lambda: "getdata" in test_node.last_message, timeout=30, lock=mininode_lock)
- assert_equal(len(test_node.last_message["getdata"].inv), 1)
+ test_node.wait_for_getdata([block.sha256], timeout=30)
assert_equal(test_node.last_message["getdata"].inv[0].type, 4)
- assert_equal(test_node.last_message["getdata"].inv[0].hash, block.sha256)
# Send back a compactblock message that omits the coinbase
comp_block = HeaderAndShortIDs()
@@ -567,10 +563,8 @@ class CompactBlocksTest(BitcoinTestFramework):
assert_equal(int(node.getbestblockhash(), 16), block.hashPrevBlock)
# We should receive a getdata request
- wait_until(lambda: "getdata" in test_node.last_message, timeout=10, lock=mininode_lock)
- assert_equal(len(test_node.last_message["getdata"].inv), 1)
+ test_node.wait_for_getdata([block.sha256], timeout=10)
assert test_node.last_message["getdata"].inv[0].type == 2 or test_node.last_message["getdata"].inv[0].type == 2 | MSG_WITNESS_FLAG
- assert_equal(test_node.last_message["getdata"].inv[0].hash, block.sha256)
# Deliver the block
if version == 2: