Skip to content

Conversation

@0xB10C
Copy link
Contributor

@0xB10C 0xB10C commented Dec 10, 2025

Test that a node sends a self-announcement with its external IP to in- and outbound peers after connection open and again sometime later.

Since the code for the test is mostly the same for addr and addrv2 messages, I opted to add a new test file instead of having duplicate code in p2p_addr_relay.py and p2p_addrv2_relay.py.

@DrahtBot DrahtBot added the Tests label Dec 10, 2025
@DrahtBot
Copy link
Contributor

DrahtBot commented Dec 10, 2025

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Code Coverage & Benchmarks

For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/34039.

Reviews

See the guideline for information on the review process.

Type Reviewers
ACK Bicaru20

If your review is incorrectly listed, please copy-paste <!--meta-tag:bot-skip--> into the comment that the bot should ignore.

Comment on lines +110 to +114
# m_next_local_addr_send and AVG_LOCAL_ADDRESS_BROADCAST_INTERVAL:
# 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).
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

inspired by

# invoke m_next_addr_send timer:
# `addr` messages are sent on an exponential distribution with mean interval of 30s.
# Setting the mocktime 600s forward gives a probability of (1 - e^-(600/30)) that
# the event will occur (i.e. this fails once in ~500 million repeats).
(using the same exponent of e^-20 here)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nothing for this PR, but since these things are quite common (recently #33121), I wonder if a mode -test=cutoffexponentialtimers or something similar would make sense which would cut off the long tail of all exponential timers (rand_exp_duration) at some percentile, so we don't need to deal with these probabilistic failures in functional tests.

Test that a node sends a self-announcement with its external IP to
in- and outbound peers after connection open and again sometime later.

Since the code for the test is mostly the same for addr and addrv2
messages, I opted to add a new test file instead of having duplicate
code in p2p_addr_relay.py and p2p_addrv2_relay.py.
@0xB10C 0xB10C force-pushed the 2025-12-test-address-self-announcement branch from 2cac7e0 to fb9c393 Compare December 10, 2025 15:56
Comment on lines +67 to +68
first_octet = 1 + (i >> 8)
second_octet = i % 256

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since increasing the 50 in the loop will not contribute anything to the test, maybe the >> 8 and % 256 could be erased.

Suggested change
first_octet = 1 + (i >> 8)
second_octet = i % 256
first_octet = 1 + i
second_octet = i

@Bicaru20
Copy link

Code review ACK fb9c393. I have run the test and everything checks out.

I left a small comment in the code, also fine with merging as-is

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants