Skip to content

Commit 08ac7b6

Browse files
committed
itest: update itests to use new *WithSweep helper assertions
This change is due to the fact that blockbeat handling is now more async in the cnct.
1 parent b578431 commit 08ac7b6

File tree

6 files changed

+24
-24
lines changed

6 files changed

+24
-24
lines changed

itest/lnd_channel_backup_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1630,7 +1630,7 @@ func assertDLPExecuted(ht *lntest.HarnessTest,
16301630
// Expect one tx - the commitment sweep from Dave. For anchor
16311631
// channels, we expect the two anchor sweeping txns to be
16321632
// failed due they are uneconomical.
1633-
ht.MineBlocksAndAssertNumTxes(1, 1)
1633+
ht.MineBlocksAndAssertNumTxesWithSweep(1, 1, dave)
16341634
blocksMined++
16351635

16361636
// Now Dave should consider the channel fully closed.

itest/lnd_channel_force_close_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ func runChannelForceClosureTest(ht *lntest.HarnessTest,
184184
)
185185

186186
// We expect to see Alice's force close tx in the mempool.
187-
ht.AssertNumTxsInMempool(1)
187+
ht.AssertNumTxsInMempoolWithSweepTrigger(1, alice)
188188

189189
// Mine a block which should confirm the commitment transaction
190190
// broadcast as a result of the force closure. Once mined, we also
@@ -233,7 +233,7 @@ func runChannelForceClosureTest(ht *lntest.HarnessTest,
233233
// Carol's sweep tx should be in the mempool already, as her output is
234234
// not timelocked. This sweep tx should spend her to_local output as
235235
// the anchor output is not economical to spend.
236-
carolTx := ht.GetNumTxsFromMempool(1)[0]
236+
carolTx := ht.GetNumTxsFromMempoolWithSweep(1, carol)[0]
237237

238238
// Carol's sweeping tx should have 1-input-1-output shape.
239239
require.Len(ht, carolTx.TxIn, 1)
@@ -792,7 +792,7 @@ func runChannelForceClosureTestRestart(ht *lntest.HarnessTest,
792792
ht.RestartNode(alice)
793793

794794
// We expect to see Alice's force close tx in the mempool.
795-
ht.AssertNumTxsInMempool(1)
795+
ht.AssertNumTxsInMempoolWithSweepTrigger(1, alice)
796796

797797
// Mine a block which should confirm the commitment transaction
798798
// broadcast as a result of the force closure. Once mined, we also
@@ -847,7 +847,7 @@ func runChannelForceClosureTestRestart(ht *lntest.HarnessTest,
847847
// Carol's sweep tx should be in the mempool already, as her output is
848848
// not timelocked. This sweep tx should spend her to_local output as
849849
// the anchor output is not economical to spend.
850-
carolTx := ht.GetNumTxsFromMempool(1)[0]
850+
carolTx := ht.GetNumTxsFromMempoolWithSweep(1, carol)[0]
851851

852852
// Carol's sweeping tx should have 1-input-1-output shape.
853853
require.Len(ht, carolTx.TxIn, 1)

itest/lnd_funding_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1272,11 +1272,10 @@ func testChannelFundingWithUnstableUtxos(ht *lntest.HarnessTest) {
12721272
// Make sure Carol sees her to_remote output from the force close tx.
12731273
ht.AssertNumPendingSweeps(carol, 1)
12741274

1275-
// Wait for Carol's sweep transaction to appear in the mempool. Due to
1276-
// async confirmation notifications, there's a race between when the
1277-
// sweep is registered and when the sweeper processes the next block.
1278-
// The sweeper uses immediate=false, so it broadcasts on the next block
1279-
// after registration. Mine an empty block to trigger the broadcast.
1275+
// Mine an empty block to trigger the sweep. Due to async confirmation
1276+
// notifications, the sweep registration might happen after the force
1277+
// close block is processed by the sweeper. Mining another block gives
1278+
// time for registration and triggers the broadcast.
12801279
ht.MineEmptyBlocks(1)
12811280

12821281
// Now the sweep should be in the mempool.
@@ -1338,9 +1337,10 @@ func testChannelFundingWithUnstableUtxos(ht *lntest.HarnessTest) {
13381337
// Make sure Carol sees her to_remote output from the force close tx.
13391338
ht.AssertNumPendingSweeps(carol, 1)
13401339

1341-
// Mine an empty block to trigger the sweep broadcast (same fix as
1342-
// above).
1340+
// Mine an empty block to trigger the sweep (same as above).
13431341
ht.MineEmptyBlocks(1)
1342+
1343+
// Sweep should be in mempool.
13441344
ht.AssertNumTxsInMempool(1)
13451345

13461346
// Wait for the to_remote sweep tx to show up in carol's wallet.

itest/lnd_multi-hop_force_close_test.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ func runLocalClaimOutgoingHTLC(ht *lntest.HarnessTest,
428428
// We expect to see tow txns in the mempool,
429429
// 1. Bob's force close tx.
430430
// 2. Bob's anchor sweep tx.
431-
ht.AssertNumTxsInMempool(2)
431+
ht.AssertNumTxsInMempoolWithSweepTrigger(2, bob)
432432

433433
// Mine a block to confirm the closing tx and the anchor sweeping tx.
434434
ht.MineBlocksAndAssertNumTxes(1, 2)
@@ -447,7 +447,7 @@ func runLocalClaimOutgoingHTLC(ht *lntest.HarnessTest,
447447
// Bob's sweeper should sweep his outgoing HTLC immediately since it's
448448
// expired. His to_local output cannot be swept due to the CSV lock.
449449
// Carol's anchor sweep should be failed due to output being dust.
450-
ht.AssertNumTxsInMempool(1)
450+
ht.AssertNumTxsInMempoolWithSweepTrigger(1, bob)
451451

452452
// Mine a block to confirm Bob's outgoing HTLC sweeping tx.
453453
ht.MineBlocksAndAssertNumTxes(1, 1)
@@ -788,7 +788,7 @@ func runMultiHopReceiverPreimageClaim(ht *lntest.HarnessTest,
788788
// We expect to see tow txns in the mempool,
789789
// 1. Carol's force close tx.
790790
// 2. Carol's anchor sweep tx.
791-
ht.AssertNumTxsInMempool(2)
791+
ht.AssertNumTxsInMempoolWithSweepTrigger(2, carol)
792792

793793
// Mine a block to confirm the closing tx and the anchor sweeping tx.
794794
ht.MineBlocksAndAssertNumTxes(1, 2)
@@ -1133,7 +1133,7 @@ func runLocalForceCloseBeforeHtlcTimeout(ht *lntest.HarnessTest,
11331133
ht.MineBlocks(int(defaultCSV - 1))
11341134

11351135
// Mine a block to confirm Bob's to_local sweep.
1136-
ht.MineBlocksAndAssertNumTxes(1, 1)
1136+
ht.MineBlocksAndAssertNumTxesWithSweep(1, 1, bob)
11371137
}
11381138

11391139
// We'll now mine enough blocks for the HTLC to expire. After this, Bob
@@ -1457,7 +1457,7 @@ func runRemoteForceCloseBeforeHtlcTimeout(ht *lntest.HarnessTest,
14571457
// won't be swept due it being uneconomical. For Carol, since
14581458
// her anchor is not used for CPFP, it'd be also uneconomical
14591459
// to sweep so it will fail.
1460-
ht.MineBlocksAndAssertNumTxes(1, 1)
1460+
ht.MineBlocksAndAssertNumTxesWithSweep(1, 1, bob)
14611461
}
14621462

14631463
// Next, we'll mine enough blocks for the HTLC to expire. At this
@@ -1711,7 +1711,7 @@ func runLocalClaimIncomingHTLC(ht *lntest.HarnessTest,
17111711
// commit tx). Her anchor output won't be swept as it's uneconomical.
17121712
// For Bob, since his anchor is not used for CPFP, it'd be uneconomical
17131713
// to sweep so it will fail.
1714-
ht.AssertNumTxsInMempool(1)
1714+
ht.AssertNumTxsInMempoolWithSweepTrigger(1, alice)
17151715

17161716
// Mine a block to confirm Alice's sweeping tx.
17171717
ht.MineBlocksAndAssertNumTxes(1, 1)
@@ -1771,7 +1771,7 @@ func runLocalClaimIncomingHTLC(ht *lntest.HarnessTest,
17711771
// commitment anchor output, we'd expect to see two txns,
17721772
// - Carol's second level HTLC tx.
17731773
// - Bob's commitment output sweeping tx.
1774-
ht.AssertNumTxsInMempool(2)
1774+
ht.AssertNumTxsInMempoolWithSweepTrigger(2, bob)
17751775

17761776
// At this point we suspend Alice to make sure she'll handle the
17771777
// on-chain settle after a restart.
@@ -2401,7 +2401,7 @@ func runLocalPreimageClaim(ht *lntest.HarnessTest,
24012401
// We mine one block to confirm,
24022402
// - Carol's sweeping tx of the incoming HTLC.
24032403
// - Bob's sweeping tx of his commit output.
2404-
ht.MineBlocksAndAssertNumTxes(1, 2)
2404+
ht.MineBlocksAndAssertNumTxesWithSweep(1, 2, bob)
24052405

24062406
// When Bob notices Carol's second level tx in the block, he will
24072407
// extract the preimage and offer the HTLC to his sweeper. So he has,
@@ -2641,7 +2641,7 @@ func runLocalPreimageClaimLeased(ht *lntest.HarnessTest,
26412641

26422642
// We mine one block to confirm,
26432643
// - Carol's sweeping tx of the incoming HTLC.
2644-
ht.MineBlocksAndAssertNumTxes(1, 1)
2644+
ht.MineBlocksAndAssertNumTxesWithSweep(1, 1, carol)
26452645

26462646
// When Bob notices Carol's second level tx in the block, he will
26472647
// extract the preimage and offer the HTLC to his sweeper. So he has,
@@ -3030,7 +3030,7 @@ func runHtlcAggregation(ht *lntest.HarnessTest,
30303030

30313031
// Bob's force close tx and anchor sweeping tx should now be found in
30323032
// the mempool.
3033-
ht.AssertNumTxsInMempool(2)
3033+
ht.AssertNumTxsInMempoolWithSweepTrigger(2, bob)
30343034

30353035
// Mine a block to confirm Bob's force close tx and anchor sweeping tx.
30363036
ht.MineBlocksAndAssertNumTxes(1, 2)

itest/lnd_sweep_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1389,7 +1389,7 @@ func testSweepCommitOutputAndAnchor(ht *lntest.HarnessTest) {
13891389
// requests will be sent to the sweeper. Finally, when the sweeper
13901390
// receives this blockbeat, it will create the sweeping tx and publish
13911391
// it.
1392-
ht.AssertNumTxsInMempool(1)
1392+
ht.AssertNumTxsInMempoolWithSweepTrigger(1, bob)
13931393

13941394
// Mine one more empty block should trigger Bob's sweeping. Since we
13951395
// use a CSV of 2, this means Alice's to_local output is now mature.

itest/lnd_wipe_fwdpkgs_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,5 +97,5 @@ func testWipeForwardingPackages(ht *lntest.HarnessTest) {
9797
ht.AssertNumPendingSweeps(alice, 1)
9898

9999
// Mine 1 block to get Alice's sweeping tx confirmed.
100-
ht.MineBlocksAndAssertNumTxes(1, 1)
100+
ht.MineBlocksAndAssertNumTxesWithSweep(1, 1, alice)
101101
}

0 commit comments

Comments
 (0)