@@ -414,23 +414,16 @@ func TestCustomSweepConfTarget(t *testing.T) {
414414// not detected our settle) and settle the off chain htlc, indicating that the
415415// server successfully settled using the preimage push. In this test, we need
416416// to start with a fee rate that will be too high, then progress to an
417- // acceptable one. We do this by starting with a high confirmation target with
418- // a high fee, and setting the default confirmation fee (which our swap will
419- // drop down to if it is not confirming in time) to a lower fee. This is not
420- // intuitive (lower confs having lower fees), but it allows up to mock fee
421- // changes.
417+ // acceptable one.
422418func TestPreimagePush (t * testing.T ) {
423419 defer test .Guard (t )()
424420
425421 lnd := test .NewMockLnd ()
426422 ctx := test .NewContext (t , lnd )
427423 server := newServerMock (lnd )
428424
429- // Start with a high confirmation delta which will have a very high fee
430- // attached to it.
431425 testReq := * testRequest
432- testReq .SweepConfTarget = testLoopOutMinOnChainCltvDelta -
433- DefaultSweepConfTargetDelta - 1
426+ testReq .SweepConfTarget = 10
434427 testReq .Expiry = ctx .Lnd .Height + testLoopOutMinOnChainCltvDelta
435428
436429 // We set our mock fee estimate for our target sweep confs to be our
@@ -442,11 +435,6 @@ func TestPreimagePush(t *testing.T) {
442435 ),
443436 )
444437
445- // We set the fee estimate for our default confirmation target very
446- // low, so that once we drop down to our default confs we will start
447- // trying to sweep the preimage.
448- ctx .Lnd .SetFeeEstimate (DefaultSweepConfTarget , 1 )
449-
450438 cfg := newSwapConfig (
451439 & lnd .LndServices , newStoreMock (t ), server ,
452440 )
@@ -520,15 +508,15 @@ func TestPreimagePush(t *testing.T) {
520508 // preimage is not revealed, we also do not expect a preimage push.
521509 expiryChan <- testTime
522510
523- // Now, we notify the height at which the client will start using the
524- // default confirmation target. This has the effect of lowering our fees
525- // so that the client still start sweeping.
526- defaultConfTargetHeight := ctx .Lnd .Height + testLoopOutMinOnChainCltvDelta -
527- DefaultSweepConfTargetDelta
528- blockEpochChan <- defaultConfTargetHeight
511+ // Now we decrease our fees for the swap's confirmation target to less
512+ // than the maximum miner fee.
513+ ctx .Lnd .SetFeeEstimate (testReq .SweepConfTarget , chainfee .SatPerKWeight (
514+ testReq .MaxMinerFee / 2 ,
515+ ))
529516
530- // This time when we tick the expiry chan, our fees are lower than the
531- // swap max, so we expect it to prompt a sweep.
517+ // Now when we report a new block and tick our expiry fee timer, and
518+ // fees are acceptably low so we expect our sweep to be published.
519+ blockEpochChan <- ctx .Lnd .Height + 2
532520 expiryChan <- testTime
533521
534522 // Expect a signing request for the HTLC success transaction.
0 commit comments