Skip to content

Commit 170291c

Browse files
committed
itest: fix tests re the new anchor behavior
1 parent 97030a5 commit 170291c

File tree

2 files changed

+21
-19
lines changed

2 files changed

+21
-19
lines changed

itest/lnd_channel_force_close_test.go

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -978,15 +978,6 @@ func runChannelForceClosureTestRestart(ht *lntest.HarnessTest,
978978
Outpoint: commitSweep.Outpoint,
979979
AmountSat: uint64(aliceBalance),
980980
}
981-
op = fmt.Sprintf("%v:%v", anchorSweep.Outpoint.TxidStr,
982-
anchorSweep.Outpoint.OutputIndex)
983-
aliceReports[op] = &lnrpc.Resolution{
984-
ResolutionType: lnrpc.ResolutionType_ANCHOR,
985-
Outcome: lnrpc.ResolutionOutcome_CLAIMED,
986-
SweepTxid: sweepTxid.String(),
987-
Outpoint: anchorSweep.Outpoint,
988-
AmountSat: uint64(anchorSweep.AmountSat),
989-
}
990981

991982
// Check that we can find the commitment sweep in our set of known
992983
// sweeps, using the simple transaction id ListSweeps output.
@@ -1101,8 +1092,9 @@ func runChannelForceClosureTestRestart(ht *lntest.HarnessTest,
11011092

11021093
// Since Alice had numInvoices (6) htlcs extended to Carol before force
11031094
// closing, we expect Alice to broadcast an htlc timeout txn for each
1104-
// one.
1105-
ht.AssertNumPendingSweeps(alice, numInvoices)
1095+
// one. In addition, the anchor input is still pending due to it's
1096+
// uneconomical to sweep.
1097+
ht.AssertNumPendingSweeps(alice, numInvoices+1)
11061098

11071099
// Wait for them all to show up in the mempool
11081100
htlcTxid := ht.AssertNumTxsInMempool(1)[0]
@@ -1198,7 +1190,7 @@ func runChannelForceClosureTestRestart(ht *lntest.HarnessTest,
11981190
numBlocks := int(htlcCsvMaturityHeight - uint32(curHeight) - 1)
11991191
ht.MineEmptyBlocks(numBlocks)
12001192

1201-
ht.AssertNumPendingSweeps(alice, numInvoices)
1193+
ht.AssertNumPendingSweeps(alice, numInvoices+1)
12021194

12031195
// Fetch the htlc sweep transaction from the mempool.
12041196
htlcSweepTx := ht.GetNumTxsFromMempool(1)[0]
@@ -1220,7 +1212,7 @@ func runChannelForceClosureTestRestart(ht *lntest.HarnessTest,
12201212
}, defaultTimeout)
12211213
require.NoError(ht, err, "timeout while checking force closed channel")
12221214

1223-
ht.AssertNumPendingSweeps(alice, numInvoices)
1215+
ht.AssertNumPendingSweeps(alice, numInvoices+1)
12241216

12251217
// Ensure the htlc sweep transaction only has one input for each htlc
12261218
// Alice extended before force closing.

itest/lnd_sweep_test.go

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1224,8 +1224,8 @@ func testSweepHTLCs(ht *lntest.HarnessTest) {
12241224
// 4. Alice force closes the channel.
12251225
//
12261226
// Test:
1227-
// 1. Alice's anchor sweeping is not attempted, instead, it should be swept
1228-
// together with her to_local output using the no deadline path.
1227+
// 1. Alice's CPFP-anchor sweeping is not attempted, instead, it should be
1228+
// swept using the no deadline path and failed due it's not economical.
12291229
// 2. Bob would also sweep his anchor and to_local outputs separately due to
12301230
// they have different deadline heights, which means only the to_local
12311231
// sweeping tx will succeed as the anchor sweeping is not economical.
@@ -1241,10 +1241,15 @@ func testSweepCommitOutputAndAnchor(ht *lntest.HarnessTest) {
12411241
// config.
12421242
deadline := uint32(1000)
12431243

1244-
// deadlineA is the deadline used for Alice, since her commit output is
1245-
// offered to the sweeper at CSV-1. With a deadline of 1000, her actual
1246-
// width of her fee func is CSV+1000-1. Given we are using a CSV of 2
1247-
// here, her fee func deadline then becomes 1001.
1244+
// deadlineA is the deadline used for Alice, given that,
1245+
// - the force close tx is broadcast at height 445, her inputs are
1246+
// registered at the same height, so her to_local and anchor outputs
1247+
// have a deadline height of 1445.
1248+
// - the force close tx is mined at 446, which means her anchor output
1249+
// now has a deadline delta of (1445-446) = 999 blocks.
1250+
// - for her to_local output, with a deadline of 1000, the width of the
1251+
// fee func is CSV+1000-1. Given we are using a CSV of 2 here, her fee
1252+
// func deadline then becomes 1001.
12481253
deadlineA := deadline + 1
12491254

12501255
// deadlineB is the deadline used for Bob, the actual deadline used by
@@ -1267,6 +1272,11 @@ func testSweepCommitOutputAndAnchor(ht *lntest.HarnessTest) {
12671272
// conf target is the deadline.
12681273
ht.SetFeeEstimateWithConf(startFeeRate, deadlineB)
12691274

1275+
// Set up the starting fee for Alice's anchor sweeping. With this low
1276+
// fee rate, her anchor sweeping should be attempted and failed due to
1277+
// dust output generated in the sweeping tx.
1278+
ht.SetFeeEstimateWithConf(startFeeRate, deadline-1)
1279+
12701280
// toLocalCSV is the CSV delay for Alice's to_local output. We use a
12711281
// small value to save us from mining blocks.
12721282
//

0 commit comments

Comments
 (0)