Skip to content

Commit

Permalink
test: fix intermittent failure in p2p_getaddr_caching
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mzumsande committed Jul 25, 2023
1 parent d23fda0 commit feb0096
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions test/functional/test_framework/test_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit feb0096

Please sign in to comment.