aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorglozow <gloriajzhao@gmail.com>2022-09-28 16:20:46 +0100
committerglozow <gloriajzhao@gmail.com>2022-09-28 16:21:19 +0100
commitb2da6dd943292b9e08e95fc81577b9fc99d16134 (patch)
tree3a96dbe844437ec2de0d69bc4adfa7a6acac8ab4
parent9fcdb9f3a044330d3d7515fa35709102c98534d2 (diff)
parentfaeea28753a94c45618c1b0ba83bb8700c53009a (diff)
Merge bitcoin/bitcoin#26138: test: Avoid race in disconnect_nodes helper
faeea28753a94c45618c1b0ba83bb8700c53009a test: Avoid race in disconnect_nodes helper (MacroFake) Pull request description: Also wait for the other node to notice the closed socket. Otherwise, the other node is not able to use the connect helper. Fixes https://github.com/bitcoin/bitcoin/issues/26014 ACKs for top commit: stickies-v: ACK faeea2875 glozow: ACK faeea28753a94c45618c1b0ba83bb8700c53009a Tree-SHA512: 2f0fa6812c0519aba3eaf21f0c70073b768fcd4dad23989d57e138ee9057a7da1a6b281645e9bff4051259cdca51568700e066491ac6b6daae99f30e395159ca
-rwxr-xr-xtest/functional/test_framework/test_framework.py17
1 files changed, 9 insertions, 8 deletions
diff --git a/test/functional/test_framework/test_framework.py b/test/functional/test_framework/test_framework.py
index c880aabd21..b1164b98fd 100755
--- a/test/functional/test_framework/test_framework.py
+++ b/test/functional/test_framework/test_framework.py
@@ -596,24 +596,24 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
self.wait_until(lambda: sum(peer['bytesrecv_per_msg'].pop('verack', 0) == 24 for peer in to_connection.getpeerinfo()) == to_num_peers)
def disconnect_nodes(self, a, b):
- def disconnect_nodes_helper(from_connection, node_num):
- def get_peer_ids():
+ def disconnect_nodes_helper(node_a, node_b):
+ def get_peer_ids(from_connection, node_num):
result = []
for peer in from_connection.getpeerinfo():
if "testnode{}".format(node_num) in peer['subver']:
result.append(peer['id'])
return result
- peer_ids = get_peer_ids()
+ peer_ids = get_peer_ids(node_a, node_b.index)
if not peer_ids:
self.log.warning("disconnect_nodes: {} and {} were not connected".format(
- from_connection.index,
- node_num,
+ node_a.index,
+ node_b.index,
))
return
for peer_id in peer_ids:
try:
- from_connection.disconnectnode(nodeid=peer_id)
+ node_a.disconnectnode(nodeid=peer_id)
except JSONRPCException as e:
# If this node is disconnected between calculating the peer id
# and issuing the disconnect, don't worry about it.
@@ -622,9 +622,10 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
raise
# wait to disconnect
- self.wait_until(lambda: not get_peer_ids(), timeout=5)
+ self.wait_until(lambda: not get_peer_ids(node_a, node_b.index), timeout=5)
+ self.wait_until(lambda: not get_peer_ids(node_b, node_a.index), timeout=5)
- disconnect_nodes_helper(self.nodes[a], b)
+ disconnect_nodes_helper(self.nodes[a], self.nodes[b])
def split_network(self):
"""