mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-04 18:22:57 +02:00
test: Fix all races after a socket is closed gracefully
This waits for any disconnect (e.g. from a restart of one of the nodes)
to fully happen before the next connect.
Can be reviewed with the git option:
--color-moved=dimmed-zebra
Github-Pull: #34425
Rebased-From: fab2772647
This commit is contained in:
@@ -558,6 +558,17 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
|
||||
"""
|
||||
from_connection = self.nodes[a]
|
||||
to_connection = self.nodes[b]
|
||||
|
||||
# Use subversion as peer id. Test nodes have their node number appended to the user agent string
|
||||
from_connection_subver = from_connection.getnetworkinfo()['subversion']
|
||||
to_connection_subver = to_connection.getnetworkinfo()['subversion']
|
||||
|
||||
def find_conn(node, peer_subversion, inbound):
|
||||
return next(filter(lambda peer: peer['subver'] == peer_subversion and peer['inbound'] == inbound, node.getpeerinfo()), None)
|
||||
|
||||
self.wait_until(lambda: not find_conn(from_connection, to_connection_subver, inbound=False))
|
||||
self.wait_until(lambda: not find_conn(to_connection, from_connection_subver, inbound=True))
|
||||
|
||||
ip_port = "127.0.0.1:" + str(p2p_port(b))
|
||||
|
||||
if peer_advertises_v2 is None:
|
||||
@@ -573,13 +584,6 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
|
||||
if not wait_for_connect:
|
||||
return
|
||||
|
||||
# Use subversion as peer id. Test nodes have their node number appended to the user agent string
|
||||
from_connection_subver = from_connection.getnetworkinfo()['subversion']
|
||||
to_connection_subver = to_connection.getnetworkinfo()['subversion']
|
||||
|
||||
def find_conn(node, peer_subversion, inbound):
|
||||
return next(filter(lambda peer: peer['subver'] == peer_subversion and peer['inbound'] == inbound, node.getpeerinfo()), None)
|
||||
|
||||
self.wait_until(lambda: find_conn(from_connection, to_connection_subver, inbound=False) is not None)
|
||||
self.wait_until(lambda: find_conn(to_connection, from_connection_subver, inbound=True) is not None)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user