diff options
-rwxr-xr-x | test/functional/p2p_getaddr_caching.py | 9 | ||||
-rwxr-xr-x | test/functional/test_framework/test_node.py | 5 |
2 files changed, 5 insertions, 9 deletions
diff --git a/test/functional/p2p_getaddr_caching.py b/test/functional/p2p_getaddr_caching.py index 1c9ad7289b..60b43c32ae 100755 --- a/test/functional/p2p_getaddr_caching.py +++ b/test/functional/p2p_getaddr_caching.py @@ -6,7 +6,6 @@ import time -from test_framework.messages import msg_getaddr from test_framework.p2p import ( P2PInterface, p2p_lock @@ -21,6 +20,7 @@ from test_framework.util import ( MAX_ADDR_TO_SEND = 1000 MAX_PCT_ADDR_TO_SEND = 23 + class AddrReceiver(P2PInterface): def __init__(self): @@ -70,11 +70,8 @@ class AddrTest(BitcoinTestFramework): cur_mock_time = int(time.time()) for i in range(N): addr_receiver_local = self.nodes[0].add_p2p_connection(AddrReceiver()) - addr_receiver_local.send_and_ping(msg_getaddr()) addr_receiver_onion1 = self.nodes[0].add_p2p_connection(AddrReceiver(), dstport=self.onion_port1) - addr_receiver_onion1.send_and_ping(msg_getaddr()) addr_receiver_onion2 = self.nodes[0].add_p2p_connection(AddrReceiver(), dstport=self.onion_port2) - addr_receiver_onion2.send_and_ping(msg_getaddr()) # Trigger response cur_mock_time += 5 * 60 @@ -105,11 +102,8 @@ class AddrTest(BitcoinTestFramework): self.log.info('After time passed, see a new response to addr request') addr_receiver_local = self.nodes[0].add_p2p_connection(AddrReceiver()) - addr_receiver_local.send_and_ping(msg_getaddr()) addr_receiver_onion1 = self.nodes[0].add_p2p_connection(AddrReceiver(), dstport=self.onion_port1) - addr_receiver_onion1.send_and_ping(msg_getaddr()) addr_receiver_onion2 = self.nodes[0].add_p2p_connection(AddrReceiver(), dstport=self.onion_port2) - addr_receiver_onion2.send_and_ping(msg_getaddr()) # Trigger response cur_mock_time += 5 * 60 @@ -123,5 +117,6 @@ class AddrTest(BitcoinTestFramework): assert set(last_response_on_onion_bind1) != set(addr_receiver_onion1.get_received_addrs()) assert set(last_response_on_onion_bind2) != set(addr_receiver_onion2.get_received_addrs()) + if __name__ == '__main__': AddrTest().main() diff --git a/test/functional/test_framework/test_node.py b/test/functional/test_framework/test_node.py index 2fc3da55fa..544a81602e 100755 --- a/test/functional/test_framework/test_node.py +++ b/test/functional/test_framework/test_node.py @@ -649,10 +649,11 @@ class TestNode(): p2p_conn.sync_with_ping() # Consistency check that the node received our user agent string. - # Find our connection in getpeerinfo by our address:port, as it is unique. + # Find our connection in getpeerinfo by our address:port and theirs, as this combination is unique. sockname = p2p_conn._transport.get_extra_info("socket").getsockname() our_addr_and_port = f"{sockname[0]}:{sockname[1]}" - info = [peer for peer in self.getpeerinfo() if peer["addr"] == our_addr_and_port] + dst_addr_and_port = f"{p2p_conn.dstaddr}:{p2p_conn.dstport}" + info = [peer for peer in self.getpeerinfo() if peer["addr"] == our_addr_and_port and peer["addrbind"] == dst_addr_and_port] assert_equal(len(info), 1) assert_equal(info[0]["subver"], P2P_SUBVERSION) |