From 85eb3d0fee0f1a41e045e7b02bac5de20a07954e Mon Sep 17 00:00:00 2001 From: Joost Jager Date: Wed, 15 Jul 2020 16:44:48 +0200 Subject: [PATCH] loopout/test: prevent modification of global test request --- loopout_test.go | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/loopout_test.go b/loopout_test.go index 0c7fa2d..0bc449d 100644 --- a/loopout_test.go +++ b/loopout_test.go @@ -225,12 +225,14 @@ func TestCustomSweepConfTarget(t *testing.T) { // Use the highest sweep confirmation target before we attempt to use // the default. - testRequest.SweepConfTarget = testLoopOutOnChainCltvDelta - + testReq := *testRequest + + testReq.SweepConfTarget = testLoopOutOnChainCltvDelta - DefaultSweepConfTargetDelta - 1 // Set up custom fee estimates such that the lower confirmation target // yields a much higher fee rate. - ctx.Lnd.SetFeeEstimate(testRequest.SweepConfTarget, 250) + ctx.Lnd.SetFeeEstimate(testReq.SweepConfTarget, 250) ctx.Lnd.SetFeeEstimate(DefaultSweepConfTarget, 10000) cfg := newSwapConfig( @@ -238,7 +240,7 @@ func TestCustomSweepConfTarget(t *testing.T) { ) initResult, err := newLoopOutSwap( - context.Background(), cfg, ctx.Lnd.Height, testRequest, + context.Background(), cfg, ctx.Lnd.Height, &testReq, ) if err != nil { t.Fatal(err) @@ -357,7 +359,7 @@ func TestCustomSweepConfTarget(t *testing.T) { // The sweep should have a fee that corresponds to the custom // confirmation target. - _ = assertSweepTx(testRequest.SweepConfTarget) + _ = assertSweepTx(testReq.SweepConfTarget) // Once we have published an on chain sweep, we expect a preimage to // have been pushed to our server. @@ -424,15 +426,16 @@ func TestPreimagePush(t *testing.T) { // Start with a high confirmation delta which will have a very high fee // attached to it. - testRequest.SweepConfTarget = testLoopOutOnChainCltvDelta - + testReq := *testRequest + testReq.SweepConfTarget = testLoopOutOnChainCltvDelta - DefaultSweepConfTargetDelta - 1 // We set our mock fee estimate for our target sweep confs to be our // max miner fee *2, so that our fee will definitely be above what we // are willing to pay, and we will not sweep. ctx.Lnd.SetFeeEstimate( - testRequest.SweepConfTarget, chainfee.SatPerKWeight( - testRequest.MaxMinerFee*2, + testReq.SweepConfTarget, chainfee.SatPerKWeight( + testReq.MaxMinerFee*2, ), ) @@ -446,7 +449,7 @@ func TestPreimagePush(t *testing.T) { ) initResult, err := newLoopOutSwap( - context.Background(), cfg, ctx.Lnd.Height, testRequest, + context.Background(), cfg, ctx.Lnd.Height, &testReq, ) require.NoError(t, err) swap := initResult.swap