From e4b205cd90d0058b6d7c17eabca11d2d5cda4660 Mon Sep 17 00:00:00 2001 From: yyforyongyu Date: Sun, 26 Jan 2025 08:50:04 +0800 Subject: [PATCH 1/2] itest: fix flake in `testAnchorThirdPartySpend` When mining lots of blocks in the itest, the subsystems can be out of sync in terms of the best block height. We now assert the num of pending sweeps on Alice's node to give her more time to sync the blocks, essentially behaving like a `time.Sleep` as in reality, the blocks would never be generated this fast. --- itest/lnd_onchain_test.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/itest/lnd_onchain_test.go b/itest/lnd_onchain_test.go index 3a32a8c6a57..9bcf6c1943b 100644 --- a/itest/lnd_onchain_test.go +++ b/itest/lnd_onchain_test.go @@ -564,7 +564,13 @@ func testAnchorThirdPartySpend(ht *lntest.HarnessTest) { // // TODO(yy): also check the restart behavior of Alice. const anchorCsv = 16 - ht.MineEmptyBlocks(anchorCsv - defaultCSV) + blocks := anchorCsv - defaultCSV + + // Mine empty blocks and check Alice still has the two pending sweeps. + for i := 0; i < blocks; i++ { + ht.MineEmptyBlocks(1) + ht.AssertNumPendingSweeps(alice, 2) + } // Now that the channel has been closed, and Alice has an unconfirmed // transaction spending the output produced by her anchor sweep, we'll From bc8c1643c6241ea4017447499665ce9c76de212f Mon Sep 17 00:00:00 2001 From: yyforyongyu Date: Fri, 24 Jan 2025 11:39:14 +0800 Subject: [PATCH 2/2] itest: move channel force closes into one sub test var --- itest/list_exclude_test.go | 4 ++-- itest/list_on_test.go | 15 +++------------ itest/lnd_channel_force_close_test.go | 15 +++++++++++++++ 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/itest/list_exclude_test.go b/itest/list_exclude_test.go index aba4e79b8dd..0f398c208a6 100644 --- a/itest/list_exclude_test.go +++ b/itest/list_exclude_test.go @@ -39,8 +39,8 @@ var excludedTestsWindows = []string{ "multihop-htlc aggregation simple taproot", "multihop-htlc aggregation simple taproot zero conf", - "channel force closure anchor", - "channel force closure simple taproot", + "channel force close-anchor", + "channel force close-simple taproot", "channel backup restore force close", "wipe forwarding packages", diff --git a/itest/list_on_test.go b/itest/list_on_test.go index 38cd56d3503..6de56605bb4 100644 --- a/itest/list_on_test.go +++ b/itest/list_on_test.go @@ -205,18 +205,6 @@ var allTestCases = []*lntest.TestCase{ Name: "channel unsettled balance", TestFunc: testChannelUnsettledBalance, }, - { - Name: "channel force closure anchor", - TestFunc: testChannelForceClosureAnchor, - }, - { - Name: "channel force closure simple taproot", - TestFunc: testChannelForceClosureSimpleTaproot, - }, - { - Name: "failing channel", - TestFunc: testFailingChannel, - }, { Name: "chain kit", TestFunc: testChainKit, @@ -736,6 +724,9 @@ func init() { allTestCases = appendPrefixed( "send to route", allTestCases, sendToRouteTestCases, ) + allTestCases = appendPrefixed( + "channel force close", allTestCases, channelForceCloseTestCases, + ) // Prepare the test cases for windows to exclude some of the flaky // ones. diff --git a/itest/lnd_channel_force_close_test.go b/itest/lnd_channel_force_close_test.go index 4252f48fbd2..6fcd8dd86b7 100644 --- a/itest/lnd_channel_force_close_test.go +++ b/itest/lnd_channel_force_close_test.go @@ -18,6 +18,21 @@ import ( "github.com/stretchr/testify/require" ) +var channelForceCloseTestCases = []*lntest.TestCase{ + { + Name: "anchor", + TestFunc: testChannelForceClosureAnchor, + }, + { + Name: "simple taproot", + TestFunc: testChannelForceClosureSimpleTaproot, + }, + { + Name: "wrong preimage", + TestFunc: testFailingChannel, + }, +} + const pushAmt = btcutil.Amount(5e5) // testChannelForceClosureAnchor runs `runChannelForceClosureTest` with anchor