diff --git a/tests/test_closing.py b/tests/test_closing.py index ea4816556..4483f8162 100644 --- a/tests/test_closing.py +++ b/tests/test_closing.py @@ -1063,6 +1063,7 @@ def test_permfail_htlc_out(node_factory, bitcoind, executor): l2 = node_factory.get_node(disconnect=disconnects) l1.rpc.connect(l2.info['id'], 'localhost', l2.port) + l2.daemon.wait_for_log('openingd-{} chan #1: Handed peer, entering loop'.format(l1.info['id'])) l2.fund_channel(l1, 10**6) # This will fail at l2's end. diff --git a/tests/test_connection.py b/tests/test_connection.py index 49017770c..ee9b58156 100644 --- a/tests/test_connection.py +++ b/tests/test_connection.py @@ -988,15 +988,14 @@ def test_disconnectpeer(node_factory, bitcoind): assert len(l1.rpc.getpeer(l2.info['id'])['channels']) == 0 assert l1.rpc.getpeer(l3.info['id'])['connected'] assert len(l1.rpc.getpeer(l3.info['id'])['channels']) == 0 + wait_for(lambda: l2.rpc.getpeer(l1.info['id']) is not None) # Disconnect l2 from l1 l1.rpc.disconnect(l2.info['id']) - time.sleep(5) - # Make sure listpeers no longer returns the disconnected node assert l1.rpc.getpeer(l2.info['id']) is None - assert l2.rpc.getpeer(l1.info['id']) is None + wait_for(lambda: l2.rpc.getpeer(l1.info['id']) is None) # Make sure you cannot disconnect after disconnecting with pytest.raises(RpcError, match=r'Peer not connected'): diff --git a/tests/test_gossip.py b/tests/test_gossip.py index 8e91719dc..b6bbd763c 100644 --- a/tests/test_gossip.py +++ b/tests/test_gossip.py @@ -348,6 +348,7 @@ def test_gossip_weirdalias(node_factory, bitcoind): .format(normal_name)) l1.rpc.connect(l2.info['id'], 'localhost', l2.port) + l2.daemon.wait_for_log('openingd-{} chan #1: Handed peer, entering loop'.format(l1.info['id'])) l2.fund_channel(l1, 10**6) bitcoind.rpc.generate(6) diff --git a/tests/utils.py b/tests/utils.py index efc7bc892..b93771a2b 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -744,7 +744,11 @@ class NodeFactory(object): for src, dst in connections: src.rpc.connect(dst.info['id'], 'localhost', dst.port) + # If we're returning now, make sure dst all show connections in + # getpeers. if not fundchannel: + for src, dst in connections: + dst.daemon.wait_for_log('openingd-{} chan #[0-9]*: Handed peer, entering loop'.format(src.info['id'])) return nodes # If we got here, we want to fund channels