mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-27 03:33:27 -03:00
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.
This commit is contained in:
parent
d23fda0584
commit
feb0096139
1 changed files with 3 additions and 2 deletions
|
@ -645,10 +645,11 @@ class TestNode():
|
||||||
p2p_conn.sync_with_ping()
|
p2p_conn.sync_with_ping()
|
||||||
|
|
||||||
# Consistency check that the node received our user agent string.
|
# 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()
|
sockname = p2p_conn._transport.get_extra_info("socket").getsockname()
|
||||||
our_addr_and_port = f"{sockname[0]}:{sockname[1]}"
|
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(len(info), 1)
|
||||||
assert_equal(info[0]["subver"], P2P_SUBVERSION)
|
assert_equal(info[0]["subver"], P2P_SUBVERSION)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue