From 8b95b2127de767661ad2bac16afcf4c067a7dd54 Mon Sep 17 00:00:00 2001 From: ThomasV Date: Mon, 29 Mar 2021 19:08:22 +0200 Subject: [PATCH] regtest backups: test both cases (onchain and imported) lnpeer: call close_and_cleanup() after we force close, or the above test will fail. --- electrum/lnpeer.py | 1 + electrum/tests/regtest/regtest.sh | 14 ++++++-------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/electrum/lnpeer.py b/electrum/lnpeer.py index d0d3c4244..33d6eb926 100644 --- a/electrum/lnpeer.py +++ b/electrum/lnpeer.py @@ -1081,6 +1081,7 @@ class Peer(Logger): elif we_are_ahead: self.logger.warning(f"channel_reestablish ({chan.get_id_for_log()}): we are ahead of remote! trying to force-close.") await self.lnworker.try_force_closing(chan_id) + self.close_and_cleanup() return chan.peer_state = PeerState.GOOD diff --git a/electrum/tests/regtest/regtest.sh b/electrum/tests/regtest/regtest.sh index d2517e168..5b431f865 100755 --- a/electrum/tests/regtest/regtest.sh +++ b/electrum/tests/regtest/regtest.sh @@ -137,15 +137,12 @@ if [[ $1 == "backup" ]]; then wait_for_balance alice 1 echo "alice opens channel" bob_node=$($bob nodeid) + channel1=$($alice open_channel $bob_node 0.15) $alice setconfig use_recoverable_channels False - channel=$($alice open_channel $bob_node 0.15) - echo "channel point: $channel" + channel2=$($alice open_channel $bob_node 0.15) new_blocks 3 wait_until_channel_open alice - backup=$($alice export_channel_backup $channel) - request=$($bob add_lightning_request 0.01 -m "blah" | jq -r ".invoice") - echo "alice pays" - $alice lnpay $request + backup=$($alice export_channel_backup $channel2) seed=$($alice getseed) $alice stop mv /tmp/alice/regtest/wallets/default_wallet /tmp/alice/regtest/wallets/default_wallet.old @@ -153,8 +150,9 @@ if [[ $1 == "backup" ]]; then $alice daemon -d $alice load_wallet $alice import_channel_backup $backup - $alice request_force_close $channel - wait_for_balance alice 0.989 + $alice request_force_close $channel1 + $alice request_force_close $channel2 + wait_for_balance alice 0.998 fi