@@ -1212,8 +1212,8 @@ func testSweepHTLCs(ht *lntest.HarnessTest) {
12121212// 4. Alice force closes the channel.
12131213//
12141214// Test:
1215- // 1. Alice's anchor sweeping is not attempted, instead, it should be swept
1216- // together with her to_local output using the no deadline path.
1215+ // 1. Alice's CPFP- anchor sweeping is not attempted, instead, it should be
1216+ // swept using the no deadline path and failed due it's not economical .
12171217// 2. Bob would also sweep his anchor and to_local outputs separately due to
12181218// they have different deadline heights, which means only the to_local
12191219// sweeping tx will succeed as the anchor sweeping is not economical.
@@ -1229,10 +1229,15 @@ func testSweepCommitOutputAndAnchor(ht *lntest.HarnessTest) {
12291229 // config.
12301230 deadline := uint32 (1000 )
12311231
1232- // deadlineA is the deadline used for Alice, since her commit output is
1233- // offered to the sweeper at CSV-1. With a deadline of 1000, her actual
1234- // width of her fee func is CSV+1000-1. Given we are using a CSV of 2
1235- // here, her fee func deadline then becomes 1001.
1232+ // deadlineA is the deadline used for Alice, given that,
1233+ // - the force close tx is broadcast at height 445, her inputs are
1234+ // registered at the same height, so her to_local and anchor outputs
1235+ // have a deadline height of 1445.
1236+ // - the force close tx is mined at 446, which means her anchor output
1237+ // now has a deadline delta of (1445-446) = 999 blocks.
1238+ // - for her to_local output, with a deadline of 1000, the width of the
1239+ // fee func is CSV+1000-1. Given we are using a CSV of 2 here, her fee
1240+ // func deadline then becomes 1001.
12361241 deadlineA := deadline + 1
12371242
12381243 // deadlineB is the deadline used for Bob, the actual deadline used by
@@ -1255,6 +1260,11 @@ func testSweepCommitOutputAndAnchor(ht *lntest.HarnessTest) {
12551260 // conf target is the deadline.
12561261 ht .SetFeeEstimateWithConf (startFeeRate , deadlineB )
12571262
1263+ // Set up the starting fee for Alice's anchor sweeping. With this low
1264+ // fee rate, her anchor sweeping should be attempted and failed due to
1265+ // dust output generated in the sweeping tx.
1266+ ht .SetFeeEstimateWithConf (startFeeRate , deadline - 1 )
1267+
12581268 // toLocalCSV is the CSV delay for Alice's to_local output. We use a
12591269 // small value to save us from mining blocks.
12601270 //
@@ -1415,10 +1425,10 @@ func testSweepCommitOutputAndAnchor(ht *lntest.HarnessTest) {
14151425 // With Alice's starting fee rate being validated, we now calculate her
14161426 // ending fee rate and fee rate delta.
14171427 //
1418- // Alice sweeps two inputs - anchor and commit , so the starting budget
1419- // should come from the sum of these two . However, due to the value
1420- // being too large, the actual ending fee rate used should be the
1421- // sweeper's max fee rate configured.
1428+ // Alice sweeps the to_local input , so the starting budget should come
1429+ // from the to_local balance . However, due to the value being too large,
1430+ // the actual ending fee rate used should be the sweeper's max fee rate
1431+ // configured.
14221432 aliceTxWeight := uint64 (ht .CalculateTxWeight (aliceSweepTx ))
14231433 aliceEndingFeeRate := sweep .DefaultMaxFeeRate .FeePerKWeight ()
14241434 aliceFeeRateDelta := (aliceEndingFeeRate - aliceStartingFeeRate ) /
@@ -1495,10 +1505,10 @@ func testSweepCommitOutputAndAnchor(ht *lntest.HarnessTest) {
14951505 }
14961506
14971507 // We should see two txns in the mempool:
1498- // - Alice's sweeping tx, which sweeps both her anchor and
1499- // commit outputs, using the increased fee rate.
1500- // - Bob's previous sweeping tx, which sweeps both his anchor
1501- // and commit outputs, at the possible increased fee rate.
1508+ // - Alice's sweeping tx, which sweeps her commit output, using
1509+ // the increased fee rate.
1510+ // - Bob's previous sweeping tx, which sweeps his commit output,
1511+ // at the possible increased fee rate.
15021512 txns := ht .GetNumTxsFromMempool (2 )
15031513
15041514 // Assume the first tx is Alice's sweeping tx, if the second tx
@@ -1565,6 +1575,11 @@ func testSweepCommitOutputAndAnchor(ht *lntest.HarnessTest) {
15651575 // Mine a block to confirm both sweeping txns, this is needed to clean
15661576 // up the mempool.
15671577 ht .MineBlocksAndAssertNumTxes (1 , 2 )
1578+
1579+ // Finally, assert that both Alice and Bob still have the anchor
1580+ // outputs, which cannot be swept due to it being uneconomical.
1581+ ht .AssertNumPendingSweeps (alice , 1 )
1582+ ht .AssertNumPendingSweeps (bob , 1 )
15681583}
15691584
15701585// testBumpForceCloseFee tests that when a force close transaction, in
0 commit comments