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.
This commit is contained in:
stratospher 2026-03-06 10:43:49 +05:30
parent 7ee8c0abc6
commit 57bfa864fe
2 changed files with 5 additions and 4 deletions

View File

@ -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

View File

@ -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)