test: use static methods and clarify comment in addr_relay
What changed, and why it matters
This is a minor cleanup of Bitcoin Core's own functional test code. It changes two helper methods to be static (they don't need access to test class state) and rewrites a comment to be clearer about why the test still sends an initial GETADDR message. There is no change to the actual Bitcoin node software, no security fix, and no vulnerability.
No security action needed. This is a routine test-maintenance commit.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit modifies only test/functional/p2p_addr_relay.py and test/functional/p2p_addr_selfannouncement.py. It adds @staticmethod decorators to two assertion helpers and updates a comment explaining that the initial GETADDR is still needed to initialize address relay for inbound connections, even though the test framework now supports disabling it. No production code is touched.
Changed components
test/functional/p2p_addr_relay.pytest/functional/p2p_addr_selfannouncement.pyInspect captured patch +5 / −4
diff --git a/test/functional/p2p_addr_relay.py b/test/functional/p2p_addr_relay.py
index eea8ee53..65b21c0d 100755
--- a/test/functional/p2p_addr_relay.py
+++ b/test/functional/p2p_addr_relay.py
@@ -402,8 +402,7 @@ class AddrTest(BitcoinTestFramework):
def get_nodes_that_received_addr(self, peer, receiver_peer, addr_receivers,
time_interval_1, time_interval_2):
- # Clean addr response related to the initial getaddr. There is no way to avoid initial
- # getaddr because the peer won't self-announce then.
+ # Clean addr response related to the initial getaddr.
for addr_receiver in addr_receivers:
addr_receiver.num_ipv4_received = 0
diff --git a/test/functional/p2p_addr_selfannouncement.py b/test/functional/p2p_addr_selfannouncement.py
index 8ab75aaa..631ecb4c 100755
--- a/test/functional/p2p_addr_selfannouncement.py
+++ b/test/functional/p2p_addr_selfannouncement.py
@@ -78,14 +78,16 @@ class AddrSelfAnnouncementTest(BitcoinTestFramework):
self.self_announcement_test(outbound=True, addrv2=False)
self.self_announcement_test(outbound=True, addrv2=True)
- def inbound_connection_open_assertions(self, addr_receiver):
+ @staticmethod
+ def inbound_connection_open_assertions(addr_receiver):
# In response to a GETADDR, we expect a message with the self-announcement
# and an addr message containing the GETADDR response.
assert_equal(addr_receiver.self_announcements_received, 1)
assert_equal(addr_receiver.addr_messages_received, 2)
assert_greater_than(addr_receiver.addresses_received, 1)
- def outbound_connection_open_assertions(self, addr_receiver):
+ @staticmethod
+ def outbound_connection_open_assertions(addr_receiver):
# We expect only the self-announcement.
assert_equal(addr_receiver.self_announcements_received, 1)
assert_equal(addr_receiver.addr_messages_received, 1)
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.