From 57bfa864fe69ea5610399f9db60cf2299930703a Mon Sep 17 00:00:00 2001 From: stratospher <44024636+stratospher@users.noreply.github.com> Date: Fri, 6 Mar 2026 10:43:49 +0530 Subject: [PATCH] test: use static methods and clarify comment in addr_relay we don't need to send GETADDR for initial self announcement anymore + can construct addr_receivers using AddrReceiver(send_getaddr=False). however we would need to send an empty ADDR message to each of the addr_receivers to initialise addr relay for inbound connections. so current code is simpler and we can just clarify the comment. --- test/functional/p2p_addr_relay.py | 3 +-- test/functional/p2p_addr_selfannouncement.py | 6 ++++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/test/functional/p2p_addr_relay.py b/test/functional/p2p_addr_relay.py index eea8ee5351c..65b21c0d505 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 8ab75aaa068..631ecb4c00e 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)