diff --git a/tests/test_connection.py b/tests/test_connection.py index 8d040e293..c682dfdca 100644 --- a/tests/test_connection.py +++ b/tests/test_connection.py @@ -764,10 +764,10 @@ def test_channel_persistence(node_factory, bitcoind, executor): wait_for(lambda: len(l2.rpc.listpeers()['peers']) == 1) # Wait for the restored HTLC to finish - wait_for(lambda: only_one(l1.rpc.listpeers()['peers'][0]['channels'])['msatoshi_to_us'] == 99990000, interval=1) + wait_for(lambda: only_one(l1.rpc.listpeers()['peers'][0]['channels'])['msatoshi_to_us'] == 99990000) - wait_for(lambda: len([p for p in l1.rpc.listpeers()['peers'] if p['connected']]), interval=1) - wait_for(lambda: len([p for p in l2.rpc.listpeers()['peers'] if p['connected']]), interval=1) + wait_for(lambda: len([p for p in l1.rpc.listpeers()['peers'] if p['connected']])) + wait_for(lambda: len([p for p in l2.rpc.listpeers()['peers'] if p['connected']])) # Now make sure this is really functional by sending a payment l1.pay(l2, 10000) diff --git a/tests/test_gossip.py b/tests/test_gossip.py index 654e685e6..72d96fadc 100644 --- a/tests/test_gossip.py +++ b/tests/test_gossip.py @@ -543,7 +543,7 @@ def test_routing_gossip(node_factory, bitcoind): return len(missing) == 0 for n in nodes: - wait_for(lambda: check_gossip(n), interval=1) + wait_for(lambda: check_gossip(n)) @unittest.skipIf(not DEVELOPER, "needs DEVELOPER=1") diff --git a/tests/utils.py b/tests/utils.py index f4437e80d..3fd409a95 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -39,10 +39,14 @@ TIMEOUT = int(os.getenv("TIMEOUT", "60")) VALGRIND = os.getenv("VALGRIND", config['VALGRIND']) == "1" -def wait_for(success, timeout=TIMEOUT, interval=0.1): +def wait_for(success, timeout=TIMEOUT): start_time = time.time() + interval = 0.25 while not success() and time.time() < start_time + timeout: time.sleep(interval) + interval *= 2 + if interval > 5: + interval = 5 if time.time() > start_time + timeout: raise ValueError("Error waiting for {}", success) @@ -570,7 +574,7 @@ class LightningNode(object): wait_for(lambda: txid in self.bitcoin.rpc.getrawmempool()) def wait_channel_active(self, chanid): - wait_for(lambda: self.is_channel_active(chanid), interval=1) + wait_for(lambda: self.is_channel_active(chanid)) # This waits until gossipd sees channel_update in both directions # (or for local channels, at least a local announcement)