aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorBen Woosley <ben.woosley@gmail.com>2020-07-30 16:12:09 -0700
committerBen Woosley <ben.woosley@gmail.com>2020-07-30 16:13:48 -0700
commit9e165d0de4c3cd168137fc85b8f31b371bd4e851 (patch)
tree44b25ed5058caf6ffb3b2945926207b0eb9101d1 /test
parentedec7f7c254294cd5c46ae5cf304353d458bb852 (diff)
downloadbitcoin-9e165d0de4c3cd168137fc85b8f31b371bd4e851.tar.xz
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 <billygarrison.btc@gmail.com>
Diffstat (limited to 'test')
-rwxr-xr-xtest/functional/p2p_compactblocks.py9
1 files changed, 3 insertions, 6 deletions
diff --git a/test/functional/p2p_compactblocks.py b/test/functional/p2p_compactblocks.py
index 0b3738b572..3a33a96123 100755
--- a/test/functional/p2p_compactblocks.py
+++ b/test/functional/p2p_compactblocks.py
@@ -294,12 +294,11 @@ class CompactBlocksTest(BitcoinTestFramework):
block.rehash()
# Wait until the block was announced (via compact blocks)
- wait_until(test_node.received_block_announcement, timeout=30, lock=mininode_lock)
+ wait_until(lambda: "cmpctblock" in test_node.last_message, timeout=30, lock=mininode_lock)
# Now fetch and check the compact block
header_and_shortids = None
with mininode_lock:
- assert "cmpctblock" in test_node.last_message
# Convert the on-the-wire representation to absolute indexes
header_and_shortids = HeaderAndShortIDs(test_node.last_message["cmpctblock"].header_and_shortids)
self.check_compactblock_construction_from_block(version, header_and_shortids, block_hash, block)
@@ -309,12 +308,11 @@ class CompactBlocksTest(BitcoinTestFramework):
inv = CInv(MSG_CMPCT_BLOCK, block_hash)
test_node.send_message(msg_getdata([inv]))
- wait_until(test_node.received_block_announcement, timeout=30, lock=mininode_lock)
+ wait_until(lambda: "cmpctblock" in test_node.last_message, timeout=30, lock=mininode_lock)
# Now fetch and check the compact block
header_and_shortids = None
with mininode_lock:
- assert "cmpctblock" in test_node.last_message
# Convert the on-the-wire representation to absolute indexes
header_and_shortids = HeaderAndShortIDs(test_node.last_message["cmpctblock"].header_and_shortids)
self.check_compactblock_construction_from_block(version, header_and_shortids, block_hash, block)
@@ -691,10 +689,9 @@ class CompactBlocksTest(BitcoinTestFramework):
node.submitblock(ToHex(block))
for l in listeners:
- wait_until(lambda: l.received_block_announcement(), timeout=30, lock=mininode_lock)
+ wait_until(lambda: "cmpctblock" in l.last_message, timeout=30, lock=mininode_lock)
with mininode_lock:
for l in listeners:
- assert "cmpctblock" in l.last_message
l.last_message["cmpctblock"].header_and_shortids.header.calc_sha256()
assert_equal(l.last_message["cmpctblock"].header_and_shortids.header.sha256, block.sha256)