From acd9419f642a053a53c8a33257512a212e9530a8 Mon Sep 17 00:00:00 2001 From: Dusty Daemon Date: Thu, 15 Feb 2024 15:08:24 -0500 Subject: [PATCH] channeld: Add aggressive restart test --- contrib/pyln-client/pyln/client/lightning.py | 14 +++ tests/test_restart.py | 115 +++++++++++++++++++ 2 files changed, 129 insertions(+) create mode 100644 tests/test_restart.py diff --git a/contrib/pyln-client/pyln/client/lightning.py b/contrib/pyln-client/pyln/client/lightning.py index 3b95adb2596c..e3b2ee8dfaa5 100644 --- a/contrib/pyln-client/pyln/client/lightning.py +++ b/contrib/pyln-client/pyln/client/lightning.py @@ -1156,6 +1156,20 @@ def openchannel_abort(self, channel_id): } return self.call("openchannel_abort", payload) + def stfu_channels(self, channel_ids): + """ STFU multiple channels """ + payload = { + "channel_ids": channel_ids, + } + return self.call("stfu_channels", payload) + + def abort_channels(self, channel_ids): + """ Abort multiple channels """ + payload = { + "channel_ids": channel_ids, + } + return self.call("abort_channels", payload) + def splice_init(self, chan_id, amount, initialpsbt=None, feerate_per_kw=None): """ Initiate a splice """ payload = { diff --git a/tests/test_restart.py b/tests/test_restart.py new file mode 100644 index 000000000000..4c5a83dda2de --- /dev/null +++ b/tests/test_restart.py @@ -0,0 +1,115 @@ +from fixtures import * # noqa: F401,F403 +import pytest +import unittest +from utils import ( + TEST_NETWORK +) + + +@pytest.mark.openchannel('v1') +@pytest.mark.openchannel('v2') +@unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd doesnt yet support PSBT features we need') +def test_agressive_restart(node_factory, bitcoind): + l1, l2 = node_factory.line_graph(2, fundamount=1000000, wait_for_announce=True, opts={'experimental-splicing': None}) + + chan_id = l1.get_channel_id(l2) + + l1.rpc.stfu_channels([chan_id]) + l1.rpc.abort_channels([chan_id]) + l1.daemon.wait_for_log(r'peer_in WIRE_CHANNEL_REESTABLISH') + l2.daemon.wait_for_log(r'peer_in WIRE_CHANNEL_REESTABLISH') + + l1.rpc.stfu_channels([chan_id]) + l1.rpc.abort_channels([chan_id]) + l1.daemon.wait_for_log(r'peer_in WIRE_CHANNEL_REESTABLISH') + l2.daemon.wait_for_log(r'peer_in WIRE_CHANNEL_REESTABLISH') + + l1.rpc.stfu_channels([chan_id]) + l1.rpc.abort_channels([chan_id]) + l1.daemon.wait_for_log(r'peer_in WIRE_CHANNEL_REESTABLISH') + l2.daemon.wait_for_log(r'peer_in WIRE_CHANNEL_REESTABLISH') + + l1.rpc.stfu_channels([chan_id]) + l1.rpc.abort_channels([chan_id]) + l1.daemon.wait_for_log(r'peer_in WIRE_CHANNEL_REESTABLISH') + l2.daemon.wait_for_log(r'peer_in WIRE_CHANNEL_REESTABLISH') + + l1.rpc.stfu_channels([chan_id]) + l1.rpc.abort_channels([chan_id]) + l1.daemon.wait_for_log(r'peer_in WIRE_CHANNEL_REESTABLISH') + l2.daemon.wait_for_log(r'peer_in WIRE_CHANNEL_REESTABLISH') + + l1.rpc.stfu_channels([chan_id]) + l1.rpc.abort_channels([chan_id]) + l1.daemon.wait_for_log(r'peer_in WIRE_CHANNEL_REESTABLISH') + l2.daemon.wait_for_log(r'peer_in WIRE_CHANNEL_REESTABLISH') + + l1.rpc.stfu_channels([chan_id]) + l1.rpc.abort_channels([chan_id]) + l1.daemon.wait_for_log(r'peer_in WIRE_CHANNEL_REESTABLISH') + l2.daemon.wait_for_log(r'peer_in WIRE_CHANNEL_REESTABLISH') + + l1.rpc.stfu_channels([chan_id]) + l1.rpc.abort_channels([chan_id]) + l1.daemon.wait_for_log(r'peer_in WIRE_CHANNEL_REESTABLISH') + l2.daemon.wait_for_log(r'peer_in WIRE_CHANNEL_REESTABLISH') + + l1.rpc.stfu_channels([chan_id]) + l1.rpc.abort_channels([chan_id]) + l1.daemon.wait_for_log(r'peer_in WIRE_CHANNEL_REESTABLISH') + l2.daemon.wait_for_log(r'peer_in WIRE_CHANNEL_REESTABLISH') + + l1.rpc.stfu_channels([chan_id]) + l1.rpc.abort_channels([chan_id]) + l1.daemon.wait_for_log(r'peer_in WIRE_CHANNEL_REESTABLISH') + l2.daemon.wait_for_log(r'peer_in WIRE_CHANNEL_REESTABLISH') + + l1.rpc.stfu_channels([chan_id]) + l1.rpc.abort_channels([chan_id]) + l1.daemon.wait_for_log(r'peer_in WIRE_CHANNEL_REESTABLISH') + l2.daemon.wait_for_log(r'peer_in WIRE_CHANNEL_REESTABLISH') + + l1.rpc.stfu_channels([chan_id]) + l1.rpc.abort_channels([chan_id]) + l1.daemon.wait_for_log(r'peer_in WIRE_CHANNEL_REESTABLISH') + l2.daemon.wait_for_log(r'peer_in WIRE_CHANNEL_REESTABLISH') + + l1.rpc.stfu_channels([chan_id]) + l1.rpc.abort_channels([chan_id]) + l1.daemon.wait_for_log(r'peer_in WIRE_CHANNEL_REESTABLISH') + l2.daemon.wait_for_log(r'peer_in WIRE_CHANNEL_REESTABLISH') + + l1.rpc.stfu_channels([chan_id]) + l1.rpc.abort_channels([chan_id]) + l1.daemon.wait_for_log(r'peer_in WIRE_CHANNEL_REESTABLISH') + l2.daemon.wait_for_log(r'peer_in WIRE_CHANNEL_REESTABLISH') + + l1.rpc.stfu_channels([chan_id]) + l1.rpc.abort_channels([chan_id]) + l1.daemon.wait_for_log(r'peer_in WIRE_CHANNEL_REESTABLISH') + l2.daemon.wait_for_log(r'peer_in WIRE_CHANNEL_REESTABLISH') + + l1.rpc.stfu_channels([chan_id]) + l1.rpc.abort_channels([chan_id]) + l1.daemon.wait_for_log(r'peer_in WIRE_CHANNEL_REESTABLISH') + l2.daemon.wait_for_log(r'peer_in WIRE_CHANNEL_REESTABLISH') + + l1.rpc.stfu_channels([chan_id]) + l1.rpc.abort_channels([chan_id]) + l1.daemon.wait_for_log(r'peer_in WIRE_CHANNEL_REESTABLISH') + l2.daemon.wait_for_log(r'peer_in WIRE_CHANNEL_REESTABLISH') + + l1.rpc.stfu_channels([chan_id]) + l1.rpc.abort_channels([chan_id]) + l1.daemon.wait_for_log(r'peer_in WIRE_CHANNEL_REESTABLISH') + l2.daemon.wait_for_log(r'peer_in WIRE_CHANNEL_REESTABLISH') + + l1.rpc.stfu_channels([chan_id]) + l1.rpc.abort_channels([chan_id]) + l1.daemon.wait_for_log(r'peer_in WIRE_CHANNEL_REESTABLISH') + l2.daemon.wait_for_log(r'peer_in WIRE_CHANNEL_REESTABLISH') + + l1.rpc.stfu_channels([chan_id]) + l1.rpc.abort_channels([chan_id]) + l1.daemon.wait_for_log(r'peer_in WIRE_CHANNEL_REESTABLISH') + l2.daemon.wait_for_log(r'peer_in WIRE_CHANNEL_REESTABLISH')