Skip to content

Commit 75848bc

Browse files
committed
[tests] Fix p2p_sendheaders race
p2p_sendheaders has a race in part 1.3. part 1.2 sends a block to the node over the 'test_node' connection, but doesn't wait for an inv to be received on the 'inv_node' connection. If we get to part 1.3 before that inv has been received, then the subsequent call to check_last_inv_announcement could fail.
1 parent 6579d80 commit 75848bc

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

test/functional/p2p_sendheaders.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,7 @@ def test_nonnull_locators(self, test_node, inv_node):
306306
test_node.clear_block_announcements() # since we requested headers...
307307
elif i == 2:
308308
# this time announce own block via headers
309+
inv_node.clear_block_announcements()
309310
height = self.nodes[0].getblockcount()
310311
last_time = self.nodes[0].getblock(self.nodes[0].getbestblockhash())['time']
311312
block_time = last_time + 1
@@ -315,6 +316,7 @@ def test_nonnull_locators(self, test_node, inv_node):
315316
test_node.wait_for_getdata([new_block.sha256])
316317
test_node.send_message(msg_block(new_block))
317318
test_node.sync_with_ping() # make sure this block is processed
319+
wait_until(lambda: inv_node.block_announced, timeout=60, lock=mininode_lock)
318320
inv_node.clear_block_announcements()
319321
test_node.clear_block_announcements()
320322

0 commit comments

Comments
 (0)