Skip to content

Commit feb0096

Browse files
committed
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.
1 parent d23fda0 commit feb0096

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

test/functional/test_framework/test_node.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -645,10 +645,11 @@ def add_p2p_connection(self, p2p_conn, *, wait_for_verack=True, **kwargs):
645645
p2p_conn.sync_with_ping()
646646

647647
# Consistency check that the node received our user agent string.
648-
# Find our connection in getpeerinfo by our address:port, as it is unique.
648+
# Find our connection in getpeerinfo by our address:port and theirs, as this combination is unique.
649649
sockname = p2p_conn._transport.get_extra_info("socket").getsockname()
650650
our_addr_and_port = f"{sockname[0]}:{sockname[1]}"
651-
info = [peer for peer in self.getpeerinfo() if peer["addr"] == our_addr_and_port]
651+
dst_addr_and_port = f"{p2p_conn.dstaddr}:{p2p_conn.dstport}"
652+
info = [peer for peer in self.getpeerinfo() if peer["addr"] == our_addr_and_port and peer["addrbind"] == dst_addr_and_port]
652653
assert_equal(len(info), 1)
653654
assert_equal(info[0]["subver"], P2P_SUBVERSION)
654655

0 commit comments

Comments
 (0)