Merge bitcoin/bitcoin#34204: test: fix intermittent failure in p2p_addr_selfannouncement

31852057ea test: fix intermittent failure in p2p_addr_selfannouncement (0xb10c)

Pull request description:

  Due to the mocktime being bumped before the expected time is updated, it could happen that the self-announcement is send with an newer timestamp than what we expect. To fix this, update the expected time before we bump the mocktime.

  closes #34159

ACKs for top commit:
  bensig:
    ACK 31852057ea
  maflcko:
    lgtm ACK 31852057ea
  w0xlt:
    ACK 31852057ea
  naiyoma:
    utACK 31852057ea

Tree-SHA512: 24696f6005c7131d4c9328f6ff43ddded863b8ba6b2cac6f6009bcb4617616c0c35a0b55812d5010f74385d8e6d4ea09dd2b06b5f4ada2bb7e86d7abee764192
This commit is contained in:
merge-script
2026-01-06 09:38:12 +00:00

View File

@@ -128,8 +128,8 @@ class AddrSelfAnnouncementTest(BitcoinTestFramework):
# self-announcements are sent on an exponential distribution with mean interval of 24h.
# Setting the mocktime 20d forward gives a probability of (1 - e^-(480/24)) that
# the event will occur (i.e. this fails once in ~500 million repeats).
addr_receiver.expected.time = self.nodes[0].mocktime + 20 * ONE_DAY
self.nodes[0].bumpmocktime(20 * ONE_DAY)
addr_receiver.expected.time = self.nodes[0].mocktime
addr_receiver.sync_with_ping()
assert_equal(addr_receiver.self_announcements_received, last_self_announcements_received + 1)