Skip to content

Commit aeeccd9

Browse files
committed
test: Fix intermittent issue in p2p_addr_relay.py
by increasing the mocktime bump for m_next_addr_send, which is on a Poisson timer, and explain why. Closes #22449
1 parent 926fc2a commit aeeccd9

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

test/functional/p2p_addr_relay.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,10 @@ def setup_rand_addr_msg(self, num):
121121

122122
def send_addr_msg(self, source, msg, receivers):
123123
source.send_and_ping(msg)
124-
# pop m_next_addr_send timer
124+
# invoke m_next_addr_send timer:
125+
# `addr` messages are sent on an exponential distribution with mean interval of 30s.
126+
# Setting the mocktime 600s forward gives a probability of (1 - e^-(600/30)) that
127+
# the event will occur (i.e. this fails once in ~500 million repeats).
125128
self.mocktime += 10 * 60
126129
self.nodes[0].setmocktime(self.mocktime)
127130
for peer in receivers:
@@ -282,7 +285,8 @@ def getaddr_tests(self):
282285
block_relay_peer.send_and_ping(msg_getaddr())
283286
inbound_peer.send_and_ping(msg_getaddr())
284287

285-
self.mocktime += 5 * 60
288+
# invoke m_next_addr_send timer, see under send_addr_msg() function for rationale
289+
self.mocktime += 10 * 60
286290
self.nodes[0].setmocktime(self.mocktime)
287291
inbound_peer.wait_until(lambda: inbound_peer.addr_received() is True)
288292

0 commit comments

Comments
 (0)