@@ -478,7 +478,10 @@ func runLocalClaimOutgoingHTLC(ht *lntest.HarnessTest,
478478 // We now mine enough blocks so the CLTV lock expires, which
479479 // will trigger the sweep of the to_local and outgoing HTLC
480480 // outputs.
481- ht .MineEmptyBlocks (int (resp .BlocksTilMaturity ))
481+ blocks := int (resp .BlocksTilMaturity )
482+ if blocks > 0 {
483+ ht .MineEmptyBlocks (blocks )
484+ }
482485
483486 // Check that Bob has a pending sweeping tx which sweeps his
484487 // to_local and outgoing HTLC outputs.
@@ -491,7 +494,10 @@ func runLocalClaimOutgoingHTLC(ht *lntest.HarnessTest,
491494 // will incur the usual CSV delay on any outputs that he can
492495 // sweep back to his wallet. We'll subtract one block from our
493496 // current maturity period to assert on the mempool.
494- ht .MineEmptyBlocks (int (resp .BlocksTilMaturity - 1 ))
497+ blocks := int (resp .BlocksTilMaturity - 1 )
498+ if blocks > 0 {
499+ ht .MineEmptyBlocks (blocks )
500+ }
495501
496502 // Check that Bob has a pending sweeping tx which sweeps his
497503 // to_local output. In addition, his immature outgoing HTLC
@@ -845,7 +851,9 @@ func runMultiHopReceiverPreimageClaim(ht *lntest.HarnessTest,
845851
846852 // If we mine 4 additional blocks, then Carol can sweep the second
847853 // level HTLC output once the CSV expires.
848- ht .MineEmptyBlocks (defaultCSV - 1 )
854+ if blocks := defaultCSV - 1 ; blocks > 0 {
855+ ht .MineEmptyBlocks (blocks )
856+ }
849857
850858 // Assert Carol has the pending HTLC sweep.
851859 ht .AssertNumPendingSweeps (carol , 1 )
@@ -873,7 +881,9 @@ func runMultiHopReceiverPreimageClaim(ht *lntest.HarnessTest,
873881
874882 // Mine enough blocks for Bob's commit output's CLTV to expire
875883 // and sweep it.
876- ht .MineEmptyBlocks (int (resp .BlocksTilMaturity ))
884+ if blocks := int (resp .BlocksTilMaturity ); blocks > 0 {
885+ ht .MineEmptyBlocks (blocks )
886+ }
877887
878888 // Bob should have two pending inputs to be swept, the commit
879889 // output and the anchor output.
@@ -1512,7 +1522,9 @@ func runRemoteForceCloseBeforeHtlcTimeout(ht *lntest.HarnessTest,
15121522 if params .CommitmentType == leasedType {
15131523 // Get the remaining blocks to mine.
15141524 resp = ht .AssertNumPendingForceClose (bob , 1 )[0 ]
1515- ht .MineEmptyBlocks (int (resp .BlocksTilMaturity ))
1525+ if blocks := int (resp .BlocksTilMaturity ); blocks > 0 {
1526+ ht .MineEmptyBlocks (blocks )
1527+ }
15161528
15171529 // Assert the commit output has been offered to the sweeper.
15181530 // Bob should have two pending sweep requests - one for the
@@ -1827,7 +1839,9 @@ func runLocalClaimIncomingHTLC(ht *lntest.HarnessTest,
18271839 "stage htlc=%v" , resp .BlocksTilMaturity ,
18281840 resp .PendingHtlcs [0 ].BlocksTilMaturity )
18291841
1830- ht .MineEmptyBlocks (int (resp .PendingHtlcs [0 ].BlocksTilMaturity ))
1842+ if blocks := int (resp .PendingHtlcs [0 ].BlocksTilMaturity ); blocks > 0 {
1843+ ht .MineEmptyBlocks (blocks )
1844+ }
18311845
18321846 // Carol should have one a sweep request for her second level tx.
18331847 ht .AssertNumPendingSweeps (carol , 1 )
@@ -1845,7 +1859,9 @@ func runLocalClaimIncomingHTLC(ht *lntest.HarnessTest,
18451859 "htlc=%v" , resp .BlocksTilMaturity ,
18461860 resp .PendingHtlcs [0 ].BlocksTilMaturity )
18471861
1848- ht .MineEmptyBlocks (int (resp .PendingHtlcs [0 ].BlocksTilMaturity ))
1862+ if blocks := int (resp .PendingHtlcs [0 ].BlocksTilMaturity ); blocks > 0 {
1863+ ht .MineEmptyBlocks (blocks )
1864+ }
18491865
18501866 // Bob should have three requests in his sweeper.
18511867 // - the second level HTLC tx.
@@ -2105,7 +2121,9 @@ func runLocalClaimIncomingHTLCLeased(ht *lntest.HarnessTest,
21052121 "stage htlc=%v" , resp .BlocksTilMaturity ,
21062122 resp .PendingHtlcs [0 ].BlocksTilMaturity )
21072123
2108- ht .MineEmptyBlocks (int (resp .PendingHtlcs [0 ].BlocksTilMaturity ))
2124+ if blocks := int (resp .PendingHtlcs [0 ].BlocksTilMaturity ); blocks > 0 {
2125+ ht .MineEmptyBlocks (blocks )
2126+ }
21092127
21102128 // Carol should have one a sweep request for her second level tx.
21112129 ht .AssertNumPendingSweeps (carol , 1 )
@@ -2122,7 +2140,9 @@ func runLocalClaimIncomingHTLCLeased(ht *lntest.HarnessTest,
21222140
21232141 ht .Logf ("Bob's timelock to_local output=%v, timelock on second stage " +
21242142 "htlc=%v" , resp .BlocksTilMaturity , htlcExpiry )
2125- ht .MineEmptyBlocks (int (htlcExpiry ))
2143+ if blocks := int (htlcExpiry ); blocks > 0 {
2144+ ht .MineEmptyBlocks (blocks )
2145+ }
21262146
21272147 // When we mine one additional block, that will confirm Bob's second
21282148 // level HTLC sweep on channel Alice=>Bob.
@@ -2136,7 +2156,9 @@ func runLocalClaimIncomingHTLCLeased(ht *lntest.HarnessTest,
21362156
21372157 ht .Logf ("Bob's timelock to_local output=%v, timelock on second stage " +
21382158 "htlc=%v" , resp .BlocksTilMaturity , htlcExpiry )
2139- ht .MineEmptyBlocks (int (resp .BlocksTilMaturity ))
2159+ if blocks := int (resp .BlocksTilMaturity ); blocks > 0 {
2160+ ht .MineEmptyBlocks (blocks )
2161+ }
21402162
21412163 // Bob should have three requests in his sweeper.
21422164 // - to_local output from channel Bob=>Carol.
@@ -2443,7 +2465,9 @@ func runLocalPreimageClaim(ht *lntest.HarnessTest,
24432465 "stage htlc=%v" , resp .BlocksTilMaturity ,
24442466 resp .PendingHtlcs [0 ].BlocksTilMaturity )
24452467
2446- ht .MineEmptyBlocks (int (resp .PendingHtlcs [0 ].BlocksTilMaturity ))
2468+ if blocks := int (resp .PendingHtlcs [0 ].BlocksTilMaturity ); blocks > 0 {
2469+ ht .MineEmptyBlocks (blocks )
2470+ }
24472471
24482472 // Carol should offer the htlc output to her sweeper.
24492473 ht .AssertNumPendingSweeps (carol , 1 )
@@ -2683,7 +2707,9 @@ func runLocalPreimageClaimLeased(ht *lntest.HarnessTest,
26832707 "stage htlc=%v" , resp .BlocksTilMaturity ,
26842708 resp .PendingHtlcs [0 ].BlocksTilMaturity )
26852709
2686- ht .MineEmptyBlocks (int (resp .PendingHtlcs [0 ].BlocksTilMaturity ))
2710+ if blocks := int (resp .PendingHtlcs [0 ].BlocksTilMaturity ); blocks > 0 {
2711+ ht .MineEmptyBlocks (blocks )
2712+ }
26872713
26882714 // Carol should offer the htlc output to her sweeper.
26892715 ht .AssertNumPendingSweeps (carol , 1 )
@@ -2715,7 +2741,9 @@ func runLocalPreimageClaimLeased(ht *lntest.HarnessTest,
27152741 "stage htlc=%v" , resp .BlocksTilMaturity ,
27162742 resp .PendingHtlcs [0 ].BlocksTilMaturity )
27172743
2718- ht .MineEmptyBlocks (int (resp .BlocksTilMaturity ))
2744+ if blocks := int (resp .BlocksTilMaturity ); blocks > 0 {
2745+ ht .MineEmptyBlocks (blocks )
2746+ }
27192747
27202748 // Alice should two sweeping requests,
27212749 // - the anchor output from channel Alice=>Bob, uneconomical.
@@ -3111,7 +3139,9 @@ func runHtlcAggregation(ht *lntest.HarnessTest,
31113139 "htlc=%v" , resp .BlocksTilMaturity ,
31123140 resp .PendingHtlcs [0 ].BlocksTilMaturity )
31133141
3114- ht .MineEmptyBlocks (int (resp .PendingHtlcs [0 ].BlocksTilMaturity ))
3142+ if blocks := int (resp .PendingHtlcs [0 ].BlocksTilMaturity ); blocks > 0 {
3143+ ht .MineEmptyBlocks (blocks )
3144+ }
31153145
31163146 // With the above mined block, Bob's HTLCs should now all be offered to
31173147 // his sweeper since the CSV lock is now expired. In addition he should
0 commit comments