mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-04-07 22:28:02 +02:00
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:
@@ -402,8 +402,7 @@ class AddrTest(BitcoinTestFramework):
|
|||||||
def get_nodes_that_received_addr(self, peer, receiver_peer, addr_receivers,
|
def get_nodes_that_received_addr(self, peer, receiver_peer, addr_receivers,
|
||||||
time_interval_1, time_interval_2):
|
time_interval_1, time_interval_2):
|
||||||
|
|
||||||
# Clean addr response related to the initial getaddr. There is no way to avoid initial
|
# Clean addr response related to the initial getaddr.
|
||||||
# getaddr because the peer won't self-announce then.
|
|
||||||
for addr_receiver in addr_receivers:
|
for addr_receiver in addr_receivers:
|
||||||
addr_receiver.num_ipv4_received = 0
|
addr_receiver.num_ipv4_received = 0
|
||||||
|
|
||||||
|
|||||||
@@ -78,14 +78,16 @@ class AddrSelfAnnouncementTest(BitcoinTestFramework):
|
|||||||
self.self_announcement_test(outbound=True, addrv2=False)
|
self.self_announcement_test(outbound=True, addrv2=False)
|
||||||
self.self_announcement_test(outbound=True, addrv2=True)
|
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
|
# In response to a GETADDR, we expect a message with the self-announcement
|
||||||
# and an addr message containing the GETADDR response.
|
# and an addr message containing the GETADDR response.
|
||||||
assert_equal(addr_receiver.self_announcements_received, 1)
|
assert_equal(addr_receiver.self_announcements_received, 1)
|
||||||
assert_equal(addr_receiver.addr_messages_received, 2)
|
assert_equal(addr_receiver.addr_messages_received, 2)
|
||||||
assert_greater_than(addr_receiver.addresses_received, 1)
|
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.
|
# We expect only the self-announcement.
|
||||||
assert_equal(addr_receiver.self_announcements_received, 1)
|
assert_equal(addr_receiver.self_announcements_received, 1)
|
||||||
assert_equal(addr_receiver.addr_messages_received, 1)
|
assert_equal(addr_receiver.addr_messages_received, 1)
|
||||||
|
|||||||
Reference in New Issue
Block a user