Skip to content

Commit

Permalink
pytest: fix instant disconnection assumption in test_funding_external…
Browse files Browse the repository at this point in the history
…_wallet_corners

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
  • Loading branch information
rustyrussell committed Jul 14, 2022
1 parent 8df2a48 commit b4de3fd
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tests/test_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand All @@ -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}])
Expand All @@ -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)
Expand All @@ -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}])
Expand Down

0 comments on commit b4de3fd

Please sign in to comment.