Skip to content

Commit 7f37a1d

Browse files
committed
Merge bitcoin#21785: test: Fix intermittent issue in p2p_addr_relay.py
faa51ef test: Fix intermittent issue in p2p_addr_relay.py (MarcoFalke) fa37116 test: Use self.send_addr_msg (MarcoFalke) Pull request description: Fixes https://github.com/bitcoin/bitcoin/pull/21707/files#r621048952 ACKs for top commit: mzumsande: ACK faa51ef amitiuttarwar: ACK faa51ef Tree-SHA512: b1fbc1a4a13b020890b465083a82762981de17dd710388c651353aefc28dee23d39803c2a1dadbf88287e92598901afcb01b488115b0fecd746ab6d73775415b
2 parents 2cbb4ab + faa51ef commit 7f37a1d

File tree

4 files changed

+13
-13
lines changed

4 files changed

+13
-13
lines changed

test/functional/p2p_addr_relay.py

Lines changed: 2 additions & 5 deletions
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')
@@ -203,10 +203,7 @@ def blocksonly_mode_tests(self):
203203
self.log.info('Check that we relay address messages')
204204
addr_source = self.nodes[0].add_p2p_connection(P2PInterface())
205205
msg = self.setup_addr_msg(2)
206-
addr_source.send_and_ping(msg)
207-
self.mocktime += 5 * 60
208-
self.nodes[0].setmocktime(self.mocktime)
209-
full_outbound_peer.sync_with_ping()
206+
self.send_addr_msg(addr_source, msg, [full_outbound_peer])
210207
assert_equal(full_outbound_peer.num_ipv4_received, 2)
211208

212209
self.nodes[0].disconnect_p2ps()

test/functional/p2p_blocksonly.py

Lines changed: 1 addition & 5 deletions
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

Lines changed: 1 addition & 2 deletions
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

Lines changed: 9 additions & 1 deletion
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)