aboutsummaryrefslogtreecommitdiff
path: root/test/functional/test_framework
diff options
context:
space:
mode:
authorBen Woosley <ben.woosley@gmail.com>2018-02-26 14:04:41 -0800
committerMarcoFalke <falke.marco@gmail.com>2018-04-20 18:38:41 -0400
commit0e98f96e42357ac24322a96f0864b6bfd5e55ffe (patch)
tree85d621fbcac468ff527bf3fb2fc1834bc5b680ed /test/functional/test_framework
parent1286f3e49a7bdae72ae022ff4f83d0a77e832891 (diff)
test: Use wait_until in tests where time was used for polling
Github-Pull: #12553 Rebased-From: 81b0822772169cb697b5994f49398e619d61a12d
Diffstat (limited to 'test/functional/test_framework')
-rw-r--r--test/functional/test_framework/util.py11
1 files changed, 3 insertions, 8 deletions
diff --git a/test/functional/test_framework/util.py b/test/functional/test_framework/util.py
index 644f2d868a..db259db8eb 100644
--- a/test/functional/test_framework/util.py
+++ b/test/functional/test_framework/util.py
@@ -334,20 +334,15 @@ def disconnect_nodes(from_connection, node_num):
for peer_id in [peer['id'] for peer in from_connection.getpeerinfo() if "testnode%d" % node_num in peer['subver']]:
from_connection.disconnectnode(nodeid=peer_id)
- for _ in range(50):
- if [peer['id'] for peer in from_connection.getpeerinfo() if "testnode%d" % node_num in peer['subver']] == []:
- break
- time.sleep(0.1)
- else:
- raise AssertionError("timed out waiting for disconnect")
+ # wait to disconnect
+ wait_until(lambda: [peer['id'] for peer in from_connection.getpeerinfo() if "testnode%d" % node_num in peer['subver']] == [], timeout=5)
def connect_nodes(from_connection, node_num):
ip_port = "127.0.0.1:" + str(p2p_port(node_num))
from_connection.addnode(ip_port, "onetry")
# poll until version handshake complete to avoid race conditions
# with transaction relaying
- while any(peer['version'] == 0 for peer in from_connection.getpeerinfo()):
- time.sleep(0.1)
+ wait_until(lambda: all(peer['version'] != 0 for peer in from_connection.getpeerinfo()))
def connect_nodes_bi(nodes, a, b):
connect_nodes(nodes[a], b)