lint: remove redundant loop var copies in test files
What changed, and why it matters
This commit is a cleanup-only change that removes unnecessary loop-variable copies in Go test files. Since Go 1.22, loop variables are already scoped per-iteration, so the old `x := x` workarounds are redundant. The change affects only test code, not the running LND node software, and does not alter any behavior or fix a security bug.
No security action needed. This is a routine lint/test-cleanup change. Reviewers can verify the project requires Go 1.22+ and that CI tests still pass.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit deletes 271 lines of redundant test := test, tc := tc, i := i, and similar loop-variable reassignments across 137 *_test.go files. These copies were previously required before Go 1.22 to avoid closure capture bugs in parallel subtests. Go 1.22 changed loop variable scoping, making the copies unnecessary. No production code is modified, no logic is changed, and no security vulnerability is addressed.
Changed components
Test files only (137 *_test.go files across the repository)Inspect captured patch +0 / −271
diff --git a/aliasmgr/aliasmgr_test.go b/aliasmgr/aliasmgr_test.go
index 3237e5b..cdf8842 100644
--- a/aliasmgr/aliasmgr_test.go
+++ b/aliasmgr/aliasmgr_test.go
@@ -259,7 +259,6 @@ func TestGetNextScid(t *testing.T) {
}
for _, test := range tests {
- test := test
t.Run(test.name, func(t *testing.T) {
nextScid := getNextScid(test.current)
require.Equal(t, test.expected, nextScid)
diff --git a/amp/derivation_test.go b/amp/derivation_test.go
index af8162d..3ebddca 100644
--- a/amp/derivation_test.go
+++ b/amp/derivation_test.go
@@ -43,7 +43,6 @@ var sharerTests = []sharerTest{
// receiver, produce identical child hashes and preimages as the sender.
func TestSharer(t *testing.T) {
for _, test := range sharerTests {
- test := test
t.Run(test.name, func(t *testing.T) {
t.Parallel()
diff --git a/autopilot/betweenness_centrality_test.go b/autopilot/betweenness_centrality_test.go
index 5571a78..7e257a8 100644
--- a/autopilot/betweenness_centrality_test.go
+++ b/autopilot/betweenness_centrality_test.go
@@ -40,7 +40,6 @@ func TestBetweennessCentralityEmptyGraph(t *testing.T) {
)
for _, chanGraph := range chanGraphs {
- chanGraph := chanGraph
graph, err := chanGraph.genFunc(t)
require.NoError(t, err, "unable to create graph")
@@ -83,7 +82,6 @@ func TestBetweennessCentralityWithNonEmptyGraph(t *testing.T) {
for _, numWorkers := range workers {
for _, chanGraph := range chanGraphs {
- chanGraph := chanGraph
numWorkers := numWorkers
graph, err := chanGraph.genFunc(t)
require.NoError(t, err, "unable to create graph")
@@ -110,7 +108,6 @@ func TestBetweennessCentralityWithNonEmptyGraph(t *testing.T) {
require.NoError(t1, err)
for _, expected := range tests {
- expected := expected
centrality := metric.GetMetric(
expected.normalize,
)
diff --git a/autopilot/prefattach_test.go b/autopilot/prefattach_test.go
index cdaec87..9ff9d30 100644
--- a/autopilot/prefattach_test.go
+++ b/autopilot/prefattach_test.go
@@ -91,7 +91,6 @@ func TestPrefAttachmentSelectEmptyGraph(t *testing.T) {
}
for _, chanGraph := range chanGraphs {
- chanGraph := chanGraph
graph, err := chanGraph.genFunc(t)
require.NoError(t, err, "unable to create graph")
@@ -128,7 +127,6 @@ func TestPrefAttachmentSelectTwoVertexes(t *testing.T) {
)
for _, chanGraph := range chanGraphs {
- chanGraph := chanGraph
graph, err := chanGraph.genFunc(t)
require.NoError(t, err, "unable to create graph")
@@ -215,7 +213,6 @@ func TestPrefAttachmentSelectGreedyAllocation(t *testing.T) {
)
for _, chanGraph := range chanGraphs {
- chanGraph := chanGraph
graph, err := chanGraph.genFunc(t)
require.NoError(t, err, "unable to create graph")
@@ -328,7 +325,6 @@ func TestPrefAttachmentSelectSkipNodes(t *testing.T) {
)
for _, chanGraph := range chanGraphs {
- chanGraph := chanGraph
graph, err := chanGraph.genFunc(t)
require.NoError(t, err, "unable to create graph")
diff --git a/autopilot/top_centrality_test.go b/autopilot/top_centrality_test.go
index 282e60c..a6fe227 100644
--- a/autopilot/top_centrality_test.go
+++ b/autopilot/top_centrality_test.go
@@ -83,7 +83,6 @@ func TestTopCentrality(t *testing.T) {
}
for _, chanGraph := range chanGraphs {
- chanGraph := chanGraph
success := t.Run(chanGraph.name, func(t1 *testing.T) {
t1.Parallel()
diff --git a/build/log_test.go b/build/log_test.go
index dbce428..d58b3dd 100644
--- a/build/log_test.go
+++ b/build/log_test.go
@@ -92,7 +92,6 @@ func TestParseAndSetDebugLevels(t *testing.T) {
}
for _, test := range testCases {
- test := test
t.Run(test.name, func(t *testing.T) {
m := &mockSubLogger{
subLogLevels: make(map[string]string),
diff --git a/chainntnfs/txnotifier_test.go b/chainntnfs/txnotifier_test.go
index 1bd9f4f..d06ab8e 100644
--- a/chainntnfs/txnotifier_test.go
+++ b/chainntnfs/txnotifier_test.go
@@ -172,7 +172,6 @@ func TestTxNotifierRegistrationValidation(t *testing.T) {
}
for _, testCase := range testCases {
- testCase := testCase
success := t.Run(testCase.name, func(t *testing.T) {
hintCache := newMockHintCache()
n := chainntnfs.NewTxNotifier(
diff --git a/chanacceptor/acceptor_test.go b/chanacceptor/acceptor_test.go
index 5a6aaa0..2746b31 100644
--- a/chanacceptor/acceptor_test.go
+++ b/chanacceptor/acceptor_test.go
@@ -134,8 +134,6 @@ func (c *channelAcceptorCtx) queryAndAssert(queries map[*lnwire.OpenChannel]*Cha
)
for request, expected := range queries {
- request := request
- expected := expected
go func() {
resp := c.acceptor.Accept(&ChannelAcceptRequest{
diff --git a/chanacceptor/merge_test.go b/chanacceptor/merge_test.go
index c6b6579..0ffaade 100644
--- a/chanacceptor/merge_test.go
+++ b/chanacceptor/merge_test.go
@@ -182,7 +182,6 @@ func TestMergeResponse(t *testing.T) {
}
for _, test := range tests {
- test := test
t.Run(test.name, func(t *testing.T) {
resp, err := mergeResponse(test.current, test.new)
diff --git a/chanacceptor/rpcacceptor_test.go b/chanacceptor/rpcacceptor_test.go
index de1f380..eb65080 100644
--- a/chanacceptor/rpcacceptor_test.go
+++ b/chanacceptor/rpcacceptor_test.go
@@ -118,7 +118,6 @@ func TestValidateAcceptorResponse(t *testing.T) {
}
for _, test := range tests {
- test := test
t.Run(test.name, func(t *testing.T) {
// Create an acceptor, everything can be nil because
diff --git a/chanbackup/backupfile_test.go b/chanbackup/backupfile_test.go
index e97d4ce..11d66e1 100644
--- a/chanbackup/backupfile_test.go
+++ b/chanbackup/backupfile_test.go
@@ -431,7 +431,6 @@ func TestCreateArchiveFile(t *testing.T) {
}
for _, tc := range tests {
- tc := tc
t.Run(tc.name, func(t *testing.T) {
defer os.RemoveAll(archiveDir)
if tc.setup != nil {
diff --git a/chanfitness/chanevent_test.go b/chanfitness/chanevent_test.go
index 43046db..8d1cc54 100644
--- a/chanfitness/chanevent_test.go
+++ b/chanfitness/chanevent_test.go
@@ -388,7 +388,6 @@ func TestGetOnlinePeriod(t *testing.T) {
}
for _, test := range tests {
- test := test
t.Run(test.name, func(t *testing.T) {
t.Parallel()
@@ -545,7 +544,6 @@ func TestUptime(t *testing.T) {
}
for _, test := range tests {
- test := test
t.Run(test.name, func(t *testing.T) {
score := &peerLog{
diff --git a/chanfitness/chaneventstore_test.go b/chanfitness/chaneventstore_test.go
index ecec3ea..f14eba1 100644
--- a/chanfitness/chaneventstore_test.go
+++ b/chanfitness/chaneventstore_test.go
@@ -57,7 +57,6 @@ func TestStartStoreError(t *testing.T) {
}
for _, test := range tests {
- test := test
t.Run(test.name, func(t *testing.T) {
clock := clock.NewTestClock(testNow)
diff --git a/chanfitness/rate_limit_test.go b/chanfitness/rate_limit_test.go
index b9bca80..6e5ebf9 100644
--- a/chanfitness/rate_limit_test.go
+++ b/chanfitness/rate_limit_test.go
@@ -39,7 +39,6 @@ func TestGetRateLimit(t *testing.T) {
}
for _, test := range tests {
- test := test
t.Run(test.name, func(t *testing.T) {
t.Parallel()
@@ -91,7 +90,6 @@ func TestCooldownFlapCount(t *testing.T) {
}
for _, test := range tests {
- test := test
t.Run(test.name, func(t *testing.T) {
t.Parallel()
diff --git a/channeldb/channel_test.go b/channeldb/channel_test.go
index 7039abe..5b8758e 100644
--- a/channeldb/channel_test.go
+++ b/channeldb/channel_test.go
@@ -566,7 +566,6 @@ func TestOptionalShutdown(t *testing.T) {
}
for _, test := range tests {
- test := test
t.Run(test.name, func(t *testing.T) {
fullDB, err := MakeTestDB(t)
@@ -1325,7 +1324,6 @@ func TestShutdownInfo(t *testing.T) {
}
for _, test := range tests {
- test := test
t.Run(test.name, func(t *testing.T) {
t.Parallel()
@@ -1513,7 +1511,6 @@ func TestCloseInitiator(t *testing.T) {
}
for _, test := range tests {
- test := test
t.Run(test.name, func(t *testing.T) {
t.Parallel()
@@ -1634,7 +1631,6 @@ func TestHasChanStatus(t *testing.T) {
}
for _, test := range tests {
- test := test
t.Run(test.name, func(t *testing.T) {
c := &OpenChannel{
@@ -1817,7 +1813,6 @@ func TestHTLCsExtraData(t *testing.T) {
}
for _, testCase := range testCases {
- testCase := testCase
t.Run(testCase.name, func(t *testing.T) {
t.Parallel()
diff --git a/channeldb/db_test.go b/channeldb/db_test.go
index 27428a6..c41b8e1 100644
--- a/channeldb/db_test.go
+++ b/channeldb/db_test.go
@@ -594,7 +594,6 @@ func TestFetchChannels(t *testing.T) {
}
for _, test := range tests {
- test := test
t.Run(test.name, func(t *testing.T) {
t.Parallel()
diff --git a/channeldb/migration/create_tlb_test.go b/channeldb/migration/create_tlb_test.go
index 164e8f2..3117165 100644
--- a/channeldb/migration/create_tlb_test.go
+++ b/channeldb/migration/create_tlb_test.go
@@ -37,7 +37,6 @@ func TestCreateTLB(t *testing.T) {
}
for _, test := range tests {
- test := test
t.Run(test.name, func(t *testing.T) {
migtest.ApplyMigration(
t,
diff --git a/channeldb/migration12/migration_test.go b/channeldb/migration12/migration_test.go
index 75d74fd..7baae64 100644
--- a/channeldb/migration12/migration_test.go
+++ b/channeldb/migration12/migration_test.go
@@ -192,7 +192,6 @@ func genAfterMigration(afterBytes []byte) func(kvdb.RwTx) error {
// final struct, but verifies that the field is properly removed.
func TestTLVInvoiceMigration(t *testing.T) {
for _, test := range migrationTests {
- test := test
t.Run(test.name, func(t *testing.T) {
migtest.ApplyMigration(
t,
diff --git a/channeldb/migration16/migration_test.go b/channeldb/migration16/migration_test.go
index dc2d017..7fb5546 100644
--- a/channeldb/migration16/migration_test.go
+++ b/channeldb/migration16/migration_test.go
@@ -105,7 +105,6 @@ func TestMigrateSequenceIndex(t *testing.T) {
}
for _, test := range tests {
- test := test
t.Run(test.name, func(t *testing.T) {
// Before the migration we have a payments bucket.
diff --git a/channeldb/migration23/migration_test.go b/channeldb/migration23/migration_test.go
index 350c4cc..c2dbdfd 100644
--- a/channeldb/migration23/migration_test.go
+++ b/channeldb/migration23/migration_test.go
@@ -155,7 +155,6 @@ func TestMigrateHtlcAttempts(t *testing.T) {
}
for _, test := range tests {
- test := test
migtest.ApplyMigration(
t,
diff --git a/channeldb/migration25/migration_test.go b/channeldb/migration25/migration_test.go
index 6098e44..4c67c07 100644
--- a/channeldb/migration25/migration_test.go
+++ b/channeldb/migration25/migration_test.go
@@ -229,7 +229,6 @@ func TestMigrateInitialBalances(t *testing.T) {
}
for _, tc := range testCases {
- tc := tc
t.Run(tc.name, func(t *testing.T) {
migtest.ApplyMigration(
t,
diff --git a/channeldb/migration26/migration_test.go b/channeldb/migration26/migration_test.go
index a775386..dd1247d 100644
--- a/channeldb/migration26/migration_test.go
+++ b/channeldb/migration26/migration_test.go
@@ -85,7 +85,6 @@ func TestMigrateBalancesToTlvRecords(t *testing.T) {
}
for _, tc := range testCases {
- tc := tc
// Before running the test, set the balance fields based on the
// test params.
diff --git a/channeldb/migration27/migration_test.go b/channeldb/migration27/migration_test.go
index f2005ed..d8d769d 100644
--- a/channeldb/migration27/migration_test.go
+++ b/channeldb/migration27/migration_test.go
@@ -97,7 +97,6 @@ func TestMigrateHistoricalBalances(t *testing.T) {
}
for _, tc := range testCases {
- tc := tc
// testChannel is used to test the balance fields are correctly
// set.
diff --git a/channeldb/migration30/iterator_test.go b/channeldb/migration30/iterator_test.go
index 8d2206e..de654a0 100644
--- a/channeldb/migration30/iterator_test.go
+++ b/channeldb/migration30/iterator_test.go
@@ -123,7 +123,6 @@ func TestLocateChanBucket(t *testing.T) {
}
for _, tc := range testCases {
- tc := tc
t.Run(tc.name, func(t *testing.T) {
err := testLocator(tc.locator)
require.Equal(t, tc.expectedErr, err)
@@ -283,7 +282,6 @@ func TestFindNextMigrateHeight(t *testing.T) {
}
for _, tc := range testCases {
- tc := tc
t.Run(tc.name, func(t *testing.T) {
// Create a test channel.
c := createTestChannel(nil)
@@ -658,7 +656,6 @@ func TestLocalNextUpdateNum(t *testing.T) {
cdb, err := migtest.MakeDB(t)
require.NoError(t, err)
- tc := tc
t.Run(tc.name, func(t *testing.T) {
// Setup the test case.
c, height := tc.setup(cdb)
diff --git a/channeldb/migration30/migration_test.go b/channeldb/migration30/migration_test.go
index 0177329..9202d91 100644
--- a/channeldb/migration30/migration_test.go
+++ b/channeldb/migration30/migration_test.go
@@ -78,7 +78,6 @@ func TestMigrateRevocationLog(t *testing.T) {
fmt.Printf("withAmtData is set to: %v\n", withAmtData)
for i, tc := range testCases {
- tc := tc
// Construct a test case name that can be easily traced.
name := fmt.Sprintf("case_%d", i)
@@ -169,7 +168,6 @@ func TestValidateMigration(t *testing.T) {
}
for _, tc := range testCases {
- tc := tc
// Create a test db.
cdb, err := migtest.MakeDB(t)
diff --git a/channeldb/migration35/migration_test.go b/channeldb/migration35/migration_test.go
index 685f575..1d30c3f 100644
--- a/channeldb/migration35/migration_test.go
+++ b/channeldb/migration35/migration_test.go
@@ -186,8 +186,6 @@ func TestMigrateWaitingProofStore(t *testing.T) {
}
for _, tc := range testCases {
- tc := tc
-
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
diff --git a/channeldb/reports_test.go b/channeldb/reports_test.go
index 1148fdf..6f0c21c 100644
--- a/channeldb/reports_test.go
+++ b/channeldb/reports_test.go
@@ -46,7 +46,6 @@ func TestPersistReport(t *testing.T) {
}
for _, test := range tests {
- test := test
t.Run(test.name, func(t *testing.T) {
db, err := MakeTestDB(t)
@@ -193,7 +192,6 @@ func TestFetchChannelWriteBucket(t *testing.T) {
}
for _, test := range tests {
- test := test
t.Run(test.name, func(t *testing.T) {
db, err := MakeTestDB(t)
diff --git a/channeldb/revocation_log_test.go b/channeldb/revocation_log_test.go
index 6e7afb9..347e86e 100644
--- a/channeldb/revocation_log_test.go
+++ b/channeldb/revocation_log_test.go
@@ -341,7 +341,6 @@ func TestSerializeAndDeserializeRevLog(t *testing.T) {
}
for _, test := range tests {
- test := test
t.Run(test.name, func(t *testing.T) {
t.Parallel()
@@ -586,7 +585,6 @@ func TestPutRevocationLog(t *testing.T) {
}
for _, tc := range testCases {
- tc := tc
fullDB, err := MakeTestDB(t)
require.NoError(t, err)
@@ -686,7 +684,6 @@ func TestFetchRevocationLogCompatible(t *testing.T) {
}
for _, tc := range testCases {
- tc := tc
fullDB, err := MakeTestDB(t)
require.NoError(t, err)
diff --git a/channeldb/waitingproof_test.go b/channeldb/waitingproof_test.go
index 4b0e444..ad04369 100644
--- a/channeldb/waitingproof_test.go
+++ b/channeldb/waitingproof_test.go
@@ -129,8 +129,6 @@ func TestWaitingProofV2RoundTrip(t *testing.T) {
}
for _, tc := range testCases {
- tc := tc
-
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
diff --git a/config_onion_ratelimit_test.go b/config_onion_ratelimit_test.go
index b97a757..3ac6bd5 100644
--- a/config_onion_ratelimit_test.go
+++ b/config_onion_ratelimit_test.go
@@ -73,7 +73,6 @@ func TestValidateOnionMsgLimiter(t *testing.T) {
},
}
for _, tc := range cases {
- tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
err := validateOnionMsgLimiter(
diff --git a/contractcourt/chain_watcher_coop_reorg_test.go b/contractcourt/chain_watcher_coop_reorg_test.go
index 0e0a552..a97c00e 100644
--- a/contractcourt/chain_watcher_coop_reorg_test.go
+++ b/contractcourt/chain_watcher_coop_reorg_test.go
@@ -132,7 +132,6 @@ func TestChainWatcherCoopCloseScaledConfirmationsWithReorg(t *testing.T) {
}
for _, tc := range testCases {
- tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
diff --git a/contractcourt/chain_watcher_test.go b/contractcourt/chain_watcher_test.go
index 8275886..c7287d3 100644
--- a/contractcourt/chain_watcher_test.go
+++ b/contractcourt/chain_watcher_test.go
@@ -499,7 +499,6 @@ func TestChainWatcherDataLossProtect(t *testing.T) {
testName := fmt.Sprintf("num_updates=%v,broadcast_state_num=%v",
testCase.NumUpdates, testCase.BroadcastStateNum)
- testCase := testCase
t.Run(testName, func(t *testing.T) {
t.Parallel()
@@ -724,7 +723,6 @@ func TestChainWatcherLocalForceCloseDetect(t *testing.T) {
testCase.localOutputOnly,
)
- testCase := testCase
t.Run(testName, func(t *testing.T) {
t.Parallel()
diff --git a/contractcourt/channel_arbitrator_test.go b/contractcourt/channel_arbitrator_test.go
index 37b9310..0e08d2c 100644
--- a/contractcourt/channel_arbitrator_test.go
+++ b/contractcourt/channel_arbitrator_test.go
@@ -1678,7 +1678,6 @@ func TestChannelArbitratorCommitFailure(t *testing.T) {
}
for _, test := range testCases {
- test := test
log := &mockArbitratorLog{
state: StateDefault,
@@ -1889,7 +1888,6 @@ func TestChannelArbitratorDanglingCommitForceClose(t *testing.T) {
}
for _, testCase := range testCases {
- testCase := testCase
testName := fmt.Sprintf("testCase: htlcExpired=%v,"+
"remotePendingHTLC=%v,remotePendingCommitConf=%v",
testCase.htlcExpired, testCase.remotePendingHTLC,
@@ -2214,7 +2212,6 @@ func TestRemoteCloseInitiator(t *testing.T) {
}
for _, test := range tests {
- test := test
t.Run(test.name, func(t *testing.T) {
t.Parallel()
@@ -2479,7 +2476,6 @@ func TestFindCommitmentDeadlineAndValue(t *testing.T) {
}
for _, tc := range testCases {
- tc := tc
t.Run(tc.name, func(t *testing.T) {
// Mock the method `FindOutgoingHTLCDeadline`.
tc.mockFindOutgoingHTLCDeadline()
@@ -3074,7 +3070,6 @@ func TestChannelArbitratorStartForceCloseFail(t *testing.T) {
}
for _, test := range tests {
- test := test
t.Run(test.name, func(t *testing.T) {
t.Parallel()
diff --git a/contractcourt/commit_sweep_resolver_test.go b/contractcourt/commit_sweep_resolver_test.go
index 5c660e1..eb00b3d 100644
--- a/contractcourt/commit_sweep_resolver_test.go
+++ b/contractcourt/commit_sweep_resolver_test.go
@@ -348,7 +348,6 @@ func TestCommitSweepResolverDelay(t *testing.T) {
}}
for _, tc := range testCases {
- tc := tc
ok := t.Run(tc.name, func(t *testing.T) {
testCommitSweepResolverDelay(t, tc.sweepErr)
})
diff --git a/contractcourt/htlc_timeout_resolver_test.go b/contractcourt/htlc_timeout_resolver_test.go
index e97af28..86ebede 100644
--- a/contractcourt/htlc_timeout_resolver_test.go
+++ b/contractcourt/htlc_timeout_resolver_test.go
@@ -1488,7 +1488,6 @@ func TestCheckSizeAndIndex(t *testing.T) {
}
for _, tc := range testCases {
- tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
@@ -1558,7 +1557,6 @@ func TestIsPreimageSpend(t *testing.T) {
}
for _, tc := range testCases {
- tc := tc
// Run the test.
t.Run(tc.name, func(t *testing.T) {
diff --git a/contractcourt/utxonursery_test.go b/contractcourt/utxonursery_test.go
index f9dd302..a99eb7e 100644
--- a/contractcourt/utxonursery_test.go
+++ b/contractcourt/utxonursery_test.go
@@ -687,7 +687,6 @@ func TestRejectedCribTransaction(t *testing.T) {
}
for _, test := range tests {
- test := test
t.Run(test.name, func(t *testing.T) {
t.Parallel()
@@ -1386,8 +1385,6 @@ func TestPatchZeroHeightHint(t *testing.T) {
}
for _, tc := range tests {
- tc := tc
-
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
diff --git a/discovery/gossiper_test.go b/discovery/gossiper_test.go
index 1995326..d6fe209 100644
--- a/discovery/gossiper_test.go
+++ b/discovery/gossiper_test.go
@@ -222,14 +222,12 @@ func (r *mockGraphSource) ForAllOutgoingChannels(_ context.Context,
chans := make(map[uint64]graphdb.ChannelEdge)
for _, info := range r.infos {
- info := info
edgeInfo := chans[info.ChannelID]
edgeInfo.Info = &info
chans[info.ChannelID] = edgeInfo
}
for _, edges := range r.edges {
- edges := edges
edge := chans[edges[0].ChannelID]
edge.Policy1 = &edges[0]
diff --git a/discovery/syncer_test.go b/discovery/syncer_test.go
index 1fd0072..f27ba7b 100644
--- a/discovery/syncer_test.go
+++ b/discovery/syncer_test.go
@@ -2296,7 +2296,6 @@ func TestGossipSyncerSyncTransitions(t *testing.T) {
}
for _, test := range tests {
- test := test
t.Run(test.name, func(t *testing.T) {
t.Parallel()
@@ -2626,7 +2625,6 @@ func TestGossipSyncerStateHandlerErrors(t *testing.T) {
}
for _, tt := range tests {
- tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
diff --git a/feature/deps_test.go b/feature/deps_test.go
index 9b6b02f..34766eb 100644
--- a/feature/deps_test.go
+++ b/feature/deps_test.go
@@ -150,7 +150,6 @@ var depTests = []depTest{
// dependencies.
func TestValidateDeps(t *testing.T) {
for _, test := range depTests {
- test := test
t.Run(test.name, func(t *testing.T) {
testValidateDeps(t, test)
})
diff --git a/feature/manager_internal_test.go b/feature/manager_internal_test.go
index 683b4df..c110fc7 100644
--- a/feature/manager_internal_test.go
+++ b/feature/manager_internal_test.go
@@ -65,7 +65,6 @@ var managerTests = []managerTest{
// including that the proper features are removed in response to config changes.
func TestManager(t *testing.T) {
for _, test := range managerTests {
- test := test
t.Run(test.name, func(t *testing.T) {
testManager(t, test)
})
@@ -260,7 +259,6 @@ func TestUpdateFeatureSets(t *testing.T) {
}
for _, testCase := range testCases {
- testCase := testCase
t.Run(testCase.name, func(t *testing.T) {
t.Parallel()
diff --git a/funding/batch_test.go b/funding/batch_test.go
index 7a674d6..ee74082 100644
--- a/funding/batch_test.go
+++ b/funding/batch_test.go
@@ -343,7 +343,6 @@ func TestBatchFund(t *testing.T) {
}}
for _, tc := range testCases {
- tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
diff --git a/funding/commitment_type_negotiation_test.go b/funding/commitment_type_negotiation_test.go
index 48b1a62..75907df 100644
--- a/funding/commitment_type_negotiation_test.go
+++ b/funding/commitment_type_negotiation_test.go
@@ -499,7 +499,6 @@ func TestCommitmentTypeNegotiation(t *testing.T) {
}
for _, testCase := range testCases {
- testCase := testCase
ok := t.Run(testCase.name, func(t *testing.T) {
localFeatures := lnwire.NewFeatureVector(
testCase.localFeatures, lnwire.Features,
diff --git a/funding/manager_test.go b/funding/manager_test.go
index 4220912..b4581ce 100644
--- a/funding/manager_test.go
+++ b/funding/manager_test.go
@@ -3609,7 +3609,6 @@ func TestFundingManagerInvalidChanReserve(t *testing.T) {
}
for _, test := range tests {
- test := test
t.Run(test.name, func(t *testing.T) {
t.Parallel()
@@ -4355,7 +4354,6 @@ func TestFundingManagerFundMax(t *testing.T) {
}
for _, test := range tests {
- test := test
t.Run(test.name, func(t *testing.T) {
t.Parallel()
@@ -4464,7 +4462,6 @@ func TestGetUpfrontShutdownScript(t *testing.T) {
}
for _, test := range tests {
- test := test
t.Run(test.name, func(t *testing.T) {
var mockPeer testNode
@@ -4742,7 +4739,6 @@ func TestFundingManagerUpfrontShutdown(t *testing.T) {
}
for _, test := range tests {
- test := test
t.Run(test.name, func(t *testing.T) {
testUpfrontFailure(t, test.pkscript, test.expectErr)
diff --git a/graph/builder_test.go b/graph/builder_test.go
index 5b62439..3d5cf8e 100644
--- a/graph/builder_test.go
+++ b/graph/builder_test.go
@@ -1106,8 +1106,6 @@ func TestIsZombieChannel(t *testing.T) {
}
for _, test := range tests {
- test := test
-
t.Run(test.name, func(t *testing.T) {
t.Parallel()
diff --git a/graph/db/graph_test.go b/graph/db/graph_test.go
index 3d0156f..e524f0b 100644
--- a/graph/db/graph_test.go
+++ b/graph/db/graph_test.go
@@ -252,8 +252,6 @@ func TestVersionedDBs(t *testing.T) {
// Run all v1 tests.
for _, vt := range versionedTests {
- vt := vt
-
t.Run(vt.name+"/v1", func(t *testing.T) {
vt.test(t, lnwire.GossipVersion1)
})
@@ -1954,7 +1952,6 @@ func TestGraphCacheTraversal(t *testing.T) {
// properly been reached.
numNodeChans := 0
for _, node := range nodeList {
- node := node
err := graph.ForEachNodeDirectedChannel(
ctx, node.PubKeyBytes, func(d *DirectedChannel) error {
@@ -4142,7 +4139,6 @@ func TestStressTestChannelGraphAPI(t *testing.T) {
)
for i := 0; i < concurrencyLevel; i++ {
- i := i
t.Run(fmt.Sprintf("%d", i), func(t *testing.T) {
t.Parallel()
@@ -4347,7 +4343,6 @@ func TestFilterChannelRange(t *testing.T) {
}
for _, test := range tests {
- test := test
t.Run(test.name, func(t *testing.T) {
t.Parallel()
diff --git a/htlcswitch/hop/iterator_test.go b/htlcswitch/hop/iterator_test.go
index ab435a9..e3d1efd 100644
--- a/htlcswitch/hop/iterator_test.go
+++ b/htlcswitch/hop/iterator_test.go
@@ -139,7 +139,6 @@ func TestForwardingAmountCalc(t *testing.T) {
}
for _, testCase := range tests {
- testCase := testCase
t.Run(testCase.name, func(t *testing.T) {
t.Parallel()
diff --git a/htlcswitch/hop/payload_test.go b/htlcswitch/hop/payload_test.go
index bd0081c..7b3e568 100644
--- a/htlcswitch/hop/payload_test.go
+++ b/htlcswitch/hop/payload_test.go
@@ -758,7 +758,6 @@ func TestValidateBlindedRouteData(t *testing.T) {
}
for _, testCase := range tests {
- testCase := testCase
t.Run(testCase.name, func(t *testing.T) {
err := hop.ValidateBlindedRouteData(
diff --git a/htlcswitch/link_test.go b/htlcswitch/link_test.go
index 29b4f90..6a518cb 100644
--- a/htlcswitch/link_test.go
+++ b/htlcswitch/link_test.go
@@ -922,7 +922,6 @@ func TestChannelLinkCancelFullCommitment(t *testing.T) {
// Now, settle all htlcs held by bob and clear the commitment of htlcs.
for _, preimage := range preimages {
- preimage := preimage
// It's possible that the HTLCs have not been delivered to the
// invoice registry at this point, so we poll until we are able
diff --git a/htlcswitch/switch_test.go b/htlcswitch/switch_test.go
index e8176aa..9dfe22e 100644
--- a/htlcswitch/switch_test.go
+++ b/htlcswitch/switch_test.go
@@ -441,7 +441,6 @@ func TestSwitchForwardMapping(t *testing.T) {
}
for _, test := range tests {
- test := test
t.Run(test.name, func(t *testing.T) {
t.Parallel()
testSwitchForwardMapping(
@@ -661,7 +660,6 @@ func TestSwitchSendHTLCMapping(t *testing.T) {
}
for _, test := range tests {
- test := test
t.Run(test.name, func(t *testing.T) {
t.Parallel()
testSwitchSendHtlcMapping(
@@ -1917,7 +1915,6 @@ func TestCircularForwards(t *testing.T) {
}
for _, test := range tests {
- test := test
t.Run(test.name, func(t *testing.T) {
t.Parallel()
@@ -2099,7 +2096,6 @@ func TestCheckCircularForward(t *testing.T) {
}
for _, test := range tests {
- test := test
t.Run(test.name, func(t *testing.T) {
t.Parallel()
@@ -2183,7 +2179,6 @@ func TestSkipIneligibleLinksMultiHopForward(t *testing.T) {
}
for _, test := range tests {
- test := test
t.Run(test.name, func(t *testing.T) {
testSkipIneligibleLinksMultiHopForward(t, &test)
})
@@ -3371,7 +3366,6 @@ func TestHtlcNotifier(t *testing.T) {
}
for _, test := range tests {
- test := test
t.Run(test.name, func(t *testing.T) {
testHtcNotifier(
@@ -4864,7 +4858,6 @@ func TestSwitchForwardFailAlias(t *testing.T) {
}
for _, test := range tests {
- test := test
t.Run(test.name, func(t *testing.T) {
testSwitchForwardFailAlias(t, test.zeroConf)
@@ -5074,7 +5067,6 @@ func TestSwitchAliasFailAdd(t *testing.T) {
}
for _, test := range tests {
- test := test
t.Run(test.name, func(t *testing.T) {
testSwitchAliasFailAdd(
@@ -5263,7 +5255,6 @@ func TestSwitchHandlePacketForward(t *testing.T) {
}
for _, test := range tests {
- test := test
t.Run(test.name, func(t *testing.T) {
testSwitchHandlePacketForward(
@@ -5420,7 +5411,6 @@ func TestSwitchAliasInterceptFail(t *testing.T) {
}
for _, test := range tests {
- test := test
t.Run(test.name, func(t *testing.T) {
testSwitchAliasInterceptFail(t, test.zeroConf)
diff --git a/input/musig2_test.go b/input/musig2_test.go
index 1fccd16..dea5d3d 100644
--- a/input/musig2_test.go
+++ b/input/musig2_test.go
@@ -178,7 +178,6 @@ func TestMuSig2CombineKeys(t *testing.T) {
}}
for _, tc := range testCases {
- tc := tc
t.Run(tc.name, func(tt *testing.T) {
tt.Parallel()
diff --git a/input/size_test.go b/input/size_test.go
index 88a66c7..b0531b1 100644
--- a/input/size_test.go
+++ b/input/size_test.go
@@ -1579,7 +1579,6 @@ var witnessSizeTests = []witnessSizeTest{
// aren't under estimating or our transactions could get stuck.
func TestWitnessSizes(t *testing.T) {
for _, test := range witnessSizeTests {
- test := test
t.Run(test.name, func(t *testing.T) {
size := test.genWitness(t).SerializeSize()
if size != test.expSize {
@@ -1793,7 +1792,6 @@ var txSizeTests = []txSizeTest{
// TestTxSizes asserts the correctness of our magic tx size constants.
func TestTxSizes(t *testing.T) {
for _, test := range txSizeTests {
- test := test
t.Run(test.name, func(t *testing.T) {
tx := test.genTx(t)
diff --git a/input/taproot_test.go b/input/taproot_test.go
index 7defa9e..8405092 100644
--- a/input/taproot_test.go
+++ b/input/taproot_test.go
@@ -388,8 +388,6 @@ func testTaprootSenderHtlcSpend(t *testing.T, auxLeaf AuxTapLeaf,
}
for i, testCase := range testCases {
- i := i
- testCase := testCase
spendTxCopy := spendTx.Copy()
@@ -883,8 +881,6 @@ func testTaprootReceiverHtlcSpend(t *testing.T, auxLeaf AuxTapLeaf,
},
}
for i, testCase := range testCases {
- i := i
- testCase := testCase
spendTxCopy := spendTx.Copy()
t.Run(testCase.name, func(t *testing.T) {
@@ -1225,8 +1221,6 @@ func testTaprootCommitScriptToSelf(t *testing.T, auxLeaf AuxTapLeaf,
}
for i, testCase := range testCases {
- i := i
- testCase := testCase
spendTxCopy := spendTx.Copy()
t.Run(testCase.name, func(t *testing.T) {
@@ -1439,8 +1433,6 @@ func testTaprootCommitScriptRemote(t *testing.T, auxLeaf AuxTapLeaf,
}
for i, testCase := range testCases {
- i := i
- testCase := testCase
spendTxCopy := spendTx.Copy()
t.Run(testCase.name, func(t *testing.T) {
@@ -1695,8 +1687,6 @@ func TestTaprootAnchorScript(t *testing.T) {
}
for i, testCase := range testCases {
- i := i
- testCase := testCase
spendTxCopy := spendTx.Copy()
t.Run(testCase.name, func(t *testing.T) {
@@ -1984,8 +1974,6 @@ func testTaprootSecondLevelHtlcScript(t *testing.T, auxLeaf AuxTapLeaf,
}
for i, testCase := range testCases {
- i := i
- testCase := testCase
spendTxCopy := spendTx.Copy()
t.Run(testCase.name, func(t *testing.T) {
diff --git a/internal/musig2v040/musig2_test.go b/internal/musig2v040/musig2_test.go
index 42e84c7..a563176 100644
--- a/internal/musig2v040/musig2_test.go
+++ b/internal/musig2v040/musig2_test.go
@@ -1048,7 +1048,6 @@ func testMultiPartySign(t *testing.T, taprootTweak []byte,
// signer.
var wg sync.WaitGroup
for i, signCtx := range signers {
- signCtx := signCtx
wg.Add(1)
go func(idx int, signer *Session) {
diff --git a/invoices/invoiceregistry_test.go b/invoices/invoiceregistry_test.go
index 785da11..cad3e27 100644
--- a/invoices/invoiceregistry_test.go
+++ b/invoices/invoiceregistry_test.go
@@ -159,7 +159,6 @@ func TestInvoiceRegistry(t *testing.T) {
}
for _, test := range testList {
- test := test
t.Run(test.name+"_KV", func(t *testing.T) {
test.test(t, makeKeyValueDB)
@@ -1924,7 +1923,6 @@ func testSpontaneousAmpPayment(t *testing.T,
}
for _, test := range tests {
- test := test
t.Run(test.name, func(t *testing.T) {
testSpontaneousAmpPaymentImpl(
t, test.ampEnabled, test.failReconstruction,
diff --git a/invoices/invoices_test.go b/invoices/invoices_test.go
index 0f7e473..987292b 100644
--- a/invoices/invoices_test.go
+++ b/invoices/invoices_test.go
@@ -261,7 +261,6 @@ func TestInvoices(t *testing.T) {
}
for _, test := range testList {
- test := test
t.Run(test.name+"_KV", func(t *testing.T) {
test.test(t, makeKeyValueDB)
})
@@ -340,7 +339,6 @@ func testInvoiceWorkflow(t *testing.T,
t.Parallel()
for _, test := range invWorkflowTests {
- test := test
t.Run(test.name, func(t *testing.T) {
t.Parallel()
testInvoiceWorkflowImpl(t, test, makeDB)
@@ -2618,7 +2616,6 @@ func testUpdateHTLCPreimages(t *testing.T,
}
for _, test := range tests {
- test := test
t.Run(test.name, func(t *testing.T) {
t.Parallel()
testUpdateHTLCPreimagesImpl(t, test, makeDB)
diff --git a/invoices/kv_sql_migration_test.go b/invoices/kv_sql_migration_test.go
index 709a3c8..d14a63f 100644
--- a/invoices/kv_sql_migration_test.go
+++ b/invoices/kv_sql_migration_test.go
@@ -134,7 +134,6 @@ func TestMigrationWithChannelDB(t *testing.T) {
}
for _, test := range tests {
- test := test
t.Run(test.name, func(t *testing.T) {
var kvStore *channeldb.DB
diff --git a/invoices/update_invoice_test.go b/invoices/update_invoice_test.go
index 6069fbe..d6e4ed9 100644
--- a/invoices/update_invoice_test.go
+++ b/invoices/update_invoice_test.go
@@ -744,7 +744,6 @@ func TestUpdateHTLC(t *testing.T) {
}
for _, test := range tests {
- test := test
t.Run(test.name, func(t *testing.T) {
testUpdateHTLC(t, test, testNow)
})
diff --git a/itest/lnd_coop_close_rbf_test.go b/itest/lnd_coop_close_rbf_test.go
index f1acf02..f607e50 100644
--- a/itest/lnd_coop_close_rbf_test.go
+++ b/itest/lnd_coop_close_rbf_test.go
@@ -157,7 +157,6 @@ func testCoopCloseRbf(ht *lntest.HarnessTest) {
}
for _, chanType := range channelTypes {
- chanType := chanType
ht.Run(chanType.name, func(t1 *testing.T) {
st := ht.Subtest(t1)
// Set the fee estimate to 1sat/vbyte. This ensures that
diff --git a/itest/lnd_coop_close_with_htlcs_test.go b/itest/lnd_coop_close_with_htlcs_test.go
index 06d4dc9..b35b526 100644
--- a/itest/lnd_coop_close_with_htlcs_test.go
+++ b/itest/lnd_coop_close_with_htlcs_test.go
@@ -72,7 +72,6 @@ func testCoopCloseWithHtlcs(ht *lntest.HarnessTest) {
testCases := createFlagCombos()
for _, testCase := range testCases {
- testCase := testCase // Capture range variable.
ht.Run(testCase.testName, func(t *testing.T) {
tt := ht.Subtest(t)
@@ -94,7 +93,6 @@ func testCoopCloseWithHtlcsWithRestart(ht *lntest.HarnessTest) {
testCases := createFlagCombos()
for _, testCase := range testCases {
- testCase := testCase // Capture range variable.
ht.Run(testCase.testName, func(t *testing.T) {
tt := ht.Subtest(t)
diff --git a/itest/lnd_etcd_failover_test.go b/itest/lnd_etcd_failover_test.go
index 53b1dd6..3821229 100644
--- a/itest/lnd_etcd_failover_test.go
+++ b/itest/lnd_etcd_failover_test.go
@@ -47,7 +47,6 @@ func testEtcdFailover(ht *lntest.HarnessTest) {
}}
for _, test := range testCases {
- test := test
success := ht.Run(test.name, func(t1 *testing.T) {
st := ht.Subtest(t1)
diff --git a/itest/lnd_forward_delete_test.go b/itest/lnd_forward_delete_test.go
index d3a0a0b..678a0d7 100644
--- a/itest/lnd_forward_delete_test.go
+++ b/itest/lnd_forward_delete_test.go
@@ -43,7 +43,6 @@ func testDeleteForwardingHistory(ht *lntest.HarnessTest) {
}
for _, tc := range testCases {
- tc := tc
success := ht.Run(tc.name, func(t *testing.T) {
st := ht.Subtest(t)
tc.test(st)
diff --git a/itest/lnd_macaroons_test.go b/itest/lnd_macaroons_test.go
index 70c50c3..ddd48b1 100644
--- a/itest/lnd_macaroons_test.go
+++ b/itest/lnd_macaroons_test.go
@@ -391,7 +391,6 @@ func testMacaroonAuthentication(ht *lntest.HarnessTest) {
}}
for _, tc := range testCases {
- tc := tc
ht.Run(tc.name, func(tt *testing.T) {
ctxt, cancel := context.WithTimeout(
ht.Context(), defaultTimeout,
@@ -607,7 +606,6 @@ func testBakeMacaroon(ht *lntest.HarnessTest) {
}}
for _, tc := range testCases {
- tc := tc
ht.Run(tc.name, func(tt *testing.T) {
ctxt, cancel := context.WithTimeout(
ht.Context(), defaultTimeout,
diff --git a/itest/lnd_nonstd_sweep_test.go b/itest/lnd_nonstd_sweep_test.go
index 47725f1..ca596d1 100644
--- a/itest/lnd_nonstd_sweep_test.go
+++ b/itest/lnd_nonstd_sweep_test.go
@@ -62,7 +62,6 @@ func testNonstdSweep(ht *lntest.HarnessTest) {
}
for _, test := range tests {
- test := test
success := ht.Run(test.name, func(t *testing.T) {
st := ht.Subtest(t)
diff --git a/itest/lnd_rest_api_test.go b/itest/lnd_rest_api_test.go
index 70e1032..5ec4823 100644
--- a/itest/lnd_rest_api_test.go
+++ b/itest/lnd_rest_api_test.go
@@ -221,14 +221,12 @@ func testRestAPI(ht *lntest.HarnessTest) {
alice := ht.NewNodeWithCoins("Alice", args)
for _, tc := range testCases {
- tc := tc
ht.Run(tc.name, func(t *testing.T) {
tc.run(t, alice, bob)
})
}
for _, tc := range wsTestCases {
- tc := tc
ht.Run(tc.name, func(t *testing.T) {
st := ht.Subtest(t)
tc.run(st)
diff --git a/itest/lnd_rpc_middleware_interceptor_test.go b/itest/lnd_rpc_middleware_interceptor_test.go
index e0409af..3a82e5a 100644
--- a/itest/lnd_rpc_middleware_interceptor_test.go
+++ b/itest/lnd_rpc_middleware_interceptor_test.go
@@ -205,7 +205,6 @@ func middlewareRegistrationRestrictionTests(t *testing.T,
}}
for idx, tc := range testCases {
- tc := tc
t.Run(fmt.Sprintf("%d", idx), func(tt *testing.T) {
invalidName := registerMiddleware(
diff --git a/itest/lnd_test.go b/itest/lnd_test.go
index c073cb5..e6b25b6 100644
--- a/itest/lnd_test.go
+++ b/itest/lnd_test.go
@@ -128,7 +128,6 @@ func TestLightningNetworkDaemon(t *testing.T) {
// Run the subset of the test cases selected in this tranche.
for idx, testCase := range testCases {
- testCase := testCase
name := fmt.Sprintf("tranche%02d/%02d-of-%d/%s/%s",
trancheIndex, trancheOffset+uint(idx)+1,
len(allTestCases), harnessTest.ChainBackendName(),
diff --git a/itest/lnd_wallet_import_test.go b/itest/lnd_wallet_import_test.go
index 4a08fb2..39774ba 100644
--- a/itest/lnd_wallet_import_test.go
+++ b/itest/lnd_wallet_import_test.go
@@ -646,7 +646,6 @@ func testWalletImportPubKey(ht *lntest.HarnessTest) {
}
for _, tc := range testCases {
- tc := tc
success := ht.Run(tc.name, func(tt *testing.T) {
testFunc := func(ht *lntest.HarnessTest) {
testWalletImportPubKeyScenario(
diff --git a/itest/lnd_zero_conf_test.go b/itest/lnd_zero_conf_test.go
index ac82ba0..84602ec 100644
--- a/itest/lnd_zero_conf_test.go
+++ b/itest/lnd_zero_conf_test.go
@@ -281,7 +281,6 @@ func testOptionScidAlias(ht *lntest.HarnessTest) {
}
for _, testCase := range testCases {
- testCase := testCase
success := ht.Run(testCase.name, func(t *testing.T) {
st := ht.Subtest(t)
optionScidAliasScenario(
diff --git a/lnencrypt/crypto_test.go b/lnencrypt/crypto_test.go
index 42ebe1c..dfe224f 100644
--- a/lnencrypt/crypto_test.go
+++ b/lnencrypt/crypto_test.go
@@ -66,9 +66,7 @@ func TestEncryptDecryptPayload(t *testing.T) {
require.NoError(t, err)
for _, payloadCase := range payloadCases {
- payloadCase := payloadCase
for _, enc := range []*Encrypter{keyRingEnc, privKeyEnc} {
- enc := enc
// First, we'll encrypt the passed payload with our
// scheme.
diff --git a/lnrpc/invoicesrpc/addinvoice_test.go b/lnrpc/invoicesrpc/addinvoice_test.go
index 104b287..41ab63e 100644
--- a/lnrpc/invoicesrpc/addinvoice_test.go
+++ b/lnrpc/invoicesrpc/addinvoice_test.go
@@ -448,7 +448,6 @@ var shouldIncludeChannelTestCases = []struct {
func TestShouldIncludeChannel(t *testing.T) {
for _, tc := range shouldIncludeChannelTestCases {
- tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
@@ -514,7 +513,6 @@ var sufficientHintsTestCases = []struct {
func TestSufficientHints(t *testing.T) {
for _, tc := range sufficientHintsTestCases {
- tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
@@ -881,7 +879,6 @@ func setupMockTwoChannels(h *hopHintsConfigMock) (lnwire.ChannelID,
func TestPopulateHopHints(t *testing.T) {
for _, tc := range populateHopHintsTestCases {
- tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
diff --git a/lnrpc/routerrpc/parse_duration_test.go b/lnrpc/routerrpc/parse_duration_test.go
index d36c8be..66c8c3b 100644
--- a/lnrpc/routerrpc/parse_duration_test.go
+++ b/lnrpc/routerrpc/parse_duration_test.go
@@ -128,7 +128,6 @@ func TestParseDuration(t *testing.T) {
}
for _, tt := range tests {
- tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
diff --git a/lnrpc/routerrpc/router_backend_test.go b/lnrpc/routerrpc/router_backend_test.go
index d4ff224..b494ffb 100644
--- a/lnrpc/routerrpc/router_backend_test.go
+++ b/lnrpc/routerrpc/router_backend_test.go
@@ -337,7 +337,6 @@ func TestUnmarshalMPP(t *testing.T) {
}
for _, test := range tests {
- test := test
t.Run(test.name, func(t *testing.T) {
testUnmarshalMPP(t, test)
})
@@ -447,7 +446,6 @@ func TestUnmarshalAMP(t *testing.T) {
}
for _, test := range tests {
- test := test
t.Run(test.name, func(t *testing.T) {
testUnmarshalAMP(t, test)
})
diff --git a/lnrpc/walletrpc/walletkit_server_test.go b/lnrpc/walletrpc/walletkit_server_test.go
index 40fb62e..041a9d1 100644
--- a/lnrpc/walletrpc/walletkit_server_test.go
+++ b/lnrpc/walletrpc/walletkit_server_test.go
@@ -43,8 +43,6 @@ func TestWitnessTypeMapping(t *testing.T) {
for witnessType, witnessTypeProto := range allWitnessTypes {
// Redeclare to avoid loop variables being captured
// by func literal.
- witnessType := witnessType
- witnessTypeProto := witnessTypeProto
t.Run(witnessType.String(), func(tt *testing.T) {
tt.Parallel()
@@ -629,7 +627,6 @@ func TestFundPsbtCoinSelect(t *testing.T) {
}}
for _, tc := range testCases {
- tc := tc
privKey, err := btcec.NewPrivateKey()
require.NoError(t, err)
diff --git a/lnrpc/walletrpc/walletkit_util_test.go b/lnrpc/walletrpc/walletkit_util_test.go
index fdc8d2e..097c513 100644
--- a/lnrpc/walletrpc/walletkit_util_test.go
+++ b/lnrpc/walletrpc/walletkit_util_test.go
@@ -55,7 +55,6 @@ func TestParseDerivationPath(t *testing.T) {
}}
for _, tc := range testCases {
- tc := tc
t.Run(tc.name, func(tt *testing.T) {
result, err := parseDerivationPath(tc.path)
diff --git a/lnutils/fs_test.go b/lnutils/fs_test.go
index 3e96d4f..c232504 100644
--- a/lnutils/fs_test.go
+++ b/lnutils/fs_test.go
@@ -66,7 +66,6 @@ func TestCreateDir(t *testing.T) {
}
for _, tc := range tests {
- tc := tc
t.Run(tc.name, func(t *testing.T) {
dir := tc.setup()
defer os.RemoveAll(dir)
diff --git a/lnwallet/btcwallet/psbt_test.go b/lnwallet/btcwallet/psbt_test.go
index 694a8c0..4423be0 100644
--- a/lnwallet/btcwallet/psbt_test.go
+++ b/lnwallet/btcwallet/psbt_test.go
@@ -277,7 +277,6 @@ func TestSignPsbt(t *testing.T) {
}}
for _, tc := range testCases {
- tc := tc
// This is the private key we're going to sign with.
privKey, err := w.deriveKeyByBIP32Path(tc.inputType.keyPath())
@@ -465,7 +464,6 @@ func TestEstimateInputWeight(t *testing.T) {
input.WitnessHeaderSize
for _, tc := range testCases {
- tc := tc
t.Run(tc.name, func(tt *testing.T) {
estimator := input.TxWeightEstimator{}
@@ -551,7 +549,6 @@ func TestBip32DerivationFromKeyDesc(t *testing.T) {
}
for _, tc := range testCases {
- tc := tc
t.Run(tc.name, func(tt *testing.T) {
d, trD, path := Bip32DerivationFromKeyDesc(
@@ -607,7 +604,6 @@ func TestBip32DerivationFromAddress(t *testing.T) {
w, _ := newTestWallet(t, netParams, seedBytes)
for _, tc := range testCases {
- tc := tc
addr, err := w.NewAddress(
tc.addrType, false, lnwallet.DefaultAccountName,
diff --git a/lnwallet/btcwallet/signer_test.go b/lnwallet/btcwallet/signer_test.go
index 6f288c2..803296f 100644
--- a/lnwallet/btcwallet/signer_test.go
+++ b/lnwallet/btcwallet/signer_test.go
@@ -188,7 +188,6 @@ func TestBip32KeyDerivation(t *testing.T) {
// Let's go through the test cases now that we know our wallet is ready.
for _, tc := range testCases {
- tc := tc
t.Run(tc.name, func(t *testing.T) {
privKey, err := w.deriveKeyByBIP32Path(tc.path)
@@ -513,7 +512,6 @@ func TestMaybeTweakPrivKey(t *testing.T) {
}
for _, tc := range testCases {
- tc := tc
t.Run(tc.name, func(t *testing.T) {
// Create a sign descriptor with the test tweaks.
signDesc := &input.SignDescriptor{
diff --git a/lnwallet/chainfee/estimator_test.go b/lnwallet/chainfee/estimator_test.go
index 3d355d5..67fe6d4 100644
--- a/lnwallet/chainfee/estimator_test.go
+++ b/lnwallet/chainfee/estimator_test.go
@@ -261,7 +261,6 @@ func TestWebAPIFeeEstimator(t *testing.T) {
require.NoError(t, estimator.Start(), "unable to start fee estimator")
for _, tc := range testCases {
- tc := tc
t.Run(tc.name, func(t *testing.T) {
est, err := estimator.EstimateFeePerKW(tc.target)
@@ -361,7 +360,6 @@ func TestGetCachedFee(t *testing.T) {
}
for _, tc := range testCases {
- tc := tc
t.Run(tc.name, func(t *testing.T) {
cachedFee, err := estimator.getCachedFee(tc.confTarget)
diff --git a/lnwallet/chainfee/filtermanager_test.go b/lnwallet/chainfee/filtermanager_test.go
index 085814d..0271c81 100644
--- a/lnwallet/chainfee/filtermanager_test.go
+++ b/lnwallet/chainfee/filtermanager_test.go
@@ -35,7 +35,6 @@ func TestFeeFilterMedian(t *testing.T) {
}
for _, test := range tests {
- test := test
t.Run(test.name, func(t *testing.T) {
cb := func() ([]SatPerKWeight, error) {
return nil, nil
diff --git a/lnwallet/chancloser/chancloser_test.go b/lnwallet/chancloser/chancloser_test.go
index 16afb65..a89a5b9 100644
--- a/lnwallet/chancloser/chancloser_test.go
+++ b/lnwallet/chancloser/chancloser_test.go
@@ -123,7 +123,6 @@ func TestMaybeMatchScript(t *testing.T) {
}
for _, test := range tests {
- test := test
t.Run(test.name, func(t *testing.T) {
t.Parallel()
@@ -361,7 +360,6 @@ func TestMaxFeeClamp(t *testing.T) {
},
}
for _, test := range tests {
- test := test
t.Run(test.name, func(t *testing.T) {
t.Parallel()
@@ -398,7 +396,6 @@ func TestMaxFeeBailOut(t *testing.T) {
)
for _, isInitiator := range []bool{true, false} {
- isInitiator := isInitiator
t.Run(fmt.Sprintf("initiator=%v", isInitiator), func(t *testing.T) {
t.Parallel()
@@ -494,7 +491,6 @@ func TestParseUpfrontShutdownAddress(t *testing.T) {
}
for _, tc := range tests {
- tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
diff --git a/lnwallet/chanfunding/coin_select_test.go b/lnwallet/chanfunding/coin_select_test.go
index e20259c..312ae7d 100644
--- a/lnwallet/chanfunding/coin_select_test.go
+++ b/lnwallet/chanfunding/coin_select_test.go
@@ -123,7 +123,6 @@ func TestCalculateFees(t *testing.T) {
fundingOutputEstimate.AddP2WSHOutput()
for _, test := range testCases {
- test := test
t.Run(test.name, func(t *testing.T) {
feeNoChange, feeWithChange, err := calculateFees(
test.utxos, feeRate, fundingOutputEstimate,
@@ -309,7 +308,6 @@ func TestCoinSelect(t *testing.T) {
fundingOutputEstimate.AddP2WSHOutput()
for _, test := range testCases {
- test := test
t.Run(test.name, func(t *testing.T) {
t.Parallel()
@@ -451,7 +449,6 @@ func TestCalculateChangeAmount(t *testing.T) {
}}
for _, tc := range testCases {
- tc := tc
t.Run(tc.name, func(tt *testing.T) {
changeAmt, needMore, err := CalculateChangeAmount(
tc.totalInputAmt, tc.requiredAmt,
@@ -644,7 +641,6 @@ func TestCoinSelectSubtractFees(t *testing.T) {
fundingOutputEstimate.AddP2WSHOutput()
for _, test := range testCases {
- test := test
t.Run(test.name, func(t *testing.T) {
feeRate := feeRate
@@ -893,7 +889,6 @@ func TestCoinSelectUpToAmount(t *testing.T) {
fundingOutputEstimate.AddP2WSHOutput()
for _, test := range testCases {
- test := test
t.Run(test.name, func(t *testing.T) {
t.Parallel()
diff --git a/lnwallet/chanfunding/psbt_assembler_test.go b/lnwallet/chanfunding/psbt_assembler_test.go
index 461b83f..71988e2 100644
--- a/lnwallet/chanfunding/psbt_assembler_test.go
+++ b/lnwallet/chanfunding/psbt_assembler_test.go
@@ -456,7 +456,6 @@ func TestPsbtVerify(t *testing.T) {
// Loop through all our test cases.
for _, tc := range testCases {
- tc := tc
t.Run(tc.name, func(t *testing.T) {
// Reset the state from a previous test and create a new
// pending PSBT that we can manipulate.
@@ -622,7 +621,6 @@ func TestPsbtFinalize(t *testing.T) {
// Loop through all our test cases.
for _, tc := range testCases {
- tc := tc
t.Run(tc.name, func(t *testing.T) {
// Reset the state from a previous test and create a new
// pending PSBT that we can manipulate.
@@ -739,7 +737,6 @@ func TestVerifyAllInputsSegWit(t *testing.T) {
}}
for _, tc := range testCases {
- tc := tc
t.Run(tc.name, func(t *testing.T) {
r := strings.NewReader(tc.packet)
diff --git a/lnwallet/channel_test.go b/lnwallet/channel_test.go
index ab96d33..09822f3 100644
--- a/lnwallet/channel_test.go
+++ b/lnwallet/channel_test.go
@@ -387,7 +387,6 @@ func TestSimpleAddSettleWorkflow(t *testing.T) {
t.Parallel()
for _, tweakless := range []bool{true, false} {
- tweakless := tweakless
t.Run(fmt.Sprintf("tweakless=%v", tweakless), func(t *testing.T) {
testAddSettleWorkflow(t, tweakless, 0, false)
@@ -8927,7 +8926,6 @@ func TestFetchParent(t *testing.T) {
}
for _, test := range tests {
- test := test
t.Run(test.name, func(t *testing.T) {
// Create a lightning channel with newly initialized
@@ -9274,7 +9272,6 @@ func TestEvaluateView(t *testing.T) {
}
for _, test := range tests {
- test := test
t.Run(test.name, func(t *testing.T) {
isInitiator := test.channelInitiator == lntypes.Local
@@ -10312,7 +10309,6 @@ func TestCreateBreachRetribution(t *testing.T) {
}
for _, tc := range testCases {
- tc := tc
t.Run(tc.name, func(t *testing.T) {
tx := spendTx
if tc.noSpendTx {
@@ -10741,7 +10737,6 @@ func TestApplyCommitmentFee(t *testing.T) {
}
for _, tc := range testCases {
- tc := tc
t.Run(tc.name, func(t *testing.T) {
//nolint:ll
balance, bufferAmt, commitFee, err := tc.channel.applyCommitFee(
diff --git a/lnwallet/confscale_test.go b/lnwallet/confscale_test.go
index 53165fc..2b50b28 100644
--- a/lnwallet/confscale_test.go
+++ b/lnwallet/confscale_test.go
@@ -262,7 +262,6 @@ func TestScaleNumConfsKnownValues(t *testing.T) {
}
for _, tc := range testCases {
- tc := tc
t.Run(tc.name, func(t *testing.T) {
result := ScaleNumConfs(tc.chanAmt, tc.pushAmt)
diff --git a/lnwallet/parameters_test.go b/lnwallet/parameters_test.go
index 3cee8f3..eef7e36 100644
--- a/lnwallet/parameters_test.go
+++ b/lnwallet/parameters_test.go
@@ -38,7 +38,6 @@ func TestDefaultRoutingFeeLimitForAmount(t *testing.T) {
}
for _, test := range tests {
- test := test
t.Run(fmt.Sprintf("%d sats", test.amount), func(t *testing.T) {
feeLimit := DefaultRoutingFeeLimitForAmount(test.amount)
@@ -85,7 +84,6 @@ func TestDustLimitForSize(t *testing.T) {
}
for _, test := range tests {
- test := test
t.Run(test.name, func(t *testing.T) {
dustlimit := DustLimitForSize(test.size)
diff --git a/lnwallet/transactions_test.go b/lnwallet/transactions_test.go
index 38131ea..42639a4 100644
--- a/lnwallet/transactions_test.go
+++ b/lnwallet/transactions_test.go
@@ -226,7 +226,6 @@ func TestCommitmentAndHTLCTransactions(t *testing.T) {
}
for _, set := range vectorSets {
- set := set
var testCases []testCase
@@ -237,7 +236,6 @@ func TestCommitmentAndHTLCTransactions(t *testing.T) {
require.NoError(t, err)
for _, test := range testCases {
- test := test
name := fmt.Sprintf("%s-%s", set.name, test.Name)
t.Run(name, func(t *testing.T) {
@@ -787,7 +785,6 @@ func TestCommitmentSpendValidation(t *testing.T) {
// but we also need to support older nodes that want to open channels
// with the legacy format, so we'll test spending in both scenarios.
for _, tweakless := range []bool{true, false} {
- tweakless := tweakless
t.Run(fmt.Sprintf("tweak=%v", tweakless), func(t *testing.T) {
testSpendValidation(t, tweakless)
})
diff --git a/lnwire/accept_channel_test.go b/lnwire/accept_channel_test.go
index 87d9dc0..b0b199e 100644
--- a/lnwire/accept_channel_test.go
+++ b/lnwire/accept_channel_test.go
@@ -29,7 +29,6 @@ func TestDecodeAcceptChannel(t *testing.T) {
}
for _, test := range tests {
- test := test
t.Run(test.name, func(t *testing.T) {
priv, err := btcec.NewPrivateKey()
diff --git a/lnwire/features_test.go b/lnwire/features_test.go
index c77ddd4..f18e7b3 100644
--- a/lnwire/features_test.go
+++ b/lnwire/features_test.go
@@ -340,7 +340,6 @@ func TestFeatures(t *testing.T) {
}
for _, test := range tests {
- test := test
t.Run(test.name, func(t *testing.T) {
fv := NewFeatureVector(
toRawFV(test.exp), Features,
@@ -508,7 +507,6 @@ func TestValidateUpdate(t *testing.T) {
}
for _, testCase := range testCases {
- testCase := testCase
t.Run(testCase.name, func(t *testing.T) {
t.Parallel()
diff --git a/lnwire/local_nonces_test.go b/lnwire/local_nonces_test.go
index e1b3c85..1652f04 100644
--- a/lnwire/local_nonces_test.go
+++ b/lnwire/local_nonces_test.go
@@ -78,7 +78,6 @@ func TestLocalNoncesDataEncodeDecodeValue(t *testing.T) {
}
for _, test := range tests {
- test := test
t.Run(test.name, func(t *testing.T) {
t.Parallel()
@@ -181,7 +180,6 @@ func TestLocalNoncesDataDecodeFailuresValue(t *testing.T) {
}
for _, test := range tests {
- test := test
t.Run(test.name, func(t *testing.T) {
t.Parallel()
diff --git a/lnwire/onion_error_test.go b/lnwire/onion_error_test.go
index a3bbea5..1eae250 100644
--- a/lnwire/onion_error_test.go
+++ b/lnwire/onion_error_test.go
@@ -93,7 +93,6 @@ func TestEncodeDecodeTlv(t *testing.T) {
t.Parallel()
for _, testFailure := range onionFailures {
- testFailure := testFailure
code := testFailure.Code().String()
t.Run(code, func(t *testing.T) {
diff --git a/lnwire/ping_test.go b/lnwire/ping_test.go
index 0cc60cf..adbef29 100644
--- a/lnwire/ping_test.go
+++ b/lnwire/ping_test.go
@@ -19,7 +19,6 @@ func TestPingDecodeAllowsNoReplyPongSizes(t *testing.T) {
testCases := []uint16{65532, 65535}
for _, numPongBytes := range testCases {
- numPongBytes := numPongBytes
testName := strconv.FormatUint(uint64(numPongBytes), 10)
t.Run(testName, func(t *testing.T) {
diff --git a/lnwire/query_channel_range_test.go b/lnwire/query_channel_range_test.go
index 5d690f3..53c6bda 100644
--- a/lnwire/query_channel_range_test.go
+++ b/lnwire/query_channel_range_test.go
@@ -39,7 +39,6 @@ func TestQueryChannelRange(t *testing.T) {
}
for _, test := range tests {
- test := test
t.Run(test.name, func(t *testing.T) {
t.Parallel()
diff --git a/lnwire/query_short_chan_ids_test.go b/lnwire/query_short_chan_ids_test.go
index 996c9f7..a147061 100644
--- a/lnwire/query_short_chan_ids_test.go
+++ b/lnwire/query_short_chan_ids_test.go
@@ -50,7 +50,6 @@ var (
// that contains duplicate or unsorted ids returns an ErrUnsortedSIDs failure.
func TestQueryShortChanIDsUnsorted(t *testing.T) {
for _, test := range unsortedSidTests {
- test := test
t.Run(test.name, func(t *testing.T) {
req := &QueryShortChanIDs{
EncodingType: test.encType,
@@ -96,7 +95,6 @@ func TestQueryShortChanIDsZero(t *testing.T) {
}
for _, test := range testCases {
- test := test
t.Run(test.name, func(t *testing.T) {
req := &QueryShortChanIDs{
EncodingType: test.encoding,
diff --git a/lnwire/reply_channel_range_test.go b/lnwire/reply_channel_range_test.go
index 12955cf..ac95066 100644
--- a/lnwire/reply_channel_range_test.go
+++ b/lnwire/reply_channel_range_test.go
@@ -12,7 +12,6 @@ import (
// that contains duplicate or unsorted ids returns an ErrUnsortedSIDs failure.
func TestReplyChannelRangeUnsorted(t *testing.T) {
for _, test := range unsortedSidTests {
- test := test
t.Run(test.name, func(t *testing.T) {
req := &ReplyChannelRange{
EncodingType: test.encType,
@@ -63,7 +62,6 @@ func TestReplyChannelRangeEmpty(t *testing.T) {
}
for _, test := range emptyChannelsTests {
- test := test
t.Run(test.name, func(t *testing.T) {
req := ReplyChannelRange{
FirstBlockHeight: 1,
@@ -210,7 +208,6 @@ func TestReplyChannelRangeEncode(t *testing.T) {
}
for _, test := range tests {
- test := test
t.Run(test.name, func(t *testing.T) {
t.Parallel()
@@ -327,7 +324,6 @@ func TestReplyChannelRangeDecode(t *testing.T) {
}
for _, test := range tests {
- test := test
t.Run(test.name, func(t *testing.T) {
t.Parallel()
diff --git a/lnwire/signature_test.go b/lnwire/signature_test.go
index 73263f1..c47bf97 100644
--- a/lnwire/signature_test.go
+++ b/lnwire/signature_test.go
@@ -273,7 +273,6 @@ func TestNewSigFromRawSignature(t *testing.T) {
}
for _, tc := range testCases {
- tc := tc
t.Run(tc.name, func(t *testing.T) {
result, err := NewSigFromECDSARawSignature(tc.rawSig)
require.Equal(t, tc.expectedErr, err)
diff --git a/lnwire/writer_test.go b/lnwire/writer_test.go
index bb2bada..4f15ba5 100644
--- a/lnwire/writer_test.go
+++ b/lnwire/writer_test.go
@@ -457,7 +457,6 @@ func TestWriteTCPAddr(t *testing.T) {
}
for _, tc := range testCases {
- tc := tc
t.Run(tc.name, func(t *testing.T) {
oldLen := buf.Len()
@@ -545,7 +544,6 @@ func TestWriteOnionAddr(t *testing.T) {
}
for _, tc := range testCases {
- tc := tc
t.Run(tc.name, func(t *testing.T) {
oldLen := buf.Len()
@@ -618,7 +616,6 @@ func TestWriteNetAddrs(t *testing.T) {
}
for _, tc := range testCases {
- tc := tc
t.Run(tc.name, func(t *testing.T) {
buf := new(bytes.Buffer)
diff --git a/netann/channel_update_test.go b/netann/channel_update_test.go
index 2a619e0..fe0bc33 100644
--- a/netann/channel_update_test.go
+++ b/netann/channel_update_test.go
@@ -105,7 +105,6 @@ func TestUpdateDisableFlag(t *testing.T) {
t.Parallel()
for _, tc := range updateDisableTests {
- tc := tc
t.Run(tc.name, func(t *testing.T) {
// Create the initial update, the only fields we are
// concerned with in this test are the timestamp and the
diff --git a/onionmessage/ratelimit_test.go b/onionmessage/ratelimit_test.go
index c43a9ef..4f7885c 100644
--- a/onionmessage/ratelimit_test.go
+++ b/onionmessage/ratelimit_test.go
@@ -29,7 +29,6 @@ func TestGlobalLimiterDisabled(t *testing.T) {
{"both zero", 0, 0},
}
for _, tc := range cases {
- tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
lim := NewGlobalLimiter(tc.kbps, tc.burstBytes)
@@ -84,7 +83,6 @@ func TestPeerRateLimiterDisabled(t *testing.T) {
{"both zero", 0, 0},
}
for _, tc := range cases {
- tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
p := NewPeerRateLimiter(tc.kbps, tc.burstBytes)
@@ -217,7 +215,6 @@ func TestPeerRateLimiterConcurrentAllowN(t *testing.T) {
var wg sync.WaitGroup
var ops atomic.Uint64
for w := 0; w < workers; w++ {
- w := w
wg.Add(1)
go func() {
defer wg.Done()
diff --git a/payments/db/payment_status_test.go b/payments/db/payment_status_test.go
index 1bb4dc3..b5c762d 100644
--- a/payments/db/payment_status_test.go
+++ b/payments/db/payment_status_test.go
@@ -168,7 +168,6 @@ func TestDecidePaymentStatus(t *testing.T) {
}
for _, tc := range testCases {
- tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
@@ -228,7 +227,6 @@ func TestPaymentStatusActions(t *testing.T) {
}
for i, tc := range testCases {
- i, tc := i, tc
ps := tc.status
name := fmt.Sprintf("test_%d_%s", i, ps.String())
diff --git a/payments/db/payment_test.go b/payments/db/payment_test.go
index e304b13..e77a152 100644
--- a/payments/db/payment_test.go
+++ b/payments/db/payment_test.go
@@ -783,8 +783,6 @@ func TestPaymentRegistrable(t *testing.T) {
}
for i, tc := range testCases {
- i, tc := i, tc
-
p := &MPPayment{
Status: tc.status,
State: &MPPaymentState{
@@ -901,8 +899,6 @@ func TestPaymentSetState(t *testing.T) {
}
for _, tc := range testCases {
- tc := tc
-
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
@@ -1034,8 +1030,6 @@ func TestNeedWaitAttempts(t *testing.T) {
}
for _, tc := range testCases {
- tc := tc
-
p := &MPPayment{
Info: &PaymentCreationInfo{
PaymentIdentifier: [32]byte{1, 2, 3},
@@ -1212,8 +1206,6 @@ func TestAllowMoreAttempts(t *testing.T) {
}
for i, tc := range testCases {
- tc := tc
-
p := &MPPayment{
Info: &PaymentCreationInfo{
PaymentIdentifier: [32]byte{1, 2, 3},
diff --git a/peer/brontide_test.go b/peer/brontide_test.go
index f4bb661..0dc218d 100644
--- a/peer/brontide_test.go
+++ b/peer/brontide_test.go
@@ -737,7 +737,6 @@ func TestChooseDeliveryScript(t *testing.T) {
}
for _, test := range tests {
- test := test
t.Run(test.name, func(t *testing.T) {
script, err := chooseDeliveryScript(
@@ -817,7 +816,6 @@ func TestCustomShutdownScript(t *testing.T) {
}
for _, test := range tests {
- test := test
t.Run(test.name, func(t *testing.T) {
// Open a channel.
@@ -985,7 +983,6 @@ func TestStaticRemoteDowngrade(t *testing.T) {
}
for _, test := range tests {
- test := test
t.Run(test.name, func(t *testing.T) {
params := createTestPeer(t)
@@ -1288,7 +1285,6 @@ func TestHandleNewPendingChannel(t *testing.T) {
}
for _, tc := range testCases {
- tc := tc
// Create a request for testing.
errChan := make(chan error, 1)
@@ -1373,7 +1369,6 @@ func TestHandleRemovePendingChannel(t *testing.T) {
}
for _, tc := range testCases {
- tc := tc
// Create a request for testing.
errChan := make(chan error, 1)
diff --git a/record/blinded_data_test.go b/record/blinded_data_test.go
index bc1230b..0620e9b 100644
--- a/record/blinded_data_test.go
+++ b/record/blinded_data_test.go
@@ -79,7 +79,6 @@ func TestBlindedDataEncoding(t *testing.T) {
}
for _, testCase := range tests {
- testCase := testCase
t.Run(testCase.name, func(t *testing.T) {
t.Parallel()
@@ -143,7 +142,6 @@ func TestBlindedDataFinalHopEncoding(t *testing.T) {
}
for _, test := range tests {
- test := test
t.Run(test.name, func(t *testing.T) {
t.Parallel()
diff --git a/record/record_test.go b/record/record_test.go
index 45faa9f..92902fa 100644
--- a/record/record_test.go
+++ b/record/record_test.go
@@ -73,7 +73,6 @@ var recordEncDecTests = []recordEncDecTest{
// the original record matches the decoded record.
func TestRecordEncodeDecode(t *testing.T) {
for _, test := range recordEncDecTests {
- test := test
t.Run(test.name, func(t *testing.T) {
r := test.encRecord()
r2 := test.decRecord()
diff --git a/routing/additional_edge_test.go b/routing/additional_edge_test.go
index 0324e2e..34fd219 100644
--- a/routing/additional_edge_test.go
+++ b/routing/additional_edge_test.go
@@ -68,7 +68,6 @@ func TestIntermediatePayloadSize(t *testing.T) {
}
for _, testCase := range testCases {
- testCase := testCase
t.Run(testCase.name, func(t *testing.T) {
t.Parallel()
diff --git a/routing/bandwidth_test.go b/routing/bandwidth_test.go
index b7f6e3f..ff5529f 100644
--- a/routing/bandwidth_test.go
+++ b/routing/bandwidth_test.go
@@ -102,7 +102,6 @@ func TestBandwidthManager(t *testing.T) {
}
for _, testCase := range testCases {
- testCase := testCase
t.Run(testCase.name, func(t *testing.T) {
g := newMockGraph(t)
diff --git a/routing/blindedpath/blinded_path_test.go b/routing/blindedpath/blinded_path_test.go
index 0020f38..3f4cb75 100644
--- a/routing/blindedpath/blinded_path_test.go
+++ b/routing/blindedpath/blinded_path_test.go
@@ -161,7 +161,6 @@ func TestApplyBlindedPathPolicyBuffer(t *testing.T) {
}
for _, test := range tests {
- test := test
t.Run(test.name, func(t *testing.T) {
t.Parallel()
@@ -351,7 +350,6 @@ func TestPadBlindedHopInfo(t *testing.T) {
}
for _, test := range tests {
- test := test
t.Run(test.name, func(t *testing.T) {
t.Parallel()
diff --git a/routing/blinding_test.go b/routing/blinding_test.go
index 0a8846a..2ca9b63 100644
--- a/routing/blinding_test.go
+++ b/routing/blinding_test.go
@@ -64,7 +64,6 @@ func TestBlindedPathValidation(t *testing.T) {
}
for _, testCase := range tests {
- testCase := testCase
t.Run(testCase.name, func(t *testing.T) {
t.Parallel()
diff --git a/routing/integrated_routing_test.go b/routing/integrated_routing_test.go
index 9636b10..035c228 100644
--- a/routing/integrated_routing_test.go
+++ b/routing/integrated_routing_test.go
@@ -270,7 +270,6 @@ func TestBadFirstHopHint(t *testing.T) {
// TestMppSend tests that a payment can be completed using multiple shards.
func TestMppSend(t *testing.T) {
for _, testCase := range mppTestCases {
- testCase := testCase
t.Run(testCase.name, func(t *testing.T) {
testMppSend(t, &testCase)
diff --git a/routing/localchans/manager_test.go b/routing/localchans/manager_test.go
index c48e616..92d8ce0 100644
--- a/routing/localchans/manager_test.go
+++ b/routing/localchans/manager_test.go
@@ -359,7 +359,6 @@ func TestManager(t *testing.T) {
}
for _, test := range tests {
- test := test
t.Run(test.name, func(t *testing.T) {
currentPolicy = test.currentPolicy
channelSet = test.channelSet
diff --git a/routing/missioncontrol_store_test.go b/routing/missioncontrol_store_test.go
index 889dca0..9cfd118 100644
--- a/routing/missioncontrol_store_test.go
+++ b/routing/missioncontrol_store_test.go
@@ -276,7 +276,6 @@ func BenchmarkMissionControlStoreFlushing(b *testing.B) {
const testMaxRecords = 1000
for _, tc := range tests {
- tc := tc
name := fmt.Sprintf("%v additional results", tc)
b.Run(name, func(b *testing.B) {
h := newMCStoreTestHarness(
diff --git a/routing/pathfind_test.go b/routing/pathfind_test.go
index 85689ef..9bf0363 100644
--- a/routing/pathfind_test.go
+++ b/routing/pathfind_test.go
@@ -899,7 +899,6 @@ func TestPathFinding(t *testing.T) {
// Run with graph cache enabled.
for _, tc := range testCases {
- tc := tc
t.Run("cache=true/"+tc.name, func(tt *testing.T) {
tt.Parallel()
@@ -911,7 +910,6 @@ func TestPathFinding(t *testing.T) {
// And with the DB fallback to make sure everything works the same
// still.
for _, tc := range testCases {
- tc := tc
t.Run("cache=false/"+tc.name, func(tt *testing.T) {
tt.Parallel()
@@ -1686,7 +1684,6 @@ func TestNewRoute(t *testing.T) {
}}
for _, testCase := range testCases {
- testCase := testCase
// Overwrite the final hop's features if the test requires a
// custom feature vector.
@@ -2804,7 +2801,6 @@ func runProbabilityRouting(t *testing.T, useCache bool) {
}
for _, tc := range testCases {
- tc := tc
t.Run(tc.name, func(t *testing.T) {
testProbabilityRouting(
@@ -3717,7 +3713,6 @@ func TestLastHopPayloadSize(t *testing.T) {
}
for _, tc := range testCases {
- tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
diff --git a/routing/payment_lifecycle_test.go b/routing/payment_lifecycle_test.go
index 564942d..3405821 100644
--- a/routing/payment_lifecycle_test.go
+++ b/routing/payment_lifecycle_test.go
@@ -574,7 +574,6 @@ func TestDecideNextStep(t *testing.T) {
}
for _, tc := range testCases {
- tc := tc
// Create a test paymentLifecycle.
p, _ := newTestPaymentLifecycle(t)
diff --git a/routing/payment_session_test.go b/routing/payment_session_test.go
index 0bc0b6d..7ad44b8 100644
--- a/routing/payment_session_test.go
+++ b/routing/payment_session_test.go
@@ -55,7 +55,6 @@ func TestValidateCLTVLimit(t *testing.T) {
}
for _, testCase := range testCases {
- testCase := testCase
success := t.Run(testCase.name, func(t *testing.T) {
err := ValidateCLTVLimit(
diff --git a/routing/probability_apriori_test.go b/routing/probability_apriori_test.go
index b7df8ae..0527d2d 100644
--- a/routing/probability_apriori_test.go
+++ b/routing/probability_apriori_test.go
@@ -315,7 +315,6 @@ func TestCapacityCutoff(t *testing.T) {
}
for _, test := range tests {
- test := test
t.Run(test.name, func(t *testing.T) {
t.Parallel()
diff --git a/routing/probability_bimodal_test.go b/routing/probability_bimodal_test.go
index 57590a8..b7ecda2 100644
--- a/routing/probability_bimodal_test.go
+++ b/routing/probability_bimodal_test.go
@@ -239,7 +239,6 @@ func TestSuccessProbability(t *testing.T) {
}
for _, test := range tests {
- test := test
t.Run(test.name, func(t *testing.T) {
t.Parallel()
@@ -369,7 +368,6 @@ func TestIntegral(t *testing.T) {
}
for _, test := range tests {
- test := test
t.Run(test.name, func(t *testing.T) {
t.Parallel()
@@ -671,7 +669,6 @@ func TestComputeProbability(t *testing.T) {
}
for _, test := range tests {
- test := test
t.Run(test.name, func(t *testing.T) {
t.Parallel()
@@ -748,7 +745,6 @@ func TestLocalPairProbability(t *testing.T) {
}
for _, test := range tests {
- test := test
t.Run(test.name, func(t *testing.T) {
t.Parallel()
diff --git a/routing/route/route_test.go b/routing/route/route_test.go
index 83cfc07..b7d104d 100644
--- a/routing/route/route_test.go
+++ b/routing/route/route_test.go
@@ -255,7 +255,6 @@ func TestBlindedHops(t *testing.T) {
}
for _, testCase := range tests {
- testCase := testCase
t.Run(testCase.name, func(t *testing.T) {
t.Parallel()
@@ -358,7 +357,6 @@ func TestPayloadSize(t *testing.T) {
}
for _, testCase := range testCases {
- testCase := testCase
t.Run(testCase.name, func(t *testing.T) {
t.Parallel()
diff --git a/routing/router_test.go b/routing/router_test.go
index e14ac19..535e4db 100644
--- a/routing/router_test.go
+++ b/routing/router_test.go
@@ -1423,8 +1423,6 @@ func TestSendToRouteStructuredError(t *testing.T) {
}
for failIndex, errorType := range testCases {
- failIndex := failIndex
- errorType := errorType
t.Run(fmt.Sprintf("%T", errorType), func(t *testing.T) {
// We'll modify the SendToSwitch method so that it
@@ -2086,7 +2084,6 @@ func TestInboundOutbound(t *testing.T) {
}
for _, tc := range tests {
- tc := tc
t.Run(tc.name, func(tt *testing.T) {
testInboundOutboundFee(
@@ -2692,7 +2689,6 @@ func TestNewRouteRequest(t *testing.T) {
}
for _, testCase := range testCases {
- testCase := testCase
t.Run(testCase.name, func(t *testing.T) {
t.Parallel()
diff --git a/routing/unified_edges_test.go b/routing/unified_edges_test.go
index 25c8e92..6faf2ef 100644
--- a/routing/unified_edges_test.go
+++ b/routing/unified_edges_test.go
@@ -224,7 +224,6 @@ func TestNodeEdgeUnifier(t *testing.T) {
}
for _, test := range tests {
- test := test
t.Run(test.name, func(t *testing.T) {
t.Parallel()
diff --git a/sweep/aggregator_test.go b/sweep/aggregator_test.go
index 2cb89bd..41d0b44 100644
--- a/sweep/aggregator_test.go
+++ b/sweep/aggregator_test.go
@@ -370,7 +370,6 @@ func TestBudgetAggregatorCreateInputSets(t *testing.T) {
// Iterate over the test cases.
for _, tc := range testCases {
- tc := tc
t.Run(tc.name, func(t *testing.T) {
// Setup the mocks.
diff --git a/sweep/fee_bumper_test.go b/sweep/fee_bumper_test.go
index d697f90..cccb9b4 100644
--- a/sweep/fee_bumper_test.go
+++ b/sweep/fee_bumper_test.go
@@ -220,7 +220,6 @@ func TestBumpRequestMaxFeeRateAllowed(t *testing.T) {
}
for _, tc := range testCases {
- tc := tc
t.Run(tc.name, func(t *testing.T) {
// Check the method under test.
@@ -503,7 +502,6 @@ func TestCreateAndCheckTx(t *testing.T) {
}
for _, tc := range testCases {
- tc := tc
r := &monitorRecord{
req: tc.req,
@@ -674,7 +672,6 @@ func TestCreateRBFCompliantTx(t *testing.T) {
var requestCounter atomic.Uint64
for _, tc := range testCases {
- tc := tc
rid := requestCounter.Add(1)
@@ -798,7 +795,6 @@ func TestTxPublisherBroadcast(t *testing.T) {
}
for _, tc := range testCases {
- tc := tc
t.Run(tc.name, func(t *testing.T) {
tc.setupMock()
@@ -931,7 +927,6 @@ func TestRemoveResult(t *testing.T) {
}
for _, tc := range testCases {
- tc := tc
t.Run(tc.name, func(t *testing.T) {
requestID := tc.setupRecord()
diff --git a/sweep/fee_function_test.go b/sweep/fee_function_test.go
index a55ce79..d973084 100644
--- a/sweep/fee_function_test.go
+++ b/sweep/fee_function_test.go
@@ -258,7 +258,6 @@ func TestLinearFeeFunctionFeeRateAtPosition(t *testing.T) {
}
for _, tc := range testCases {
- tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
diff --git a/sweep/sweeper_test.go b/sweep/sweeper_test.go
index d97fd99..917119e 100644
--- a/sweep/sweeper_test.go
+++ b/sweep/sweeper_test.go
@@ -1043,7 +1043,6 @@ func TestMonitorFeeBumpResult(t *testing.T) {
}
for _, tc := range testCases {
- tc := tc
t.Run(tc.name, func(t *testing.T) {
// Setup the testing result channel.
diff --git a/sweep/txgenerator_test.go b/sweep/txgenerator_test.go
index 3f20516..bedb3e7 100644
--- a/sweep/txgenerator_test.go
+++ b/sweep/txgenerator_test.go
@@ -134,7 +134,6 @@ func TestWeightEstimatorUnknownScript(t *testing.T) {
}
for _, test := range tests {
- test := test
t.Run(test.name, func(t *testing.T) {
testUnknownScriptInner(
t, test.pkscript, test.expectFail,
diff --git a/sweep/walletsweep_test.go b/sweep/walletsweep_test.go
index c7a5dfc..b6bed3b 100644
--- a/sweep/walletsweep_test.go
+++ b/sweep/walletsweep_test.go
@@ -126,7 +126,6 @@ func TestFeeEstimateInfo(t *testing.T) {
}
for _, tc := range testCases {
- tc := tc
t.Run(tc.name, func(t *testing.T) {
// Setup the mockers if specified.
diff --git a/tls_manager_test.go b/tls_manager_test.go
index 541b123..9cb88c2 100644
--- a/tls_manager_test.go
+++ b/tls_manager_test.go
@@ -428,7 +428,6 @@ func TestGenerateCertPairWithPartialFiles(t *testing.T) {
}
for _, tc := range testCases {
- tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
diff --git a/watchtower/blob/justice_kit_test.go b/watchtower/blob/justice_kit_test.go
index 0d23e2e..0934c4e 100644
--- a/watchtower/blob/justice_kit_test.go
+++ b/watchtower/blob/justice_kit_test.go
@@ -326,7 +326,6 @@ func TestJusticeKitRemoteWitnessConstruction(t *testing.T) {
},
}
for _, test := range tests {
- test := test
t.Run(test.name, func(t *testing.T) {
testJusticeKitRemoteWitnessConstruction(t, test)
})
@@ -485,7 +484,6 @@ func TestJusticeKitToLocalWitnessConstruction(t *testing.T) {
},
}
for _, test := range tests {
- test := test
t.Run(test.name, func(t *testing.T) {
t.Parallel()
diff --git a/watchtower/wtclient/backup_task_internal_test.go b/watchtower/wtclient/backup_task_internal_test.go
index 62d7609..afdb454 100644
--- a/watchtower/wtclient/backup_task_internal_test.go
+++ b/watchtower/wtclient/backup_task_internal_test.go
@@ -552,7 +552,6 @@ func TestBackupTask(t *testing.T) {
}
for _, test := range backupTaskTests {
- test := test
t.Run(test.name, func(t *testing.T) {
t.Parallel()
diff --git a/watchtower/wtclient/queue_test.go b/watchtower/wtclient/queue_test.go
index a8494c2..66fe20c 100644
--- a/watchtower/wtclient/queue_test.go
+++ b/watchtower/wtclient/queue_test.go
@@ -61,7 +61,6 @@ func TestDiskOverflowQueue(t *testing.T) {
}
for _, test := range tests {
- test := test
t.Run(test.name, func(tt *testing.T) {
tt.Parallel()
diff --git a/watchtower/wtdb/migration1/client_db_test.go b/watchtower/wtdb/migration1/client_db_test.go
index acae177..d75503d 100644
--- a/watchtower/wtdb/migration1/client_db_test.go
+++ b/watchtower/wtdb/migration1/client_db_test.go
@@ -94,7 +94,6 @@ func TestMigrateTowerToSessionIndex(t *testing.T) {
}
for _, test := range tests {
- test := test
t.Run(test.name, func(t *testing.T) {
// Before the migration we have a sessions bucket.
diff --git a/watchtower/wtdb/migration2/client_db_test.go b/watchtower/wtdb/migration2/client_db_test.go
index c143618..b74c00f 100644
--- a/watchtower/wtdb/migration2/client_db_test.go
+++ b/watchtower/wtdb/migration2/client_db_test.go
@@ -69,7 +69,6 @@ func TestMigrateClientChannelDetails(t *testing.T) {
}
for _, test := range tests {
- test := test
t.Run(test.name, func(t *testing.T) {
t.Parallel()
diff --git a/watchtower/wtdb/migration3/client_db_test.go b/watchtower/wtdb/migration3/client_db_test.go
index a2fc8ae..8cd3796 100644
--- a/watchtower/wtdb/migration3/client_db_test.go
+++ b/watchtower/wtdb/migration3/client_db_test.go
@@ -83,7 +83,6 @@ func TestMigrateChannelIDIndex(t *testing.T) {
}
for _, test := range tests {
- test := test
t.Run(test.name, func(t *testing.T) {
t.Parallel()
diff --git a/watchtower/wtdb/migration4/client_db_test.go b/watchtower/wtdb/migration4/client_db_test.go
index 267cfe1..917b01d 100644
--- a/watchtower/wtdb/migration4/client_db_test.go
+++ b/watchtower/wtdb/migration4/client_db_test.go
@@ -226,7 +226,6 @@ func TestMigrateAckedUpdates(t *testing.T) {
}
for _, test := range tests {
- test := test
t.Run(test.name, func(t *testing.T) {
t.Parallel()
diff --git a/watchtower/wtdb/migration5/client_db_test.go b/watchtower/wtdb/migration5/client_db_test.go
index a0a67e5..ec29dfd 100644
--- a/watchtower/wtdb/migration5/client_db_test.go
+++ b/watchtower/wtdb/migration5/client_db_test.go
@@ -95,7 +95,6 @@ func TestCompleteTowerToSessionIndex(t *testing.T) {
}
for _, test := range tests {
- test := test
t.Run(test.name, func(t *testing.T) {
t.Parallel()
diff --git a/watchtower/wtdb/migration6/client_db_test.go b/watchtower/wtdb/migration6/client_db_test.go
index c4928e2..9b3880f 100644
--- a/watchtower/wtdb/migration6/client_db_test.go
+++ b/watchtower/wtdb/migration6/client_db_test.go
@@ -81,7 +81,6 @@ func TestMigrateSessionIDIndex(t *testing.T) {
}
for _, test := range tests {
- test := test
t.Run(test.name, func(t *testing.T) {
t.Parallel()
diff --git a/watchtower/wtdb/migration7/client_db_test.go b/watchtower/wtdb/migration7/client_db_test.go
index 40eeec5..2480b27 100644
--- a/watchtower/wtdb/migration7/client_db_test.go
+++ b/watchtower/wtdb/migration7/client_db_test.go
@@ -112,7 +112,6 @@ func TestMigrateChannelToSessionIndex(t *testing.T) {
}
for _, test := range tests {
- test := test
t.Run(test.name, func(t *testing.T) {
t.Parallel()
diff --git a/zpay32/invoice_internal_test.go b/zpay32/invoice_internal_test.go
index 22434a9..c2729e8 100644
--- a/zpay32/invoice_internal_test.go
+++ b/zpay32/invoice_internal_test.go
@@ -834,7 +834,6 @@ func TestParseTaggedFields(t *testing.T) {
},
}
for _, tc := range tests {
- tc := tc // pin
t.Run(tc.name, func(t *testing.T) {
var invoice Invoice
gotErr := parseTaggedFields(&invoice, tc.data, netParams)
diff --git a/zpay32/invoice_test.go b/zpay32/invoice_test.go
index bfa1539..cec6bfd 100644
--- a/zpay32/invoice_test.go
+++ b/zpay32/invoice_test.go
@@ -901,7 +901,6 @@ func TestDecodeEncode(t *testing.T) {
}
for i, test := range tests {
- test := test
t.Run(fmt.Sprintf("%d", i), func(t *testing.T) {
t.Parallel()
@@ -1050,7 +1049,6 @@ func TestNewInvoice(t *testing.T) {
}
for i, test := range tests {
- test := test
t.Run(fmt.Sprintf("%d", i), func(t *testing.T) {
t.Parallel()
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.