aboutsummaryrefslogtreecommitdiff
path: root/test/functional/test_framework
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2018-03-19 17:10:29 +0100
committerWladimir J. van der Laan <laanwj@gmail.com>2018-03-19 17:13:51 +0100
commit93634f296e0b2281b25fdbbd5e608b2f5e662ea3 (patch)
tree4d467384afc67eb9b382b6419d33128f08cf1bdf /test/functional/test_framework
parentc39dd2ef59c986576726cc356a27165486fd0d65 (diff)
parent9d7f839a206b7392aebfa436ae0f9a29d33d2960 (diff)
downloadbitcoin-93634f296e0b2281b25fdbbd5e608b2f5e662ea3.tar.xz
Merge #12553: Prefer wait_until over polling with time.sleep
9d7f839a2 test: Use os.path.join consistently in feature_pruning tests (Ben Woosley) 81b082277 test: Use wait_until in tests where time was used for polling (Ben Woosley) Pull request description: This is prompted by and builds on #12545, a nice cleanup / consolidation of patterns. In cases where the exception message was meaningful, I tried to represent it as well in a comment. I expect #12545 will go in first, but I'm happy to squash them if that's preferred. Tree-SHA512: 7a861244001c87fd6b59b6bc248ee741ac8178f7255d6f1fda39bc693c5ff3b7de5f53d13afe9829aef6ea69153481edb0a9d5bc07c36c4f66b4315edd180bb4
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 7be695550b..68ac97d755 100644
--- a/test/functional/test_framework/util.py
+++ b/test/functional/test_framework/util.py
@@ -340,20 +340,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)