diff --git a/tests/test_connection.py b/tests/test_connection.py index d145bc1b8cb7..782e2809a793 100644 --- a/tests/test_connection.py +++ b/tests/test_connection.py @@ -1265,6 +1265,7 @@ def test_funding_external_wallet_corners(node_factory, bitcoind): l1.rpc.fundchannel_cancel(l2.info['id']) # Cancelling causes disconnection. + wait_for(lambda: l1.rpc.listpeers(l2.info['id'])['peers'] == []) l1.rpc.connect(l2.info['id'], 'localhost', l2.port) amount2 = 1000000 funding_addr = l1.rpc.fundchannel_start(l2.info['id'], amount2)['funding_address'] @@ -1286,6 +1287,7 @@ def test_funding_external_wallet_corners(node_factory, bitcoind): # But must unreserve inputs manually. l1.rpc.txdiscard(prep['txid']) + wait_for(lambda: l1.rpc.listpeers(l2.info['id'])['peers'] == []) l1.rpc.connect(l2.info['id'], 'localhost', l2.port) funding_addr = l1.rpc.fundchannel_start(l2.info['id'], amount)['funding_address'] prep = l1.rpc.txprepare([{funding_addr: amount}]) @@ -1307,6 +1309,7 @@ def test_funding_external_wallet_corners(node_factory, bitcoind): == 'CHANNELD_AWAITING_LOCKIN') # on reconnect, channel should get destroyed + wait_for(lambda: l1.rpc.listpeers(l2.info['id'])['peers'] == []) l1.rpc.connect(l2.info['id'], 'localhost', l2.port) l1.daemon.wait_for_log('Unknown channel .* for WIRE_CHANNEL_REESTABLISH') wait_for(lambda: len(l1.rpc.listpeers()['peers']) == 0) @@ -1316,6 +1319,7 @@ def test_funding_external_wallet_corners(node_factory, bitcoind): l1.rpc.txdiscard(prep['txid']) # we have to connect again, because we got disconnected when everything errored + wait_for(lambda: l1.rpc.listpeers(l2.info['id'])['peers'] == []) l1.rpc.connect(l2.info['id'], 'localhost', l2.port) funding_addr = l1.rpc.fundchannel_start(l2.info['id'], amount)['funding_address'] prep = l1.rpc.txprepare([{funding_addr: amount}])