From cac5b32d883697f218787972afe1a1508e1fc818 Mon Sep 17 00:00:00 2001 From: ziggie Date: Mon, 29 Jul 2024 16:53:41 +0200 Subject: [PATCH] itest: adapt itest for the new anchor behavior. Now we also register anchors when no HTLCs are at stake. --- itest/lnd_sweep_test.go | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/itest/lnd_sweep_test.go b/itest/lnd_sweep_test.go index b95bc0513..5c4e63f3e 100644 --- a/itest/lnd_sweep_test.go +++ b/itest/lnd_sweep_test.go @@ -73,9 +73,11 @@ func testSweepCPFPAnchorOutgoingTimeout(ht *lntest.HarnessTest) { htlcBudget := htlcValue.MulF64(contractcourt.DefaultBudgetRatio) // cpfpBudget is the budget used to sweep the CPFP anchor. + // In addition to the htlc amount to protect we also need to include + // the anchor amount itself for the budget. cpfpBudget := (htlcValue - htlcBudget).MulF64( contractcourt.DefaultBudgetRatio, - ) + ) + contractcourt.AnchorOutputValue // Create a preimage, that will be held by Carol. var preimage lntypes.Preimage @@ -488,9 +490,11 @@ func testSweepCPFPAnchorIncomingTimeout(ht *lntest.HarnessTest) { htlcBudget := htlcValue.MulF64(contractcourt.DefaultBudgetRatio) // cpfpBudget is the budget used to sweep the CPFP anchor. + // In addition to the htlc amount to protect we also need to include + // the anchor amount itself for the budget. cpfpBudget := (htlcValue - htlcBudget).MulF64( contractcourt.DefaultBudgetRatio, - ) + ) + contractcourt.AnchorOutputValue // Carol should have one incoming HTLC on channel Bob -> Carol. ht.AssertIncomingHTLCActive(carol, bcChanPoint, payHash[:]) @@ -1342,9 +1346,13 @@ func testSweepCommitOutputAndAnchor(ht *lntest.HarnessTest) { // PendingChannels RPC under the waiting close section. ht.AssertChannelWaitingClose(alice, chanPoint) - // We should see neither Alice or Bob has any pending sweeps as there - // are no time-sensitive HTLCs. - ht.AssertNumPendingSweeps(alice, 0) + // Alice should see 2 anchor sweeps for the local and remote commitment. + // Even without HTLCs at stake the anchors are registered with the + // sweeper subsytem. + ht.AssertNumPendingSweeps(alice, 2) + + // Bob did not force close the channel therefore he should have no + // pending sweeps. ht.AssertNumPendingSweeps(bob, 0) // Mine a block to confirm Alice's force closing tx. Once it's