test: Use wait_until in tests where time was used for polling

This commit is contained in:
Ben Woosley committed 2018-03-15 23:43:53 -07:00
1 parent 7be9a9a570
commit 81b0822772
5 files changed
+13 -34

No files matched your search

+2 -8
View File
@@ -7,8 +7,6 @@
Tests correspond to code in rpc/net.cpp.
"""
import time
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
assert_equal,
@@ -62,12 +60,8 @@ class NetTest(BitcoinTestFramework):
self.nodes[0].setnetworkactive(False)
assert_equal(self.nodes[0].getnetworkinfo()['networkactive'], False)
timeout = 3
while self.nodes[0].getnetworkinfo()['connections'] != 0:
# Wait a bit for all sockets to close
assert timeout > 0, 'not all connections closed in time'
timeout -= 0.1
time.sleep(0.1)
# Wait a bit for all sockets to close
wait_until(lambda: self.nodes[0].getnetworkinfo()['connections'] == 0, timeout=3)
self.nodes[0].setnetworkactive(True)
connect_nodes_bi(self.nodes, 0, 1)