Skip to content

Commit faa51ef

Browse files
author
MarcoFalke
committed
test: Fix intermittent issue in p2p_addr_relay.py
1 parent fa37116 commit faa51ef

File tree

4 files changed

+12
-9
lines changed

4 files changed

+12
-9
lines changed

test/functional/p2p_addr_relay.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def send_addr_msg(self, source, msg, receivers):
8282
self.mocktime += 5 * 60
8383
self.nodes[0].setmocktime(self.mocktime)
8484
for peer in receivers:
85-
peer.sync_with_ping()
85+
peer.sync_send_with_ping()
8686

8787
def oversized_addr_test(self):
8888
self.log.info('Send an addr message that is too large')

test/functional/p2p_blocksonly.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,7 @@ def blocks_relay_conn_tests(self):
8989
# Bump time forward to ensure nNextInvSend timer pops
9090
self.nodes[0].setmocktime(int(time.time()) + 60)
9191

92-
# Calling sync_with_ping twice requires that the node calls
93-
# `ProcessMessage` twice, and thus ensures `SendMessages` must have
94-
# been called at least once
95-
conn.sync_with_ping()
96-
conn.sync_with_ping()
92+
conn.sync_send_with_ping()
9793
assert(int(txid, 16) not in conn.get_invs())
9894

9995
def check_p2p_tx_violation(self, index=1):

test/functional/p2p_filter.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,7 @@ def test_filter(self, filter_peer):
174174
filter_peer.merkleblock_received = False
175175
filter_peer.tx_received = False
176176
self.nodes[0].sendtoaddress(self.nodes[0].getnewaddress(), 90)
177-
filter_peer.sync_with_ping()
178-
filter_peer.sync_with_ping()
177+
filter_peer.sync_send_with_ping()
179178
assert not filter_peer.merkleblock_received
180179
assert not filter_peer.tx_received
181180

test/functional/test_framework/p2p.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -539,8 +539,16 @@ def send_and_ping(self, message, timeout=60):
539539
self.send_message(message)
540540
self.sync_with_ping(timeout=timeout)
541541

542-
# Sync up with the node
542+
def sync_send_with_ping(self, timeout=60):
543+
"""Ensure SendMessages is called on this connection"""
544+
# Calling sync_with_ping twice requires that the node calls
545+
# `ProcessMessage` twice, and thus ensures `SendMessages` must have
546+
# been called at least once
547+
self.sync_with_ping()
548+
self.sync_with_ping()
549+
543550
def sync_with_ping(self, timeout=60):
551+
"""Ensure ProcessMessages is called on this connection"""
544552
self.send_message(msg_ping(nonce=self.ping_counter))
545553

546554
def test_function():

0 commit comments

Comments
 (0)