mirror of
https://github.com/dashpay/dash.git
synced 2024-12-24 19:42:46 +01:00
merge bitcoin#27986: remove race in the user-agent reception check
This commit is contained in:
parent
1bf135bbc9
commit
fffe6e716b
@ -638,10 +638,13 @@ class TestNode():
|
||||
# in comparison to the upside of making tests less fragile and unexpected intermittent errors less likely.
|
||||
p2p_conn.sync_with_ping()
|
||||
|
||||
# Consistency check that the Dash Core has received our user agent string. This checks the
|
||||
# node's newest peer. It could be racy if another Dash Core node has connected since we opened
|
||||
# our connection, but we don't expect that to happen.
|
||||
assert_equal(self.getpeerinfo()[-1]['subver'], p2p_conn.strSubVer)
|
||||
# Consistency check that the node received our user agent string.
|
||||
# Find our connection in getpeerinfo by our address:port, as it 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]
|
||||
assert_equal(len(info), 1)
|
||||
assert_equal(info[0]["subver"], p2p_conn.strSubVer)
|
||||
|
||||
return p2p_conn
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user