From feb0096139e9e864632d2826d2e213b26146fff1 Mon Sep 17 00:00:00 2001 From: Martin Zumsande Date: Mon, 24 Jul 2023 20:31:00 -0400 Subject: [PATCH] test: fix intermittent failure in p2p_getaddr_caching Only the combined addr:port of source and destination must be unique. If the destination is different, the same addr:port for the source may be used by the OS. --- test/functional/test_framework/test_node.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/functional/test_framework/test_node.py b/test/functional/test_framework/test_node.py index 1fcef6ce1c83e..f01440146b5a9 100755 --- a/test/functional/test_framework/test_node.py +++ b/test/functional/test_framework/test_node.py @@ -645,10 +645,11 @@ def add_p2p_connection(self, p2p_conn, *, wait_for_verack=True, **kwargs): 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)