Skip to content

Commit cac5b32

Browse files
committed
itest: adapt itest for the new anchor behavior.
Now we also register anchors when no HTLCs are at stake.
1 parent e413759 commit cac5b32

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

itest/lnd_sweep_test.go

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,11 @@ func testSweepCPFPAnchorOutgoingTimeout(ht *lntest.HarnessTest) {
7373
htlcBudget := htlcValue.MulF64(contractcourt.DefaultBudgetRatio)
7474

7575
// cpfpBudget is the budget used to sweep the CPFP anchor.
76+
// In addition to the htlc amount to protect we also need to include
77+
// the anchor amount itself for the budget.
7678
cpfpBudget := (htlcValue - htlcBudget).MulF64(
7779
contractcourt.DefaultBudgetRatio,
78-
)
80+
) + contractcourt.AnchorOutputValue
7981

8082
// Create a preimage, that will be held by Carol.
8183
var preimage lntypes.Preimage
@@ -488,9 +490,11 @@ func testSweepCPFPAnchorIncomingTimeout(ht *lntest.HarnessTest) {
488490
htlcBudget := htlcValue.MulF64(contractcourt.DefaultBudgetRatio)
489491

490492
// cpfpBudget is the budget used to sweep the CPFP anchor.
493+
// In addition to the htlc amount to protect we also need to include
494+
// the anchor amount itself for the budget.
491495
cpfpBudget := (htlcValue - htlcBudget).MulF64(
492496
contractcourt.DefaultBudgetRatio,
493-
)
497+
) + contractcourt.AnchorOutputValue
494498

495499
// Carol should have one incoming HTLC on channel Bob -> Carol.
496500
ht.AssertIncomingHTLCActive(carol, bcChanPoint, payHash[:])
@@ -1342,9 +1346,13 @@ func testSweepCommitOutputAndAnchor(ht *lntest.HarnessTest) {
13421346
// PendingChannels RPC under the waiting close section.
13431347
ht.AssertChannelWaitingClose(alice, chanPoint)
13441348

1345-
// We should see neither Alice or Bob has any pending sweeps as there
1346-
// are no time-sensitive HTLCs.
1347-
ht.AssertNumPendingSweeps(alice, 0)
1349+
// Alice should see 2 anchor sweeps for the local and remote commitment.
1350+
// Even without HTLCs at stake the anchors are registered with the
1351+
// sweeper subsytem.
1352+
ht.AssertNumPendingSweeps(alice, 2)
1353+
1354+
// Bob did not force close the channel therefore he should have no
1355+
// pending sweeps.
13481356
ht.AssertNumPendingSweeps(bob, 0)
13491357

13501358
// Mine a block to confirm Alice's force closing tx. Once it's

0 commit comments

Comments
 (0)