@@ -414,23 +414,16 @@ func TestCustomSweepConfTarget(t *testing.T) {
414
414
// not detected our settle) and settle the off chain htlc, indicating that the
415
415
// server successfully settled using the preimage push. In this test, we need
416
416
// 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.
422
418
func TestPreimagePush (t * testing.T ) {
423
419
defer test .Guard (t )()
424
420
425
421
lnd := test .NewMockLnd ()
426
422
ctx := test .NewContext (t , lnd )
427
423
server := newServerMock (lnd )
428
424
429
- // Start with a high confirmation delta which will have a very high fee
430
- // attached to it.
431
425
testReq := * testRequest
432
- testReq .SweepConfTarget = testLoopOutMinOnChainCltvDelta -
433
- DefaultSweepConfTargetDelta - 1
426
+ testReq .SweepConfTarget = 10
434
427
testReq .Expiry = ctx .Lnd .Height + testLoopOutMinOnChainCltvDelta
435
428
436
429
// We set our mock fee estimate for our target sweep confs to be our
@@ -442,11 +435,6 @@ func TestPreimagePush(t *testing.T) {
442
435
),
443
436
)
444
437
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
-
450
438
cfg := newSwapConfig (
451
439
& lnd .LndServices , newStoreMock (t ), server ,
452
440
)
@@ -520,15 +508,15 @@ func TestPreimagePush(t *testing.T) {
520
508
// preimage is not revealed, we also do not expect a preimage push.
521
509
expiryChan <- testTime
522
510
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
+ ))
529
516
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
532
520
expiryChan <- testTime
533
521
534
522
// Expect a signing request for the HTLC success transaction.
0 commit comments