merge bitcoin#27986: remove race in the user-agent reception check

This commit is contained in:
Kittywhiskers Van Gogh 2023-06-28 10:15:41 +02:00
parent 1bf135bbc9
commit fffe6e716b
No known key found for this signature in database
GPG Key ID: 30CD0C065E5C4AAD

View File

@ -638,10 +638,13 @@ class TestNode():
# in comparison to the upside of making tests less fragile and unexpected intermittent errors less likely. # in comparison to the upside of making tests less fragile and unexpected intermittent errors less likely.
p2p_conn.sync_with_ping() p2p_conn.sync_with_ping()
# Consistency check that the Dash Core has received our user agent string. This checks the # Consistency check that the node received our user agent string.
# node's newest peer. It could be racy if another Dash Core node has connected since we opened # Find our connection in getpeerinfo by our address:port, as it is unique.
# our connection, but we don't expect that to happen. sockname = p2p_conn._transport.get_extra_info("socket").getsockname()
assert_equal(self.getpeerinfo()[-1]['subver'], p2p_conn.strSubVer) our_addr_and_port = f"{sockname[0]}:{sockname[1]}"
info = [peer for peer in self.getpeerinfo() if peer["addr"] == our_addr_and_port]
assert_equal(len(info), 1)
assert_equal(info[0]["subver"], p2p_conn.strSubVer)
return p2p_conn return p2p_conn