Skip to content

Commit 85eb3d0

Browse files
committed
loopout/test: prevent modification of global test request
1 parent f5f2d42 commit 85eb3d0

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

loopout_test.go

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -225,20 +225,22 @@ func TestCustomSweepConfTarget(t *testing.T) {
225225

226226
// Use the highest sweep confirmation target before we attempt to use
227227
// the default.
228-
testRequest.SweepConfTarget = testLoopOutOnChainCltvDelta -
228+
testReq := *testRequest
229+
230+
testReq.SweepConfTarget = testLoopOutOnChainCltvDelta -
229231
DefaultSweepConfTargetDelta - 1
230232

231233
// Set up custom fee estimates such that the lower confirmation target
232234
// yields a much higher fee rate.
233-
ctx.Lnd.SetFeeEstimate(testRequest.SweepConfTarget, 250)
235+
ctx.Lnd.SetFeeEstimate(testReq.SweepConfTarget, 250)
234236
ctx.Lnd.SetFeeEstimate(DefaultSweepConfTarget, 10000)
235237

236238
cfg := newSwapConfig(
237239
&lnd.LndServices, newStoreMock(t), server,
238240
)
239241

240242
initResult, err := newLoopOutSwap(
241-
context.Background(), cfg, ctx.Lnd.Height, testRequest,
243+
context.Background(), cfg, ctx.Lnd.Height, &testReq,
242244
)
243245
if err != nil {
244246
t.Fatal(err)
@@ -357,7 +359,7 @@ func TestCustomSweepConfTarget(t *testing.T) {
357359

358360
// The sweep should have a fee that corresponds to the custom
359361
// confirmation target.
360-
_ = assertSweepTx(testRequest.SweepConfTarget)
362+
_ = assertSweepTx(testReq.SweepConfTarget)
361363

362364
// Once we have published an on chain sweep, we expect a preimage to
363365
// have been pushed to our server.
@@ -424,15 +426,16 @@ func TestPreimagePush(t *testing.T) {
424426

425427
// Start with a high confirmation delta which will have a very high fee
426428
// attached to it.
427-
testRequest.SweepConfTarget = testLoopOutOnChainCltvDelta -
429+
testReq := *testRequest
430+
testReq.SweepConfTarget = testLoopOutOnChainCltvDelta -
428431
DefaultSweepConfTargetDelta - 1
429432

430433
// We set our mock fee estimate for our target sweep confs to be our
431434
// max miner fee *2, so that our fee will definitely be above what we
432435
// are willing to pay, and we will not sweep.
433436
ctx.Lnd.SetFeeEstimate(
434-
testRequest.SweepConfTarget, chainfee.SatPerKWeight(
435-
testRequest.MaxMinerFee*2,
437+
testReq.SweepConfTarget, chainfee.SatPerKWeight(
438+
testReq.MaxMinerFee*2,
436439
),
437440
)
438441

@@ -446,7 +449,7 @@ func TestPreimagePush(t *testing.T) {
446449
)
447450

448451
initResult, err := newLoopOutSwap(
449-
context.Background(), cfg, ctx.Lnd.Height, testRequest,
452+
context.Background(), cfg, ctx.Lnd.Height, &testReq,
450453
)
451454
require.NoError(t, err)
452455
swap := initResult.swap

0 commit comments

Comments
 (0)