diff --git a/.golangci.yml b/.golangci.yml index 7d3b1a54f20..6ccbf04e4df 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -46,16 +46,28 @@ linters: # Init functions are used by loggers throughout the codebase. - gochecknoinits - # Deprecated linters. See https://golangci-lint.run/usage/linters/. - - bodyclose + # contextcheck requires threading context.Context through many existing + # function signatures (including test harnesses), so we leave it off for + # now. - contextcheck - - nilerr - - noctx - - rowserrcheck - - sqlclosecheck + + # tparallel requires adding t.Parallel() to a large number of existing + # subtests, which can surface shared-state races. Disabled until we can + # address it carefully. - tparallel + + # unparam has a sizeable backlog of unused parameters to clean up before it + # can be enabled. - unparam - - wastedassign + + # nilerr is too noisy for our code base: most reports are intentional error + # swallowing (documented with comments) or false positives where a boolean + # check is mistaken for an error check. + - nilerr + + # noctx would only flag a couple of interface methods and a test helper that + # have no context to thread through, so it adds little value for now. + - noctx # Disable whitespace linters as it has conflict rules against our # contribution guidelines. @@ -114,7 +126,6 @@ linters: - testifylint - perfsprint - inamedparam - - copyloopvar - tagalign - protogetter - revive diff --git a/aliasmgr/aliasmgr_test.go b/aliasmgr/aliasmgr_test.go index 3237e5bbb19..cdf88423b45 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 af8162d1d40..3ebddca72a0 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 5571a78d2d4..7e257a87623 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 cdaec8746da..9ff9d30cca3 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 282e60c3651..a6fe227273c 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 dbce428e405..d58b3dddac8 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/mempool.go b/chainntnfs/mempool.go index 2e31751fcd0..037bde9e376 100644 --- a/chainntnfs/mempool.go +++ b/chainntnfs/mempool.go @@ -298,8 +298,6 @@ func (m *MempoolNotifier) notifySpent(spentInputs inputsWithTx) { // Iterate the spent inputs to notify the subscribers concurrently. for op, tx := range spentInputs { - op, tx := op, tx - m.wg.Add(1) go notifyAll(tx, op) } diff --git a/chainntnfs/txnotifier_test.go b/chainntnfs/txnotifier_test.go index 1bd9f4f1c32..451062a5dc3 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( @@ -1943,14 +1942,18 @@ func TestTxNotifierConfirmHintCache(t *testing.T) { // the height hints should remain unchanged. This simulates blocks // confirming while the historical dispatch is processing the // registration. - hint, err := hintCache.QueryConfirmHint(ntfn1.HistoricalDispatch.ConfRequest) + _, err = hintCache.QueryConfirmHint( + ntfn1.HistoricalDispatch.ConfRequest, + ) if err != chainntnfs.ErrConfirmHintNotFound { t.Fatalf("unexpected error when querying for height hint "+ "want: %v, got %v", chainntnfs.ErrConfirmHintNotFound, err) } - hint, err = hintCache.QueryConfirmHint(ntfn2.HistoricalDispatch.ConfRequest) + _, err = hintCache.QueryConfirmHint( + ntfn2.HistoricalDispatch.ConfRequest, + ) if err != chainntnfs.ErrConfirmHintNotFound { t.Fatalf("unexpected error when querying for height hint "+ "want: %v, got %v", @@ -1979,7 +1982,9 @@ func TestTxNotifierConfirmHintCache(t *testing.T) { // Now that both notifications are waiting at tip for confirmations, // they should have their height hints updated to the latest block // height. - hint, err = hintCache.QueryConfirmHint(ntfn1.HistoricalDispatch.ConfRequest) + hint, err := hintCache.QueryConfirmHint( + ntfn1.HistoricalDispatch.ConfRequest, + ) require.NoError(t, err, "unable to query for hint") if hint != tx1Height { t.Fatalf("expected hint %d, got %d", diff --git a/chanacceptor/acceptor_test.go b/chanacceptor/acceptor_test.go index 5a6aaa01276..2746b31b085 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 c6b6579a70c..0ffaadeb8b3 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 de1f380c172..eb65080d5b5 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 e97d4cebac1..11d66e1159e 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 43046db2533..8d1cc548c2e 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 ecec3ea4717..f14eba1d338 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 b9bca808650..6e5ebf97ddd 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 7039abe4659..5b8758e9a42 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 27428a6f934..c41b8e12abd 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/height_hint.go b/channeldb/height_hint.go index 9744c17c0bb..5c44d330c2f 100644 --- a/channeldb/height_hint.go +++ b/channeldb/height_hint.go @@ -91,7 +91,6 @@ func (c *HeightHintCache) CommitSpendHint(height uint32, } for _, spendRequest := range spendRequests { - spendRequest := spendRequest spendHintKey, err := spendHintKey(&spendRequest) if err != nil { return err @@ -161,7 +160,6 @@ func (c *HeightHintCache) PurgeSpendHint( } for _, spendRequest := range spendRequests { - spendRequest := spendRequest spendHintKey, err := spendHintKey(&spendRequest) if err != nil { return err @@ -198,7 +196,6 @@ func (c *HeightHintCache) CommitConfirmHint(height uint32, } for _, confRequest := range confRequests { - confRequest := confRequest confHintKey, err := confHintKey(&confRequest) if err != nil { return err @@ -269,7 +266,6 @@ func (c *HeightHintCache) PurgeConfirmHint( } for _, confRequest := range confRequests { - confRequest := confRequest confHintKey, err := confHintKey(&confRequest) if err != nil { return err diff --git a/channeldb/invoices.go b/channeldb/invoices.go index ab8d1426fa6..cee6164f145 100644 --- a/channeldb/invoices.go +++ b/channeldb/invoices.go @@ -938,7 +938,6 @@ func (k *kvInvoiceUpdater) storeAddHtlcsUpdate() error { // As we don't update the settle index above for AMP invoices, we'll do // it here for each sub-AMP invoice that was settled. for settledSetID := range k.settledSetIDs { - settledSetID := settledSetID err := k.setSettleMetaFields(&settledSetID) if err != nil { return err @@ -1862,7 +1861,6 @@ func ampStateEncoder(w io.Writer, val interface{}, buf *[8]byte) error { // inner length prefix. for setID, ampState := range *v { setID := [32]byte(setID) - ampState := ampState htlcState := uint8(ampState.State) settleDate := ampState.SettleDate diff --git a/channeldb/meta_test.go b/channeldb/meta_test.go index 066678c1a32..ea314bc983b 100644 --- a/channeldb/meta_test.go +++ b/channeldb/meta_test.go @@ -547,7 +547,7 @@ func TestApplyOptionalVersions(t *testing.T) { require.Equal(t, 0, migrateCount, "expected no migration") // Check the optional meta is not updated. - om, err := db.fetchOptionalMeta() + _, err = db.fetchOptionalMeta() require.NoError(t, err, "error getting optional meta") // Enable all optional migrations. @@ -563,7 +563,7 @@ func TestApplyOptionalVersions(t *testing.T) { ) // Fetch the updated optional meta. - om, err = db.fetchOptionalMeta() + om, err := db.fetchOptionalMeta() require.NoError(t, err, "error getting optional meta") // Verify that the optional meta is updated as expected. diff --git a/channeldb/migration/create_tlb_test.go b/channeldb/migration/create_tlb_test.go index 164e8f27f9c..31171651bde 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 75d74fdd6d4..7baae64353e 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 dc2d017fbd7..7fb55466eaa 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 350c4cc91a1..c2dbdfd7b6b 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 6098e440e3f..4c67c077581 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 a775386f777..dd1247db412 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 f2005ed65ad..d8d769d2f17 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 8d2206eb5b7..de654a01755 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 01773292c46..9202d9168c1 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 685f575374e..1d30c3f335d 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 1148fdf03eb..6f0c21c1f1c 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 6e7afb9a3c3..347e86e4fb1 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 4b0e444168a..ad04369368a 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/cmd/commands/commands.go b/cmd/commands/commands.go index 0c389a610b0..8bf75a2af70 100644 --- a/cmd/commands/commands.go +++ b/cmd/commands/commands.go @@ -769,7 +769,6 @@ func listUnspent(ctx *cli.Context) error { cli.ShowCommandHelp(ctx, "listunspent") return nil } - args = args.Tail() } unconfirmedOnly := ctx.Bool("unconfirmed_only") diff --git a/cmd/commands/walletrpc_active.go b/cmd/commands/walletrpc_active.go index dcb91a71ff5..99f89820c2c 100644 --- a/cmd/commands/walletrpc_active.go +++ b/cmd/commands/walletrpc_active.go @@ -2013,7 +2013,6 @@ func signMessageWithAddr(ctx *cli.Context) error { case ctx.Args().Present(): msg = []byte(args.First()) - args = args.Tail() default: return fmt.Errorf("msg argument missing") @@ -2121,7 +2120,6 @@ func verifyMessageWithAddr(ctx *cli.Context) error { case ctx.Args().Present(): msg = []byte(args.First()) - args = args.Tail() default: return fmt.Errorf("msg argument missing") diff --git a/config_onion_ratelimit_test.go b/config_onion_ratelimit_test.go index b97a757852b..3ac6bd5c13f 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/breach_arbitrator.go b/contractcourt/breach_arbitrator.go index 2c12f25598b..130efcb52ce 100644 --- a/contractcourt/breach_arbitrator.go +++ b/contractcourt/breach_arbitrator.go @@ -912,7 +912,6 @@ Loop: } for _, tx := range justiceTxs.spendSecondLevelHTLCs { - tx := tx brarLog.Debugf("Broadcasting justice tx "+ "spending second-level HTLC output: %v", diff --git a/contractcourt/briefcase.go b/contractcourt/briefcase.go index 3e58147c615..2e7efe0e386 100644 --- a/contractcourt/briefcase.go +++ b/contractcourt/briefcase.go @@ -1582,7 +1582,6 @@ func encodeTaprootAuxData(w io.Writer, c *ContractResolutions) error { htlcBlobs := newAuxHtlcBlobs() for _, htlc := range c.HtlcResolutions.IncomingHTLCs { - htlc := htlc htlcSignDesc := htlc.SweepSignDesc ctrlBlock := htlcSignDesc.ControlBlock @@ -1619,7 +1618,6 @@ func encodeTaprootAuxData(w io.Writer, c *ContractResolutions) error { }) } for _, htlc := range c.HtlcResolutions.OutgoingHTLCs { - htlc := htlc htlcSignDesc := htlc.SweepSignDesc ctrlBlock := htlcSignDesc.ControlBlock diff --git a/contractcourt/chain_arbitrator.go b/contractcourt/chain_arbitrator.go index 1b8b00e2aec..1b448cb4acb 100644 --- a/contractcourt/chain_arbitrator.go +++ b/contractcourt/chain_arbitrator.go @@ -1359,7 +1359,6 @@ func (c *ChainArbitrator) loadOpenChannels() error { // ChannelArbitrator. for _, channel := range openChannels { chanPoint := channel.FundingOutpoint - channel := channel // First, we'll create an active chainWatcher for this channel // to ensure that we detect any relevant on chain events. diff --git a/contractcourt/chain_watcher_coop_reorg_test.go b/contractcourt/chain_watcher_coop_reorg_test.go index 0e0a55219e7..a97c00e09af 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 8275886a140..c7287d35c1c 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.go b/contractcourt/channel_arbitrator.go index 458a8a0d254..ac7e259cc2a 100644 --- a/contractcourt/channel_arbitrator.go +++ b/contractcourt/channel_arbitrator.go @@ -615,7 +615,6 @@ func maybeAugmentTaprootResolvers(chanType channeldb.ChannelType, //nolint:ll htlcResolutions := contractResolutions.HtlcResolutions.OutgoingHTLCs for _, htlcRes := range htlcResolutions { - htlcRes := htlcRes if r.htlcResolution.ClaimOutpoint == htlcRes.ClaimOutpoint { @@ -628,7 +627,6 @@ func maybeAugmentTaprootResolvers(chanType channeldb.ChannelType, //nolint:ll htlcResolutions := contractResolutions.HtlcResolutions.OutgoingHTLCs for _, htlcRes := range htlcResolutions { - htlcRes := htlcRes if r.htlcResolution.ClaimOutpoint == htlcRes.ClaimOutpoint { @@ -641,7 +639,6 @@ func maybeAugmentTaprootResolvers(chanType channeldb.ChannelType, //nolint:ll htlcResolutions := contractResolutions.HtlcResolutions.IncomingHTLCs for _, htlcRes := range htlcResolutions { - htlcRes := htlcRes if r.htlcResolution.ClaimOutpoint == htlcRes.ClaimOutpoint { @@ -653,7 +650,6 @@ func maybeAugmentTaprootResolvers(chanType channeldb.ChannelType, //nolint:ll htlcResolutions := contractResolutions.HtlcResolutions.IncomingHTLCs for _, htlcRes := range htlcResolutions { - htlcRes := htlcRes if r.htlcResolution.ClaimOutpoint == htlcRes.ClaimOutpoint { @@ -724,7 +720,6 @@ func (c *ChannelArbitrator) relaunchResolvers(commitSet *CommitSet, // order to ensure we have complete coverage. htlcMap := make(map[wire.OutPoint]*channeldb.HTLC) for _, htlc := range confirmedHTLCs { - htlc := htlc outpoint := wire.OutPoint{ Hash: commitHash, Index: uint32(htlc.OutputIndex), @@ -2450,7 +2445,6 @@ func (c *ChannelArbitrator) prepContractResolutions( // claim the HTLC (second-level or directly), then add the pre case HtlcClaimAction: for _, htlc := range htlcs { - htlc := htlc htlcOp := wire.OutPoint{ Hash: commitHash, @@ -2481,7 +2475,6 @@ func (c *ChannelArbitrator) prepContractResolutions( // backwards. case HtlcTimeoutAction: for _, htlc := range htlcs { - htlc := htlc htlcOp := wire.OutPoint{ Hash: commitHash, @@ -2518,7 +2511,6 @@ func (c *ChannelArbitrator) prepContractResolutions( // learn of the pre-image, or let the remote party time out. case HtlcIncomingWatchAction: for _, htlc := range htlcs { - htlc := htlc htlcOp := wire.OutPoint{ Hash: commitHash, @@ -2551,7 +2543,6 @@ func (c *ChannelArbitrator) prepContractResolutions( // backwards), or just timeout. case HtlcOutgoingWatchAction: for _, htlc := range htlcs { - htlc := htlc htlcOp := wire.OutPoint{ Hash: commitHash, diff --git a/contractcourt/channel_arbitrator_test.go b/contractcourt/channel_arbitrator_test.go index 37b9310399e..0e08d2cc492 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 5c660e10008..eb00b3d734f 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 e97af28ce23..86ebede8682 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/taproot_briefcase.go b/contractcourt/taproot_briefcase.go index 4b703dd2952..c197c94d256 100644 --- a/contractcourt/taproot_briefcase.go +++ b/contractcourt/taproot_briefcase.go @@ -167,7 +167,6 @@ func (r *resolverCtrlBlocks) Encode(w io.Writer) error { } for id, ctrlBlock := range *r { - ctrlBlock := ctrlBlock if _, err := w.Write(id[:]); err != nil { return err @@ -486,7 +485,6 @@ func (h *htlcTapTweaks) Encode(w io.Writer) error { } for id, tweak := range *h { - tweak := tweak if _, err := w.Write(id[:]); err != nil { return err diff --git a/contractcourt/utxonursery_test.go b/contractcourt/utxonursery_test.go index f9dd302c983..a99eb7eaf88 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.go b/discovery/gossiper.go index 0c533d49213..6a778bba4ee 100644 --- a/discovery/gossiper.go +++ b/discovery/gossiper.go @@ -1457,7 +1457,6 @@ func (d *AuthenticatedGossiper) sendRemoteBatch(ctx context.Context, } for _, msgChunk := range annBatch { - msgChunk := msgChunk // With the syncers taken care of, we'll merge the sender map // with the set of syncers, so we don't send out duplicate diff --git a/discovery/gossiper_test.go b/discovery/gossiper_test.go index 199532642d1..d6fe209c0bb 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 1fd007295c4..f27ba7be544 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 9b6b02fa06c..34766eb453b 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 683b4dfa328..c110fc7a9d9 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.go b/funding/batch.go index d95941e8476..23733d33df8 100644 --- a/funding/batch.go +++ b/funding/batch.go @@ -301,7 +301,6 @@ func (b *Batcher) BatchFund(ctx context.Context, // Launch a goroutine that waits for the initial response on // either the update or error chan. - channel := channel eg.Go(func() error { return b.waitForUpdate(channel, true) }) @@ -415,7 +414,6 @@ func (b *Batcher) BatchFund(ctx context.Context, for _, channel := range b.channels { // Launch another goroutine that waits for the channel pending // response on the update chan. - channel := channel eg.Go(func() error { return b.waitForUpdate(channel, false) }) diff --git a/funding/batch_test.go b/funding/batch_test.go index 7a674d60be8..ee74082a449 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 48b1a62ac85..75907dfce16 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 42209127f42..b4581cecc08 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 5b6243954cc..d9e1c2c5a6f 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() @@ -2076,7 +2074,7 @@ func createTestGraphFromChannels(t *testing.T, useCache bool, } } - channelID++ //nolint:ineffassign + channelID++ //nolint:ineffassign,wastedassign } return &testGraphInstance{ diff --git a/graph/db/graph_test.go b/graph/db/graph_test.go index 3d0156ff079..e524f0b1fca 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 ab435a98684..e3d1efd9cf0 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 bd0081cb937..7b3e5683622 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 29b4f902d0b..6a518cbfa20 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 e8176aaeb59..9dfe22e7b4f 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 1fccd168683..dea5d3d317e 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 88a66c75aef..b0531b1b811 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 7defa9eb1a3..8405092f91e 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 42e84c78184..a5631767678 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.go b/invoices/invoiceregistry.go index 6528c4b1cac..8ad92e1ca52 100644 --- a/invoices/invoiceregistry.go +++ b/invoices/invoiceregistry.go @@ -196,7 +196,6 @@ func (i *InvoiceRegistry) scanInvoicesOnStart(ctx context.Context) error { var pending []invoiceExpiry for paymentHash, invoice := range pendingInvoices { - invoice := invoice expiryRef := makeInvoiceExpiry(paymentHash, &invoice) if expiryRef != nil { pending = append(pending, expiryRef) @@ -509,7 +508,6 @@ func (i *InvoiceRegistry) deliverBacklogEvents(ctx context.Context, for _, addEvent := range addEvents { // We re-bind the loop variable to ensure we don't hold onto // the loop reference causing is to point to the same item. - addEvent := addEvent select { case client.ntfnQueue.ChanIn() <- &invoiceEvent{ @@ -523,7 +521,6 @@ func (i *InvoiceRegistry) deliverBacklogEvents(ctx context.Context, for _, settleEvent := range settleEvents { // We re-bind the loop variable to ensure we don't hold onto // the loop reference causing is to point to the same item. - settleEvent := settleEvent select { case client.ntfnQueue.ChanIn() <- &invoiceEvent{ diff --git a/invoices/invoiceregistry_test.go b/invoices/invoiceregistry_test.go index 785da115ee4..cad3e27d787 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 0f7e473ebff..5cfb76c58ca 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) @@ -2816,7 +2813,7 @@ func testDeleteCanceledInvoices(t *testing.T, // Cancel every second invoice. if i%2 == 0 { - invoice, err = db.UpdateInvoice( + _, err = db.UpdateInvoice( ctxb, invpkg.InvoiceRefByHash(paymentHash), nil, updateFunc, ) diff --git a/invoices/kv_sql_migration_test.go b/invoices/kv_sql_migration_test.go index 709a3c8e106..d14a63f58ce 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 6069fbecd76..d6e4ed9e363 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_channel_force_close_test.go b/itest/lnd_channel_force_close_test.go index 60e2a61d12b..817a3567dce 100644 --- a/itest/lnd_channel_force_close_test.go +++ b/itest/lnd_channel_force_close_test.go @@ -997,7 +997,7 @@ func runChannelForceClosureTestRestart(ht *lntest.HarnessTest, sweeps = ht.AssertNumPendingSweeps(alice, 2) commitSweep, anchorSweep := sweeps[0], sweeps[1] if commitSweep.AmountSat < anchorSweep.AmountSat { - commitSweep, anchorSweep = anchorSweep, commitSweep + commitSweep = anchorSweep } // Alice's sweeping transaction should now be broadcast. So we fetch the diff --git a/itest/lnd_coop_close_rbf_test.go b/itest/lnd_coop_close_rbf_test.go index f1acf0288f1..f607e50583f 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 06d4dc9abb1..b35b526fd93 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 53b1dd6b3dd..3821229faf9 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 d3a0a0b41d2..678a0d708aa 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 70c50c3b399..ddd48b1df18 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 47725f12b00..ca596d10d9f 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_psbt_test.go b/itest/lnd_psbt_test.go index e0c07408fe7..c70803d1da0 100644 --- a/itest/lnd_psbt_test.go +++ b/itest/lnd_psbt_test.go @@ -1920,7 +1920,7 @@ func testPsbtChanFundingWithUnstableUtxos(ht *lntest.HarnessTest) { // Consume the "channel pending" update. This waits until the funding // transaction was fully compiled. updateResp = ht.ReceiveOpenChannelUpdate(chanUpdates) - upd, ok = updateResp.Update.(*lnrpc.OpenStatusUpdate_ChanPending) + _, ok = updateResp.Update.(*lnrpc.OpenStatusUpdate_ChanPending) require.True(ht, ok) err = finalTx.Deserialize(bytes.NewReader(finalizeRes.RawFinalTx)) diff --git a/itest/lnd_rest_api_test.go b/itest/lnd_rest_api_test.go index 70e10320822..5ec4823f377 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 e0409af32e2..3a82e5a991a 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 c073cb50be2..e6b25b657f9 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 4a08fb2e6cf..39774ba192e 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 ac82ba0d503..84602ec1d2c 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/keychain/interface_test.go b/keychain/interface_test.go index 8d27aa94f1e..c88384bacd1 100644 --- a/keychain/interface_test.go +++ b/keychain/interface_test.go @@ -345,7 +345,7 @@ func TestSecretKeyRingDerivation(t *testing.T) { // If we attempt to query for this key, then we // should get ErrCannotDerivePrivKey. - privKey, err = secretKeyRing.DerivePrivKey( + _, err = secretKeyRing.DerivePrivKey( keyDesc, ) if err != ErrCannotDerivePrivKey { diff --git a/lnencrypt/crypto_test.go b/lnencrypt/crypto_test.go index 42ebe1cc276..dfe224f639a 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/devrpc/dev_server.go b/lnrpc/devrpc/dev_server.go index 3cecb36b5ef..e338a9b4d89 100644 --- a/lnrpc/devrpc/dev_server.go +++ b/lnrpc/devrpc/dev_server.go @@ -270,7 +270,6 @@ func (s *Server) ImportGraph(ctx context.Context, } for _, rpcEdge := range graph.Edges { - rpcEdge := rpcEdge node1, err := parsePubKey(rpcEdge.Node1Pub) if err != nil { diff --git a/lnrpc/invoicesrpc/addinvoice_test.go b/lnrpc/invoicesrpc/addinvoice_test.go index 104b2873dde..41ab63e36db 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 d36c8be3954..66c8c3bbd3a 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 d4ff2242002..b494ffb2267 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.go b/lnrpc/walletrpc/walletkit_server.go index bece6001d6a..e04bcdd6fcc 100644 --- a/lnrpc/walletrpc/walletkit_server.go +++ b/lnrpc/walletrpc/walletkit_server.go @@ -2273,7 +2273,6 @@ func (w *WalletKit) handleChange(packet *psbt.Packet, changeIndex int32, func marshallLeases(locks []*base.ListLeasedOutputResult) []*UtxoLease { rpcLocks := make([]*UtxoLease, len(locks)) for idx, lock := range locks { - lock := lock rpcLocks[idx] = &UtxoLease{ Id: lock.LockID[:], diff --git a/lnrpc/walletrpc/walletkit_server_test.go b/lnrpc/walletrpc/walletkit_server_test.go index 40fb62ef2ad..041a9d1a4e2 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 fdc8d2e0ab1..097c51315e8 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 3e96d4faf9e..c2325044137 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/btcwallet.go b/lnwallet/btcwallet/btcwallet.go index 354238d59de..92b5f4017ea 100644 --- a/lnwallet/btcwallet/btcwallet.go +++ b/lnwallet/btcwallet/btcwallet.go @@ -618,7 +618,6 @@ func (b *BtcWallet) ListAccounts(name string, return nil, err } for _, account := range accounts.Accounts { - account := account res = append(res, &account.AccountProperties) } @@ -631,7 +630,6 @@ func (b *BtcWallet) ListAccounts(name string, return nil, err } for _, account := range accounts.Accounts { - account := account res = append(res, &account.AccountProperties) } } @@ -644,7 +642,6 @@ func (b *BtcWallet) ListAccounts(name string, return nil, err } for _, account := range accounts.Accounts { - account := account res = append(res, &account.AccountProperties) } } diff --git a/lnwallet/btcwallet/psbt_test.go b/lnwallet/btcwallet/psbt_test.go index 694a8c04f11..4423be00c0d 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 6f288c224d3..803296fa2ff 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 3d355d5034d..67fe6d41b3b 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 085814d969f..0271c81e783 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 16afb656b6f..a89a5b90e9a 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 e20259c86c2..312ae7d07e0 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 461b83f5a1b..71988e21c04 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.go b/lnwallet/channel.go index 78ca895655a..e60ebb6f4b1 100644 --- a/lnwallet/channel.go +++ b/lnwallet/channel.go @@ -603,8 +603,6 @@ func (lc *LightningChannel) extractPayDescs(feeRate chainfee.SatPerKWeight, // persist state w.r.t to if forwarded or not, or can // inadvertently trigger replays - htlc := htlc - auxLeaf := fn.FlatMapOption( func(l CommitAuxLeaves) input.AuxTapLeaf { leaves := l.OutgoingHtlcLeaves @@ -1774,7 +1772,6 @@ func (lc *LightningChannel) restorePendingRemoteUpdates( len(unsignedAckedUpdates)) for _, logUpdate := range unsignedAckedUpdates { - logUpdate := logUpdate payDesc, err := lc.remoteLogUpdateToPayDesc( &logUpdate, lc.updateLogs.Local, localCommitmentHeight, @@ -1854,7 +1851,6 @@ func (lc *LightningChannel) restorePeerLocalUpdates(updates []channeldb.LogUpdat len(updates)) for _, logUpdate := range updates { - logUpdate := logUpdate payDesc, err := lc.localLogUpdateToPayDesc( &logUpdate, lc.updateLogs.Remote, @@ -1908,7 +1904,6 @@ func (lc *LightningChannel) restorePendingLocalUpdates( // If we did have a dangling commit, then we'll examine which updates // we included in that state and re-insert them into our update log. for _, logUpdate := range pendingRemoteCommitDiff.LogUpdates { - logUpdate := logUpdate payDesc, err := lc.logUpdateToPayDesc( &logUpdate, lc.updateLogs.Remote, pendingHeight, @@ -8189,7 +8184,6 @@ func extractHtlcResolutions(feePerKw chainfee.SatPerKWeight, incomingResolutions := make([]IncomingHtlcResolution, 0, len(htlcs)) outgoingResolutions := make([]OutgoingHtlcResolution, 0, len(htlcs)) for _, htlc := range htlcs { - htlc := htlc // We'll skip any HTLC's which were dust on the commitment // transaction, as these don't have a corresponding output @@ -9065,8 +9059,7 @@ func NewAnchorResolution(chanState *channeldb.OpenChannel, return nil, err } if chanState.ChanType.IsTaproot() && whoseCommit.IsRemote() { - //nolint:ineffassign - localAnchor, remoteAnchor = remoteAnchor, localAnchor + localAnchor = remoteAnchor } // TODO(roasbeef): remote anchor not needed above diff --git a/lnwallet/channel_test.go b/lnwallet/channel_test.go index ab96d339749..2d04c3092d6 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) @@ -1385,7 +1384,6 @@ func TestForceCloseDustOutput(t *testing.T) { htlcAmount := lnwire.NewMSatFromSatoshis(500) - aliceAmount := aliceChannel.channelState.LocalCommitment.LocalBalance bobAmount := bobChannel.channelState.LocalCommitment.LocalBalance // Have Bobs' to-self output be below her dust limit and check @@ -1410,8 +1408,7 @@ func TestForceCloseDustOutput(t *testing.T) { t.Fatalf("Can't update the channel state: %v", err) } - aliceAmount = aliceChannel.channelState.LocalCommitment.LocalBalance - bobAmount = bobChannel.channelState.LocalCommitment.RemoteBalance + aliceAmount := aliceChannel.channelState.LocalCommitment.LocalBalance closeSummary, err := aliceChannel.ForceClose() require.NoError(t, err, "unable to force close channel") @@ -7106,7 +7103,6 @@ func TestChanReserve(t *testing.T) { // Bob: 5.0 htlcAmt := lnwire.NewMSatFromSatoshis(0.5 * btcutil.SatoshiPerBitcoin) htlc, _ := createHTLC(aliceIndex, htlcAmt) - aliceIndex++ addAndReceiveHTLC(t, aliceChannel, bobChannel, htlc, nil) // Force a state transition, making sure this HTLC is considered valid @@ -7128,7 +7124,6 @@ func TestChanReserve(t *testing.T) { // Alice: 4.5 // Bob: 5.0 htlc, _ = createHTLC(bobIndex, htlcAmt) - bobIndex++ _, err := bobChannel.AddHTLC(htlc, nil) require.ErrorIs(t, err, ErrBelowChanReserve) @@ -7141,7 +7136,6 @@ func TestChanReserve(t *testing.T) { aliceChannel, bobChannel = setupChannels() aliceIndex = 0 - bobIndex = 0 // Now we'll add HTLC of 3.5 BTC to Alice's commitment, this should put // Alice's balance at 1.5 BTC. @@ -7162,7 +7156,6 @@ func TestChanReserve(t *testing.T) { // balance dip below. htlcAmt = lnwire.NewMSatFromSatoshis(1 * btcutil.SatoshiPerBitcoin) htlc, _ = createHTLC(aliceIndex, htlcAmt) - aliceIndex++ _, err = aliceChannel.AddHTLC(htlc, nil) require.ErrorIs(t, err, ErrBelowChanReserve) @@ -7183,7 +7176,6 @@ func TestChanReserve(t *testing.T) { // Bob: 7.0 htlcAmt = lnwire.NewMSatFromSatoshis(2 * btcutil.SatoshiPerBitcoin) htlc, preimage := createHTLC(aliceIndex, htlcAmt) - aliceIndex++ aliceHtlcIndex, err := aliceChannel.AddHTLC(htlc, nil) require.NoError(t, err, "unable to add htlc") bobHtlcIndex, err := bobChannel.ReceiveHTLC(htlc) @@ -7219,7 +7211,6 @@ func TestChanReserve(t *testing.T) { // the fee this is okay. htlcAmt = lnwire.NewMSatFromSatoshis(1 * btcutil.SatoshiPerBitcoin) htlc, _ = createHTLC(bobIndex, htlcAmt) - bobIndex++ addAndReceiveHTLC(t, bobChannel, aliceChannel, htlc, nil) // Do a last state transition, which should succeed. @@ -7623,7 +7614,7 @@ func TestChannelRestoreUpdateLogs(t *testing.T) { // and remote commit chains are updated in an async fashion. Since the // remote chain was updated with the latest state (since Bob sent the // revocation earlier) we can keep advancing the remote commit chain. - aliceNewCommit, err = aliceChannel.SignNextCommitment(ctxb) + _, err = aliceChannel.SignNextCommitment(ctxb) require.NoError(t, err, "unable to sign commitment") // After Alice has signed this commitment, her local commitment will @@ -8927,7 +8918,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 +9264,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 +10301,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 +10729,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 53165fc2369..2b50b28aef9 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 3cee8f3e659..eef7e3640c1 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/test/test_interface.go b/lnwallet/test/test_interface.go index 8d180ca1006..90ea46d7552 100644 --- a/lnwallet/test/test_interface.go +++ b/lnwallet/test/test_interface.go @@ -3540,8 +3540,6 @@ func runTests(t *testing.T, walletDriver *lnwallet.WalletDriver, // wallet state after each step. for _, walletTest := range walletTests { - walletTest := walletTest - testName := fmt.Sprintf("%v/%v:%v", walletType, backEnd, walletTest.name) success := t.Run(testName, func(t *testing.T) { diff --git a/lnwallet/transactions_test.go b/lnwallet/transactions_test.go index 38131eaa724..42639a4e6bb 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/lnwallet/wallet.go b/lnwallet/wallet.go index daba0992577..09cfca1e881 100644 --- a/lnwallet/wallet.go +++ b/lnwallet/wallet.go @@ -619,7 +619,6 @@ func (l *LightningWallet) ListUnspentWitnessFromDefaultAccount( func (l *LightningWallet) LockedOutpoints() []*wire.OutPoint { outPoints := make([]*wire.OutPoint, 0, len(l.lockedOutPoints)) for outPoint := range l.lockedOutPoints { - outPoint := outPoint outPoints = append(outPoints, &outPoint) } diff --git a/lnwire/accept_channel_test.go b/lnwire/accept_channel_test.go index 87d9dc029cc..b0b199ef7ad 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 c77ddd4d10b..f18e7b37970 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 e1b3c859c8d..1652f042421 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 a3bbea5b70c..1eae2509658 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 0cc60cf1a4c..adbef29dc36 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 5d690f38ddb..53c6bda94d6 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 996c9f744c5..a147061e6ed 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 12955cfd9c1..ac95066a5a4 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 73263f1a667..c47bf97afeb 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 bb2bada06ad..4f15ba52d79 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 2a619e062e5..fe0bc33bf5d 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 c43a9ef1c66..4f7885c2c2b 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/migration1/payment.go b/payments/db/migration1/payment.go index 78599c3ed63..fbc1b21e5bb 100644 --- a/payments/db/migration1/payment.go +++ b/payments/db/migration1/payment.go @@ -335,7 +335,6 @@ func (m *MPPayment) InFlightHTLCs() []HTLCAttempt { func (m *MPPayment) GetAttempt(id uint64) (*HTLCAttempt, error) { // TODO(yy): iteration can be slow, make it into a tree or use BS. for _, htlc := range m.HTLCs { - htlc := htlc if htlc.AttemptID == id { return &htlc, nil } diff --git a/payments/db/payment.go b/payments/db/payment.go index ddceedfb0f0..0c928b4d6ed 100644 --- a/payments/db/payment.go +++ b/payments/db/payment.go @@ -416,7 +416,6 @@ func (m *MPPayment) InFlightHTLCs() []HTLCAttempt { func (m *MPPayment) GetAttempt(id uint64) (*HTLCAttempt, error) { // TODO(yy): iteration can be slow, make it into a tree or use BS. for _, htlc := range m.HTLCs { - htlc := htlc if htlc.AttemptID == id { return &htlc, nil } diff --git a/payments/db/payment_status_test.go b/payments/db/payment_status_test.go index 1bb4dc3889a..b5c762d071d 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 e304b136dd2..e77a1522a1e 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 f4bb661ea38..0dc218d5cc5 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 bc1230be8b9..0620e9ba596 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 45faa9f73d7..92902fa310f 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 0324e2e1063..34fd2197a9f 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 b7f6e3f13b2..ff5529f3457 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 0020f381caf..3f4cb759788 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 0a8846adb7c..2ca9b631d67 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 9636b10f7c7..035c228fd7f 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 c48e6164160..92d8ce05102 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.go b/routing/missioncontrol.go index b03724a2e62..c31a223bf73 100644 --- a/routing/missioncontrol.go +++ b/routing/missioncontrol.go @@ -709,7 +709,6 @@ func (m *MissionControl) applyPaymentResult( } for pair, pairResult := range i.pairResults { - pairResult := pairResult if pairResult.success { m.log.Debugf("Reporting pair success to Mission "+ diff --git a/routing/missioncontrol_store_test.go b/routing/missioncontrol_store_test.go index 889dca07135..9cfd118a022 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 85689ef9ed1..f43a5c8952a 100644 --- a/routing/pathfind_test.go +++ b/routing/pathfind_test.go @@ -797,8 +797,6 @@ func createTestGraphFromChannels(t *testing.T, useCache bool, return nil, err } } - - channelID++ } return &testGraphInstance{ @@ -899,7 +897,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 +908,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 +1682,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 +2799,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 +3711,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.go b/routing/payment_lifecycle.go index 488df5b796e..2b8180c23d7 100644 --- a/routing/payment_lifecycle.go +++ b/routing/payment_lifecycle.go @@ -1148,8 +1148,6 @@ func (p *paymentLifecycle) reloadInflightAttempts( } for _, a := range payment.InFlightHTLCs() { - a := a - log.Infof("Resuming HTLC attempt %v for payment %v", a.AttemptID, p.identifier) diff --git a/routing/payment_lifecycle_test.go b/routing/payment_lifecycle_test.go index 564942d327e..3405821a2d1 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 0bc0b6dcbd6..7ad44b8be41 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 b7df8ae6e04..0527d2d4102 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 57590a865cb..b7ecda213b9 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 83cfc074906..b7d104d7493 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.go b/routing/router.go index 37aeef22361..956bc125e4b 100644 --- a/routing/router.go +++ b/routing/router.go @@ -1476,7 +1476,6 @@ func (r *ChannelRouter) resumePayments() error { // Get the hashes used for the outstanding HTLCs. htlcs := make(map[uint64]lntypes.Hash) for _, a := range payment.HTLCs { - a := a // We check whether the individual attempts have their // HTLC hash set, if not we'll fall back to the overall diff --git a/routing/router_test.go b/routing/router_test.go index e14ac199f83..7dd340c2a4e 100644 --- a/routing/router_test.go +++ b/routing/router_test.go @@ -165,6 +165,7 @@ func createTestCtxFromGraphInstanceAssumeValid(t *testing.T, &mockTrafficShaper{}, ), }) + require.NoError(t, err, "unable to create router") require.NoError(t, router.Start(), "unable to start router") ctx := &testCtx{ @@ -1423,8 +1424,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 +2085,6 @@ func TestInboundOutbound(t *testing.T) { } for _, tc := range tests { - tc := tc t.Run(tc.name, func(tt *testing.T) { testInboundOutboundFee( @@ -2692,7 +2690,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 25c8e9220b9..6faf2efe783 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/rpcserver.go b/rpcserver.go index 8b40192db84..13b96aa4dfb 100644 --- a/rpcserver.go +++ b/rpcserver.go @@ -6016,7 +6016,6 @@ func (r *rpcServer) ListInvoices(ctx context.Context, LastIndexOffset: invoiceSlice.LastIndexOffset, } for i, invoice := range invoiceSlice.Invoices { - invoice := invoice resp.Invoices[i], err = invoicesrpc.CreateRPCInvoice( &invoice, r.cfg.ActiveNetParams.Params, ) @@ -7027,7 +7026,6 @@ func (r *rpcServer) ListPayments(ctx context.Context, } for _, payment := range paymentsQuerySlice.Payments { - payment := payment rpcPayment, err := r.routerBackend.MarshallPayment(payment) if err != nil { diff --git a/sweep/aggregator_test.go b/sweep/aggregator_test.go index 2cb89bdc385..41d0b44faf8 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 d697f906b2a..cccb9b4229f 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 a55ce79a784..d9730844440 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.go b/sweep/sweeper.go index e2163f6373c..379300e9635 100644 --- a/sweep/sweeper.go +++ b/sweep/sweeper.go @@ -747,7 +747,6 @@ func (s *UtxoSweeper) collector() { // those inputs will be removed from the wallet. func (s *UtxoSweeper) removeExclusiveGroup(group uint64, op wire.OutPoint) { for outpoint, input := range s.inputs { - outpoint := outpoint // Skip the input that caused the exclusive group to be removed. if outpoint == op { diff --git a/sweep/sweeper_test.go b/sweep/sweeper_test.go index d97fd992504..917119e008f 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 3f2051646a4..bedb3e70705 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 c7a5dfc2212..b6bed3b9b8f 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 541b123c45d..9cb88c264d7 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 0d23e2e0fc1..0934c4e0959 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 62d7609469e..afdb4545c71 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/client_test.go b/watchtower/wtclient/client_test.go index 1b50600ae89..5b4753977e4 100644 --- a/watchtower/wtclient/client_test.go +++ b/watchtower/wtclient/client_test.go @@ -334,7 +334,6 @@ func (c *mockChannel) createRemoteCommitTx(t *testing.T) { SignMethod: input.TaprootScriptSpendSignMethod, ControlBlock: ctrlBytes, } - outputIndex++ } txid := commitTxn.TxHash() @@ -357,7 +356,6 @@ func (c *mockChannel) createRemoteCommitTx(t *testing.T) { Hash: txid, Index: uint32(outputIndex), } - outputIndex++ } commitKeyRing := &lnwallet.CommitmentKeyRing{ diff --git a/watchtower/wtclient/queue_test.go b/watchtower/wtclient/queue_test.go index a8494c2166b..66fe20c2a6f 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 acae177ada9..d75503d6790 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 c1436184fc6..b74c00f11f5 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 a2fc8aedfbb..8cd3796aa58 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 267cfe17d74..917b01dccd4 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 a0a67e5f535..ec29dfdb02c 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 c4928e2f965..9b3880f0692 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 40eeec5b093..2480b27abb8 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 22434a99b5a..c2729e8c61c 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 bfa1539f3ec..cec6bfd741d 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()