diff --git a/pkg/api/api_test.go b/pkg/api/api_test.go index 46473a3a253..fbe43a9e361 100644 --- a/pkg/api/api_test.go +++ b/pkg/api/api_test.go @@ -465,7 +465,6 @@ func TestPostageHeaderError(t *testing.T) { ) content := []byte{7: 0} // 8 zeros for _, endpoint := range endpoints { - endpoint := endpoint t.Run(endpoint+": empty batch", func(t *testing.T) { t.Parallel() @@ -569,7 +568,6 @@ func TestPostageDirectAndDeferred(t *testing.T) { t.Parallel() for _, endpoint := range []string{"bytes", "bzz", "chunks"} { - endpoint := endpoint if endpoint != "chunks" { t.Run(endpoint+" deferred", func(t *testing.T) { diff --git a/pkg/api/balances_test.go b/pkg/api/balances_test.go index 4cb985fefc0..63733825287 100644 --- a/pkg/api/balances_test.go +++ b/pkg/api/balances_test.go @@ -338,7 +338,6 @@ func Test_peerBalanceHandler_invalidInputs(t *testing.T) { }} for _, tc := range tests { - tc := tc t.Run(tc.name, func(t *testing.T) { t.Parallel() @@ -387,7 +386,6 @@ func Test_compensatedPeerBalanceHandler_invalidInputs(t *testing.T) { }} for _, tc := range tests { - tc := tc t.Run(tc.name, func(t *testing.T) { t.Parallel() diff --git a/pkg/api/bytes_test.go b/pkg/api/bytes_test.go index abae06bc2c6..4323dc0c33b 100644 --- a/pkg/api/bytes_test.go +++ b/pkg/api/bytes_test.go @@ -314,7 +314,6 @@ func TestBytesUploadHandlerInvalidInputs(t *testing.T) { } for _, tc := range tests { - tc := tc t.Run(tc.name, func(t *testing.T) { t.Parallel() @@ -364,7 +363,6 @@ func TestBytesGetHandlerInvalidInputs(t *testing.T) { }} for _, tc := range tests { - tc := tc t.Run(tc.name, func(t *testing.T) { t.Parallel() diff --git a/pkg/api/bzz_test.go b/pkg/api/bzz_test.go index 634d4eb0166..e932f9491fe 100644 --- a/pkg/api/bzz_test.go +++ b/pkg/api/bzz_test.go @@ -199,10 +199,9 @@ func TestBzzUploadDownloadWithRedundancy(t *testing.T) { }) } for _, rLevel := range []redundancy.Level{1, 2, 3, 4} { - rLevel := rLevel + t.Run(fmt.Sprintf("level=%d", rLevel), func(t *testing.T) { for _, encrypt := range []bool{false, true} { - encrypt := encrypt shardCnt := rLevel.GetMaxShards() parityCnt := rLevel.GetParities(shardCnt) if encrypt { @@ -219,7 +218,6 @@ func TestBzzUploadDownloadWithRedundancy(t *testing.T) { case 3: chunkCnt = shardCnt*shardCnt + 1 } - levels := levels t.Run(fmt.Sprintf("encrypt=%v levels=%d chunks=%d", encrypt, levels, chunkCnt), func(t *testing.T) { if levels > 2 && (encrypt == (rLevel%2 == 1)) { t.Skip("skipping to save time") @@ -598,7 +596,7 @@ func TestBzzFilesRangeRequests(t *testing.T) { } for _, upload := range uploads { - upload := upload + t.Run(upload.name, func(t *testing.T) { t.Parallel() @@ -865,7 +863,6 @@ func Test_bzzDownloadHandler_invalidInputs(t *testing.T) { }} for _, tc := range tests { - tc := tc t.Run(tc.name, func(t *testing.T) { t.Parallel() diff --git a/pkg/api/chequebook_test.go b/pkg/api/chequebook_test.go index f12d41be999..fba0f888eeb 100644 --- a/pkg/api/chequebook_test.go +++ b/pkg/api/chequebook_test.go @@ -768,7 +768,6 @@ func Test_chequebookLastPeerHandler_invalidInputs(t *testing.T) { }} for _, tc := range tests { - tc := tc t.Run(tc.name, func(t *testing.T) { t.Parallel() diff --git a/pkg/api/chunk_test.go b/pkg/api/chunk_test.go index 21c98a8c011..10ea0e00985 100644 --- a/pkg/api/chunk_test.go +++ b/pkg/api/chunk_test.go @@ -173,7 +173,6 @@ func TestChunkHandlersInvalidInputs(t *testing.T) { method := http.MethodGet for _, tc := range tests { - tc := tc t.Run(method+" "+tc.name, func(t *testing.T) { t.Parallel() diff --git a/pkg/api/cors_test.go b/pkg/api/cors_test.go index c8b9fae3512..07bef5cadfa 100644 --- a/pkg/api/cors_test.go +++ b/pkg/api/cors_test.go @@ -79,7 +79,7 @@ func TestCORSHeaders(t *testing.T) { wantCORS: false, }, } { - tc := tc + t.Run(tc.name, func(t *testing.T) { t.Parallel() @@ -156,7 +156,7 @@ func TestCors(t *testing.T) { expectedMethods: "GET, HEAD", }, } { - tc := tc + t.Run(tc.endpoint, func(t *testing.T) { t.Parallel() @@ -212,7 +212,7 @@ func TestCorsStatus(t *testing.T) { allowedMethods: "GET, HEAD", }, } { - tc := tc + t.Run(tc.endpoint, func(t *testing.T) { t.Parallel() diff --git a/pkg/api/logger_test.go b/pkg/api/logger_test.go index e29341355a1..91ba2c2b939 100644 --- a/pkg/api/logger_test.go +++ b/pkg/api/logger_test.go @@ -178,7 +178,7 @@ func Test_loggerGetHandler_invalidInputs(t *testing.T) { }} for _, tc := range tests { - tc := tc + t.Run(tc.name, func(t *testing.T) { t.Parallel() @@ -244,7 +244,7 @@ func Test_loggerSetVerbosityHandler_invalidInputs(t *testing.T) { }} for _, tc := range tests { - tc := tc + t.Run(tc.name, func(t *testing.T) { t.Parallel() diff --git a/pkg/api/peer_test.go b/pkg/api/peer_test.go index eb1ec3ffb6a..e5edc66f074 100644 --- a/pkg/api/peer_test.go +++ b/pkg/api/peer_test.go @@ -246,7 +246,7 @@ func Test_peerConnectHandler_invalidInputs(t *testing.T) { }} for _, tc := range tests { - tc := tc + t.Run(tc.name, func(t *testing.T) { t.Parallel() @@ -295,7 +295,7 @@ func Test_peerDisconnectHandler_invalidInputs(t *testing.T) { }} for _, tc := range tests { - tc := tc + t.Run(tc.name, func(t *testing.T) { t.Parallel() diff --git a/pkg/api/pin_test.go b/pkg/api/pin_test.go index 751b93b1d65..221fc175938 100644 --- a/pkg/api/pin_test.go +++ b/pkg/api/pin_test.go @@ -172,9 +172,9 @@ func TestPinHandlersInvalidInputs(t *testing.T) { }} for _, method := range []string{http.MethodGet, http.MethodPost, http.MethodDelete} { - method := method + for _, tc := range tests { - tc := tc + t.Run(method+" "+tc.name, func(t *testing.T) { t.Parallel() diff --git a/pkg/api/pingpong_test.go b/pkg/api/pingpong_test.go index b97bdd77413..084e7c00580 100644 --- a/pkg/api/pingpong_test.go +++ b/pkg/api/pingpong_test.go @@ -114,7 +114,7 @@ func Test_pingpongHandler_invalidInputs(t *testing.T) { }} for _, tc := range tests { - tc := tc + t.Run(tc.name, func(t *testing.T) { t.Parallel() diff --git a/pkg/api/postage_test.go b/pkg/api/postage_test.go index a7055ed098a..4fab9b80537 100644 --- a/pkg/api/postage_test.go +++ b/pkg/api/postage_test.go @@ -790,8 +790,6 @@ func TestPostageAccessHandler(t *testing.T) { for _, op1 := range success { for _, op2 := range failure { - op1 := op1 - op2 := op2 t.Run(op1.name+"-"+op2.name, func(t *testing.T) { t.Parallel() @@ -935,7 +933,7 @@ func Test_postageGetStampBucketsHandler_invalidInputs(t *testing.T) { }} for _, tc := range tests { - tc := tc + t.Run(tc.name, func(t *testing.T) { t.Parallel() @@ -997,7 +995,7 @@ func Test_postageGetStampHandler_invalidInputs(t *testing.T) { }} for _, tc := range tests { - tc := tc + t.Run(tc.name, func(t *testing.T) { t.Parallel() diff --git a/pkg/api/pss_test.go b/pkg/api/pss_test.go index d40a4889d4e..c4bace588bc 100644 --- a/pkg/api/pss_test.go +++ b/pkg/api/pss_test.go @@ -435,7 +435,7 @@ func TestPssPostHandlerInvalidInputs(t *testing.T) { }} for _, tc := range tests { - tc := tc + t.Run(tc.name, func(t *testing.T) { t.Parallel() diff --git a/pkg/api/settlements_test.go b/pkg/api/settlements_test.go index bc06f540452..4f1219d12bb 100644 --- a/pkg/api/settlements_test.go +++ b/pkg/api/settlements_test.go @@ -213,7 +213,7 @@ func Test_peerSettlementsHandler_invalidInputs(t *testing.T) { }} for _, tc := range tests { - tc := tc + t.Run(tc.name, func(t *testing.T) { t.Parallel() diff --git a/pkg/api/staking_test.go b/pkg/api/staking_test.go index 8f10d4f6e24..ad7d132a563 100644 --- a/pkg/api/staking_test.go +++ b/pkg/api/staking_test.go @@ -161,7 +161,7 @@ func Test_stakingDepositHandler_invalidInputs(t *testing.T) { }} for _, tc := range tests { - tc := tc + t.Run(tc.name, func(t *testing.T) { t.Parallel() diff --git a/pkg/api/stewardship_test.go b/pkg/api/stewardship_test.go index 005b0bd66ad..3c18ab2eb89 100644 --- a/pkg/api/stewardship_test.go +++ b/pkg/api/stewardship_test.go @@ -99,9 +99,9 @@ func TestStewardshipInvalidInputs(t *testing.T) { }} for _, method := range []string{http.MethodGet, http.MethodPut} { - method := method + for _, tc := range tests { - tc := tc + t.Run(method+" "+tc.name, func(t *testing.T) { t.Parallel() diff --git a/pkg/api/subdomain_test.go b/pkg/api/subdomain_test.go index 9dfd0143bde..8e9b230a2b8 100644 --- a/pkg/api/subdomain_test.go +++ b/pkg/api/subdomain_test.go @@ -88,7 +88,7 @@ func TestSubdomains(t *testing.T) { }, }, } { - tc := tc + t.Run(tc.name, func(t *testing.T) { t.Parallel() diff --git a/pkg/api/tag_test.go b/pkg/api/tag_test.go index dea820e3860..fc2ac904879 100644 --- a/pkg/api/tag_test.go +++ b/pkg/api/tag_test.go @@ -222,9 +222,9 @@ func TestTagsHandlersInvalidInputs(t *testing.T) { }} for _, method := range []string{http.MethodGet, http.MethodDelete, http.MethodPatch} { - method := method + for _, tc := range tests { - tc := tc + t.Run(method+" "+tc.name, func(t *testing.T) { t.Parallel() diff --git a/pkg/api/util_test.go b/pkg/api/util_test.go index 5f8dd3564b4..fef6ad2fda0 100644 --- a/pkg/api/util_test.go +++ b/pkg/api/util_test.go @@ -499,7 +499,6 @@ func TestMapStructure(t *testing.T) { want: &mapSwarmAddressTest{SwarmAddressVal: swarm.MustParseHexAddress("1234567890abcdef")}, }} for _, tc := range tests { - tc := tc t.Run(tc.name, func(t *testing.T) { t.Parallel() diff --git a/pkg/auth/auth_test.go b/pkg/auth/auth_test.go index 28f16b58e0e..2afe573db1c 100644 --- a/pkg/auth/auth_test.go +++ b/pkg/auth/auth_test.go @@ -42,7 +42,7 @@ func TestAuthorize(t *testing.T) { }, } for _, tC := range tt { - tC := tC + t.Run(tC.desc, func(t *testing.T) { t.Parallel() @@ -130,7 +130,7 @@ func TestEnforce(t *testing.T) { } for _, tC := range tt { - tC := tC + t.Run(tC.desc, func(t *testing.T) { t.Parallel() diff --git a/pkg/bmt/bmt_test.go b/pkg/bmt/bmt_test.go index c74e5bdf0e8..b9b0a59308b 100644 --- a/pkg/bmt/bmt_test.go +++ b/pkg/bmt/bmt_test.go @@ -60,7 +60,7 @@ func TestHasherEmptyData(t *testing.T) { t.Parallel() for _, count := range testSegmentCounts { - count := count + t.Run(fmt.Sprintf("%d_segments", count), func(t *testing.T) { t.Parallel() @@ -88,7 +88,7 @@ func TestSyncHasherCorrectness(t *testing.T) { testData := testutil.RandBytesWithSeed(t, 4096, seed) for _, count := range testSegmentCounts { - count := count + t.Run(fmt.Sprintf("segments_%v", count), func(t *testing.T) { t.Parallel() max := count * hashSize diff --git a/pkg/bmt/proof_test.go b/pkg/bmt/proof_test.go index 1b7f6d3b3dd..b102418ea6d 100644 --- a/pkg/bmt/proof_test.go +++ b/pkg/bmt/proof_test.go @@ -211,7 +211,7 @@ func TestProof(t *testing.T) { } for i := 0; i < 128; i++ { - i := i + t.Run(fmt.Sprintf("segmentIndex %d", i), func(t *testing.T) { t.Parallel() diff --git a/pkg/cac/cac_test.go b/pkg/cac/cac_test.go index 0e70c2b392b..1dc80a3d46f 100644 --- a/pkg/cac/cac_test.go +++ b/pkg/cac/cac_test.go @@ -89,7 +89,6 @@ func TestChunkInvariantsNew(t *testing.T) { wantErr: nil, }, } { - cc := cc t.Run(cc.name, func(t *testing.T) { t.Parallel() @@ -135,7 +134,6 @@ func TestChunkInvariantsNewWithDataSpan(t *testing.T) { wantErr: nil, }, } { - cc := cc t.Run(cc.name, func(t *testing.T) { t.Parallel() @@ -219,7 +217,7 @@ func TestInvalid(t *testing.T) { ), }, } { - tc := tc + t.Run(tc.name, func(t *testing.T) { t.Parallel() diff --git a/pkg/encryption/mock/mock_test.go b/pkg/encryption/mock/mock_test.go index 69b7bf94e1d..a716cfcbfc6 100644 --- a/pkg/encryption/mock/mock_test.go +++ b/pkg/encryption/mock/mock_test.go @@ -62,7 +62,7 @@ func TestEncryptor_Encrypt(t *testing.T) { wantErr: mock.ErrInvalidXORKey, }, } { - tc := tc + t.Run(tc.name, func(t *testing.T) { t.Parallel() @@ -125,7 +125,7 @@ func TestEncryptor_Decrypt(t *testing.T) { wantErr: mock.ErrInvalidXORKey, }, } { - tc := tc + t.Run(tc.name, func(t *testing.T) { t.Parallel() diff --git a/pkg/feeds/testing/lookup.go b/pkg/feeds/testing/lookup.go index 1c70ec1183f..0e1ca685a8e 100644 --- a/pkg/feeds/testing/lookup.go +++ b/pkg/feeds/testing/lookup.go @@ -202,7 +202,6 @@ func TestFinderRandomIntervals(t *testing.T, finderf func(storage.Getter, *feeds t.Parallel() for j := 0; j < 3; j++ { - j := j t.Run(fmt.Sprintf("random intervals %d", j), func(t *testing.T) { t.Parallel() diff --git a/pkg/file/buffer_test.go b/pkg/file/buffer_test.go index b1760f9948f..0d6c626508d 100644 --- a/pkg/file/buffer_test.go +++ b/pkg/file/buffer_test.go @@ -34,7 +34,7 @@ func TestChunkPipe(t *testing.T) { {swarm.ChunkSize, swarm.ChunkSize}, // on, on } for i, tc := range dataWrites { - tc := tc + t.Run(strconv.Itoa(i), func(t *testing.T) { t.Parallel() @@ -130,7 +130,7 @@ func TestCopyBuffer(t *testing.T) { } for _, tc := range testCases { - tc := tc + t.Run(fmt.Sprintf("buf_%-4d/data_size_%d", tc.readBufferSize, tc.dataSize), func(t *testing.T) { t.Parallel() diff --git a/pkg/file/pipeline/bmt/bmt_test.go b/pkg/file/pipeline/bmt/bmt_test.go index fad40e3e3f7..f7fea7e1af3 100644 --- a/pkg/file/pipeline/bmt/bmt_test.go +++ b/pkg/file/pipeline/bmt/bmt_test.go @@ -46,7 +46,7 @@ func TestBmtWriter(t *testing.T) { expErr: bmt.ErrInvalidData, }, } { - tc := tc + t.Run(tc.name, func(t *testing.T) { t.Parallel() diff --git a/pkg/file/pipeline/builder/builder_test.go b/pkg/file/pipeline/builder/builder_test.go index 266474d9376..589a01c5b8a 100644 --- a/pkg/file/pipeline/builder/builder_test.go +++ b/pkg/file/pipeline/builder/builder_test.go @@ -87,7 +87,7 @@ func TestAllVectors(t *testing.T) { for i := 1; i <= 20; i++ { data, expect := test.GetVector(t, i) - i := i + t.Run(fmt.Sprintf("data length %d, vector %d", len(data), i), func(t *testing.T) { t.Parallel() diff --git a/pkg/file/pipeline/feeder/feeder_test.go b/pkg/file/pipeline/feeder/feeder_test.go index 470dbd7f032..6d346532eb6 100644 --- a/pkg/file/pipeline/feeder/feeder_test.go +++ b/pkg/file/pipeline/feeder/feeder_test.go @@ -75,7 +75,7 @@ func TestFeeder(t *testing.T) { span: 5, }, } { - tc := tc + t.Run(tc.name, func(t *testing.T) { t.Parallel() var results pipeline.PipeWriteArgs @@ -179,7 +179,7 @@ func TestFeederFlush(t *testing.T) { span: 3, }, } { - tc := tc + t.Run(tc.name, func(t *testing.T) { t.Parallel() diff --git a/pkg/file/pipeline/hashtrie/hashtrie_test.go b/pkg/file/pipeline/hashtrie/hashtrie_test.go index 4a966e265f3..6f6acb345d2 100644 --- a/pkg/file/pipeline/hashtrie/hashtrie_test.go +++ b/pkg/file/pipeline/hashtrie/hashtrie_test.go @@ -135,7 +135,6 @@ func TestLevels(t *testing.T) { }, } { - tc := tc t.Run(tc.desc, func(t *testing.T) { t.Parallel() @@ -312,7 +311,7 @@ func TestRedundancy(t *testing.T) { parities: 116, // // 87 (full ch) + 29 (2 ref) }, } { - tc := tc + t.Run(tc.desc, func(t *testing.T) { t.Parallel() subCtx := redundancy.SetLevelInContext(ctx, tc.level) diff --git a/pkg/file/redundancy/getter/getter_test.go b/pkg/file/redundancy/getter/getter_test.go index b18caa55c12..d6788d49de9 100644 --- a/pkg/file/redundancy/getter/getter_test.go +++ b/pkg/file/redundancy/getter/getter_test.go @@ -334,8 +334,7 @@ func checkShardsAvailable(t *testing.T, s storage.ChunkStore, addrs []swarm.Addr t.Helper() eg, ctx := errgroup.WithContext(context.Background()) for i, addr := range addrs { - i := i - addr := addr + eg.Go(func() (err error) { var delay time.Duration var ch swarm.Chunk diff --git a/pkg/hive/hive_test.go b/pkg/hive/hive_test.go index b3b0d55305d..05612f2adee 100644 --- a/pkg/hive/hive_test.go +++ b/pkg/hive/hive_test.go @@ -241,7 +241,7 @@ func TestBroadcastPeers_FLAKY(t *testing.T) { } for name, tc := range testCases { - tc := tc + t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/pkg/jsonhttp/handlers_test.go b/pkg/jsonhttp/handlers_test.go index 424d6ebfb29..66858a45db3 100644 --- a/pkg/jsonhttp/handlers_test.go +++ b/pkg/jsonhttp/handlers_test.go @@ -173,7 +173,7 @@ func TestNewMaxBodyBytesHandler(t *testing.T) { wantCode: http.StatusRequestEntityTooLarge, }, } { - tc := tc + t.Run(tc.name, func(t *testing.T) { t.Parallel() diff --git a/pkg/jsonhttp/jsonhttp_test.go b/pkg/jsonhttp/jsonhttp_test.go index 6b107ffe8ee..878dfaa0080 100644 --- a/pkg/jsonhttp/jsonhttp_test.go +++ b/pkg/jsonhttp/jsonhttp_test.go @@ -174,7 +174,7 @@ func TestRespond_special(t *testing.T) { wantMessage: "2.4.8.16", }, } { - tc := tc + t.Run(tc.name, func(t *testing.T) { t.Parallel() diff --git a/pkg/manifest/mantaray/marshal_test.go b/pkg/manifest/mantaray/marshal_test.go index 8053c0c7689..b6a12da03b0 100644 --- a/pkg/manifest/mantaray/marshal_test.go +++ b/pkg/manifest/mantaray/marshal_test.go @@ -271,7 +271,7 @@ func Test_UnmarshalBinary(t *testing.T) { } for _, tc := range tests { - tc := tc + t.Run(tc.name, func(t *testing.T) { t.Parallel() diff --git a/pkg/manifest/mantaray/node_test.go b/pkg/manifest/mantaray/node_test.go index a0647d085d0..0340b11bf8f 100644 --- a/pkg/manifest/mantaray/node_test.go +++ b/pkg/manifest/mantaray/node_test.go @@ -136,7 +136,7 @@ func TestAddAndLookupNode(t *testing.T) { }, } { ctx := context.Background() - tc := tc + t.Run(tc.name, func(t *testing.T) { t.Parallel() @@ -264,7 +264,7 @@ func TestRemove(t *testing.T) { }, } { ctx := context.Background() - tc := tc + t.Run(tc.name, func(t *testing.T) { t.Parallel() @@ -354,7 +354,7 @@ func TestHasPrefix(t *testing.T) { }, } { ctx := context.Background() - tc := tc + t.Run(tc.name, func(t *testing.T) { t.Parallel() diff --git a/pkg/manifest/mantaray/persist.go b/pkg/manifest/mantaray/persist.go index 2bd07d74c94..9c08769a1d0 100644 --- a/pkg/manifest/mantaray/persist.go +++ b/pkg/manifest/mantaray/persist.go @@ -71,7 +71,6 @@ func (n *Node) save(ctx context.Context, s Saver) error { } eg, ectx := errgroup.WithContext(ctx) for _, f := range n.forks { - f := f eg.Go(func() error { return f.Node.save(ectx, s) }) diff --git a/pkg/manifest/mantaray/walker_test.go b/pkg/manifest/mantaray/walker_test.go index ad6553eef6c..ef124a99064 100644 --- a/pkg/manifest/mantaray/walker_test.go +++ b/pkg/manifest/mantaray/walker_test.go @@ -41,7 +41,6 @@ func TestWalkNode(t *testing.T) { }, } { ctx := context.Background() - tc := tc createTree := func(t *testing.T, toAdd [][]byte) *mantaray.Node { t.Helper() @@ -198,7 +197,6 @@ func TestWalk(t *testing.T) { return pathFound } - tc := tc t.Run(tc.name, func(t *testing.T) { t.Parallel() diff --git a/pkg/manifest/simple/manifest_test.go b/pkg/manifest/simple/manifest_test.go index a8693b5ca8a..3b19fa45478 100644 --- a/pkg/manifest/simple/manifest_test.go +++ b/pkg/manifest/simple/manifest_test.go @@ -100,7 +100,7 @@ func TestEntries(t *testing.T) { t.Parallel() for _, tc := range makeTestCases(t) { - tc := tc + t.Run(tc.name, func(t *testing.T) { t.Parallel() @@ -198,7 +198,7 @@ func TestMarshal(t *testing.T) { t.Parallel() for _, tc := range makeTestCases(t) { - tc := tc + t.Run(tc.name, func(t *testing.T) { t.Parallel() @@ -271,7 +271,7 @@ func TestHasPrefix(t *testing.T) { }, }, } { - tc := tc + t.Run(tc.name, func(t *testing.T) { t.Parallel() diff --git a/pkg/manifest/simple/walker_test.go b/pkg/manifest/simple/walker_test.go index d6f2bac8170..003151a7d4d 100644 --- a/pkg/manifest/simple/walker_test.go +++ b/pkg/manifest/simple/walker_test.go @@ -15,7 +15,7 @@ func TestWalkEntry(t *testing.T) { t.Parallel() for _, tc := range makeTestCases(t) { - tc := tc + t.Run(tc.name, func(t *testing.T) { t.Parallel() diff --git a/pkg/p2p/libp2p/internal/breaker/breaker_test.go b/pkg/p2p/libp2p/internal/breaker/breaker_test.go index df02ab647de..e9c0f5b0d9e 100644 --- a/pkg/p2p/libp2p/internal/breaker/breaker_test.go +++ b/pkg/p2p/libp2p/internal/breaker/breaker_test.go @@ -73,7 +73,7 @@ func TestExecute(t *testing.T) { } for name, tc := range testCases { - tc := tc + t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/pkg/p2p/libp2p/internal/reacher/reacher_test.go b/pkg/p2p/libp2p/internal/reacher/reacher_test.go index a842103115a..6d3eefa3de2 100644 --- a/pkg/p2p/libp2p/internal/reacher/reacher_test.go +++ b/pkg/p2p/libp2p/internal/reacher/reacher_test.go @@ -61,7 +61,7 @@ func TestPingSuccess(t *testing.T) { }, }, } { - tc := tc + t.Run(tc.name, func(t *testing.T) { t.Parallel() diff --git a/pkg/p2p/libp2p/libp2p.go b/pkg/p2p/libp2p/libp2p.go index f6a77206463..a54eba28a04 100644 --- a/pkg/p2p/libp2p/libp2p.go +++ b/pkg/p2p/libp2p/libp2p.go @@ -555,7 +555,6 @@ func (s *Service) SetPickyNotifier(n p2p.PickyNotifier) { func (s *Service) AddProtocol(p p2p.ProtocolSpec) (err error) { for _, ss := range p.StreamSpecs { - ss := ss id := protocol.ID(p2p.NewSwarmStreamName(p.Name, p.Version, ss.Name)) matcher, err := s.protocolSemverMatcher(id) if err != nil { diff --git a/pkg/p2p/libp2p/static_resolver_test.go b/pkg/p2p/libp2p/static_resolver_test.go index 992d7500004..59b6e59da2f 100644 --- a/pkg/p2p/libp2p/static_resolver_test.go +++ b/pkg/p2p/libp2p/static_resolver_test.go @@ -82,7 +82,7 @@ func TestStaticAddressResolver(t *testing.T) { want: "/dns/ipv4and6.com/tcp/30777/p2p/16Uiu2HAkyyGKpjBiCkVqCKoJa6RzzZw9Nr7hGogsMPcdad1KyMmd", }, } { - tc := tc + t.Run(tc.name, func(t *testing.T) { t.Parallel() diff --git a/pkg/p2p/protobuf/protobuf_test.go b/pkg/p2p/protobuf/protobuf_test.go index f161852ab10..17a80181a99 100644 --- a/pkg/p2p/protobuf/protobuf_test.go +++ b/pkg/p2p/protobuf/protobuf_test.go @@ -44,7 +44,7 @@ func TestReader_ReadMsg(t *testing.T) { }, }, } { - tc := tc + t.Run(tc.name, func(t *testing.T) { t.Parallel() @@ -98,7 +98,7 @@ func TestReader_timeout(t *testing.T) { }, }, } { - tc := tc + t.Run(tc.name, func(t *testing.T) { t.Parallel() @@ -164,7 +164,7 @@ func TestWriter(t *testing.T) { }, }, } { - tc := tc + t.Run(tc.name, func(t *testing.T) { t.Parallel() @@ -210,7 +210,7 @@ func TestWriter_timeout(t *testing.T) { }, }, } { - tc := tc + t.Run(tc.name+"WithContext", func(t *testing.T) { t.Parallel() diff --git a/pkg/postage/stampissuer_test.go b/pkg/postage/stampissuer_test.go index 9d99b7087ca..f7c470e9a42 100644 --- a/pkg/postage/stampissuer_test.go +++ b/pkg/postage/stampissuer_test.go @@ -145,7 +145,6 @@ func TestStampItem(t *testing.T) { }} for _, tc := range tests { - tc := tc t.Run(fmt.Sprintf("%s marshal/unmarshal", tc.name), func(t *testing.T) { t.Parallel() diff --git a/pkg/puller/puller_test.go b/pkg/puller/puller_test.go index f76fe292432..2199601bea5 100644 --- a/pkg/puller/puller_test.go +++ b/pkg/puller/puller_test.go @@ -176,7 +176,7 @@ func TestSyncIntervals(t *testing.T) { }, }, } { - tc := tc + t.Run(tc.name, func(t *testing.T) { t.Parallel() diff --git a/pkg/replicas/putter.go b/pkg/replicas/putter.go index 4aa55b638f0..3ad11ab1f02 100644 --- a/pkg/replicas/putter.go +++ b/pkg/replicas/putter.go @@ -40,7 +40,6 @@ func (p *putter) Put(ctx context.Context, ch swarm.Chunk) (err error) { errc := make(chan error, rlevel.GetReplicaCount()) wg := sync.WaitGroup{} for r := range rr.c { - r := r wg.Add(1) go func() { defer wg.Done() diff --git a/pkg/resolver/client/ens/ens_test.go b/pkg/resolver/client/ens/ens_test.go index 3ecd67be4ae..7cfa74aeba8 100644 --- a/pkg/resolver/client/ens/ens_test.go +++ b/pkg/resolver/client/ens/ens_test.go @@ -53,7 +53,7 @@ func TestNewENSClient(t *testing.T) { }, } for _, tC := range testCases { - tC := tC + t.Run(tC.desc, func(t *testing.T) { t.Parallel() @@ -186,7 +186,7 @@ func TestResolve(t *testing.T) { }, } for _, tC := range testCases { - tC := tC + t.Run(tC.desc, func(t *testing.T) { t.Parallel() diff --git a/pkg/resolver/multiresolver/config_test.go b/pkg/resolver/multiresolver/config_test.go index 9ee417f6d3d..a5c879fbfeb 100644 --- a/pkg/resolver/multiresolver/config_test.go +++ b/pkg/resolver/multiresolver/config_test.go @@ -118,7 +118,7 @@ func TestParseConnectionStrings(t *testing.T) { }, } for _, tC := range testCases { - tC := tC + t.Run(tC.desc, func(t *testing.T) { t.Parallel() diff --git a/pkg/resolver/multiresolver/multiresolver_test.go b/pkg/resolver/multiresolver/multiresolver_test.go index a6d31f796e7..ca7e6f3c1c9 100644 --- a/pkg/resolver/multiresolver/multiresolver_test.go +++ b/pkg/resolver/multiresolver/multiresolver_test.go @@ -76,7 +76,7 @@ func TestPushResolver(t *testing.T) { } for _, tC := range testCases { - tC := tC + t.Run(tC.desc, func(t *testing.T) { t.Parallel() @@ -241,7 +241,7 @@ func TestResolve(t *testing.T) { } for _, tC := range testCases { - tC := tC + t.Run(tC.name, func(t *testing.T) { t.Parallel() diff --git a/pkg/sharky/shard_test.go b/pkg/sharky/shard_test.go index cb85607d488..437bf5c2a88 100644 --- a/pkg/sharky/shard_test.go +++ b/pkg/sharky/shard_test.go @@ -31,7 +31,7 @@ func TestLocationSerialization(t *testing.T) { Length: math.MaxUint16, }, } { - tc := tc + t.Run(fmt.Sprintf("%d_%d_%d", tc.Shard, tc.Slot, tc.Length), func(t *testing.T) { t.Parallel() diff --git a/pkg/sharky/sharky_test.go b/pkg/sharky/sharky_test.go index 8ae75f5b9ca..98da10f0e9b 100644 --- a/pkg/sharky/sharky_test.go +++ b/pkg/sharky/sharky_test.go @@ -73,7 +73,7 @@ func TestSingleRetrieval(t *testing.T) { nil, }, } { - tc := tc + t.Run(tc.name, func(t *testing.T) { cctx, cancel := context.WithTimeout(ctx, 800*time.Millisecond) defer cancel() @@ -188,7 +188,7 @@ func TestConcurrency(t *testing.T) { eg, ectx := errgroup.WithContext(ctx) // a number of workers write sequential numbers to sharky for k := 0; k < workers; k++ { - k := k + eg.Go(func() error { <-start buf := make([]byte, 4) @@ -287,7 +287,7 @@ func TestConcurrency(t *testing.T) { {32, 8, 32}, {64, 32, 64}, } { - c := c + t.Run(fmt.Sprintf("workers:%d,shards:%d,size:%d", c.workers, c.shards, c.shardSize), func(t *testing.T) { t.Parallel() test(t, c.workers, c.shards, c.shardSize) diff --git a/pkg/soc/validator_test.go b/pkg/soc/validator_test.go index 695d43cc46f..dd8f39f7806 100644 --- a/pkg/soc/validator_test.go +++ b/pkg/soc/validator_test.go @@ -173,7 +173,7 @@ func TestInvalid(t *testing.T) { }, }, } { - c := c + t.Run(c.name, func(t *testing.T) { t.Parallel() diff --git a/pkg/storage/migration/index_test.go b/pkg/storage/migration/index_test.go index cf2e0ab8ded..859b66def67 100644 --- a/pkg/storage/migration/index_test.go +++ b/pkg/storage/migration/index_test.go @@ -181,7 +181,7 @@ func TestStepIndex_BatchSize(t *testing.T) { const populateItemsCount = 128 for i := 1; i <= 2*populateItemsCount; i <<= 1 { - i := i + t.Run(fmt.Sprintf("callback called once per item with batch size: %d", i), func(t *testing.T) { t.Parallel() diff --git a/pkg/storage/migration/migration_test.go b/pkg/storage/migration/migration_test.go index c1de785f7d3..51cb896d4c3 100644 --- a/pkg/storage/migration/migration_test.go +++ b/pkg/storage/migration/migration_test.go @@ -157,7 +157,7 @@ func TestValidateVersions(t *testing.T) { }, } for _, tt := range tests { - tt := tt + t.Run(tt.name, func(t *testing.T) { t.Parallel() if err := migration.ValidateVersions(tt.input); (err != nil) != tt.wantErr { @@ -330,7 +330,7 @@ func TestTagIDAddressItem_MarshalAndUnmarshal(t *testing.T) { }} for _, tc := range tests { - tc := tc + t.Run(tc.name, func(t *testing.T) { t.Parallel() storagetest.TestItemMarshalAndUnmarshal(t, tc.test) diff --git a/pkg/storageincentives/agent_test.go b/pkg/storageincentives/agent_test.go index fe5bc6a937f..c4769d2d617 100644 --- a/pkg/storageincentives/agent_test.go +++ b/pkg/storageincentives/agent_test.go @@ -87,7 +87,7 @@ func TestAgent(t *testing.T) { } for _, tc := range tests { - tc := tc + t.Run(tc.name, func(t *testing.T) { t.Parallel() diff --git a/pkg/storageincentives/soc_mine_test.go b/pkg/storageincentives/soc_mine_test.go index d5b93241b21..73ab8f585b3 100644 --- a/pkg/storageincentives/soc_mine_test.go +++ b/pkg/storageincentives/soc_mine_test.go @@ -125,7 +125,7 @@ func makeChunks(t *testing.T, signer crypto.Signer, sampleSize int, filterSOCAdd count := 8 // number of parallel workers wg := sync.WaitGroup{} for i := 0; i < count; i++ { - i := i + wg.Add(1) eg.Go(func() (err error) { offset := i * 4 diff --git a/pkg/storer/internal/cache/cache_test.go b/pkg/storer/internal/cache/cache_test.go index c331853d352..7e8472c6856 100644 --- a/pkg/storer/internal/cache/cache_test.go +++ b/pkg/storer/internal/cache/cache_test.go @@ -67,7 +67,6 @@ func TestCacheEntryItem(t *testing.T) { }} for _, tc := range tests { - tc := tc t.Run(fmt.Sprintf("%s marshal/unmarshal", tc.name), func(t *testing.T) { t.Parallel() diff --git a/pkg/storer/internal/chunkstamp/chunkstamp_test.go b/pkg/storer/internal/chunkstamp/chunkstamp_test.go index a09b1c111ac..7f845223448 100644 --- a/pkg/storer/internal/chunkstamp/chunkstamp_test.go +++ b/pkg/storer/internal/chunkstamp/chunkstamp_test.go @@ -113,7 +113,6 @@ func TestChunkStampItem(t *testing.T) { }} for _, tc := range tests { - tc := tc t.Run(fmt.Sprintf("%s marshal/unmarshal", tc.name), func(t *testing.T) { t.Parallel() diff --git a/pkg/storer/internal/chunkstore/chunkstore_test.go b/pkg/storer/internal/chunkstore/chunkstore_test.go index ce135ebaceb..c0a36b8254f 100644 --- a/pkg/storer/internal/chunkstore/chunkstore_test.go +++ b/pkg/storer/internal/chunkstore/chunkstore_test.go @@ -81,7 +81,6 @@ func TestRetrievalIndexItem(t *testing.T) { }} for _, tc := range tests { - tc := tc t.Run(fmt.Sprintf("%s marshal/unmarshal", tc.name), func(t *testing.T) { t.Parallel() diff --git a/pkg/storer/internal/pinning/pinning_test.go b/pkg/storer/internal/pinning/pinning_test.go index 017b135f6f8..69364eb2fa1 100644 --- a/pkg/storer/internal/pinning/pinning_test.go +++ b/pkg/storer/internal/pinning/pinning_test.go @@ -456,7 +456,6 @@ func TestPinCollectionItem(t *testing.T) { }} for _, tc := range tests { - tc := tc t.Run(fmt.Sprintf("%s marshal/unmarshal", tc.name), func(t *testing.T) { t.Parallel() diff --git a/pkg/storer/internal/reserve/items_test.go b/pkg/storer/internal/reserve/items_test.go index 5ef0f5424ca..dc7625b56bd 100644 --- a/pkg/storer/internal/reserve/items_test.go +++ b/pkg/storer/internal/reserve/items_test.go @@ -128,7 +128,6 @@ func TestReserveItems(t *testing.T) { } for _, tc := range tests { - tc := tc t.Run(fmt.Sprintf("%s marshal/unmarshal", tc.name), func(t *testing.T) { t.Parallel() diff --git a/pkg/storer/internal/stampindex/stampindex_test.go b/pkg/storer/internal/stampindex/stampindex_test.go index c95cdf0b682..e44d792880b 100644 --- a/pkg/storer/internal/stampindex/stampindex_test.go +++ b/pkg/storer/internal/stampindex/stampindex_test.go @@ -97,7 +97,6 @@ func TestStampIndexItem(t *testing.T) { }} for _, tc := range tests { - tc := tc t.Run(fmt.Sprintf("%s marshal/unmarshal", tc.name), func(t *testing.T) { t.Parallel() diff --git a/pkg/storer/internal/upload/uploadstore_test.go b/pkg/storer/internal/upload/uploadstore_test.go index a2f7f931913..e4cc99e9fbe 100644 --- a/pkg/storer/internal/upload/uploadstore_test.go +++ b/pkg/storer/internal/upload/uploadstore_test.go @@ -117,7 +117,6 @@ func TestPushItem(t *testing.T) { }} for _, tc := range tests { - tc := tc t.Run(fmt.Sprintf("%s marshal/unmarshal", tc.name), func(t *testing.T) { t.Parallel() @@ -191,7 +190,6 @@ func TestTagItem(t *testing.T) { }} for _, tc := range tests { - tc := tc t.Run(fmt.Sprintf("%s marshal/unmarshal", tc.name), func(t *testing.T) { t.Parallel() @@ -306,7 +304,6 @@ func TestUploadItem(t *testing.T) { }} for _, tc := range tests { - tc := tc t.Run(fmt.Sprintf("%s marshal/unmarshal", tc.name), func(t *testing.T) { t.Parallel() @@ -359,7 +356,6 @@ func TestItemNextTagID(t *testing.T) { }} for _, tc := range tests { - tc := tc t.Run(fmt.Sprintf("%s marshal/unmarshal", tc.name), func(t *testing.T) { t.Parallel() @@ -409,7 +405,6 @@ func TestItemDirtyTagItem(t *testing.T) { }} for _, tc := range tests { - tc := tc t.Run(fmt.Sprintf("%s marshal/unmarshal", tc.name), func(t *testing.T) { t.Parallel() diff --git a/pkg/storer/mock/mockreserve.go b/pkg/storer/mock/mockreserve.go index d6d70390242..ff9c7e456b9 100644 --- a/pkg/storer/mock/mockreserve.go +++ b/pkg/storer/mock/mockreserve.go @@ -33,7 +33,6 @@ func WithSubscribeResp(chunks []*storer.BinC, err error) Option { func WithChunks(chs ...swarm.Chunk) Option { return optionFunc(func(p *ReserveStore) { for _, c := range chs { - c := c if c.Stamp() != nil { p.chunks[c.Address().String()+string(c.Stamp().BatchID())] = c } else { @@ -219,7 +218,6 @@ func (s *ReserveStore) put(_ context.Context, chs ...swarm.Chunk) error { s.mtx.Lock() defer s.mtx.Unlock() for _, c := range chs { - c := c if s.putHook != nil { if err := s.putHook(c); err != nil { return err diff --git a/pkg/storer/uploadstore_test.go b/pkg/storer/uploadstore_test.go index fa267728e6e..1fa5c6e8502 100644 --- a/pkg/storer/uploadstore_test.go +++ b/pkg/storer/uploadstore_test.go @@ -83,7 +83,7 @@ func testUploadStore(t *testing.T, newStorer func() (*storer.DB, error)) { pin: true, }, } { - tc := tc + testName := fmt.Sprintf("upload_%d_chunks", len(tc.chunks)) if tc.pin { testName += "_with_pin" diff --git a/pkg/swarm/swarm_test.go b/pkg/swarm/swarm_test.go index 7555ac5bf4d..f36fe9a9bb5 100644 --- a/pkg/swarm/swarm_test.go +++ b/pkg/swarm/swarm_test.go @@ -53,7 +53,7 @@ func TestAddress(t *testing.T) { want: swarm.NewAddress([]byte{0x35, 0xa2, 0x6b, 0x7b, 0xb6, 0x45, 0x5c, 0xba, 0xbe, 0x7a, 0xe, 0x5, 0xaa, 0xfb, 0xd0, 0xb8, 0xb2, 0x6f, 0xea, 0xc8, 0x43, 0xe3, 0xb9, 0xa6, 0x49, 0x46, 0x8d, 0xe, 0xa3, 0x7a, 0x12, 0xb2}), }, } { - tc := tc + t.Run(tc.name, func(t *testing.T) { t.Parallel() diff --git a/pkg/topology/kademlia/mock/kademlia.go b/pkg/topology/kademlia/mock/kademlia.go index 23713a129c6..0f44471a5cc 100644 --- a/pkg/topology/kademlia/mock/kademlia.go +++ b/pkg/topology/kademlia/mock/kademlia.go @@ -21,10 +21,7 @@ type AddrTuple struct { func WithEachPeerRevCalls(addrs ...AddrTuple) Option { return optionFunc(func(m *Mock) { - for _, a := range addrs { - a := a - m.eachPeerRev = append(m.eachPeerRev, a) - } + m.eachPeerRev = append(m.eachPeerRev, addrs...) }) } @@ -90,10 +87,7 @@ func (m *Mock) SetStorageRadius(uint8) { func (m *Mock) AddRevPeers(addrs ...AddrTuple) { m.mtx.Lock() defer m.mtx.Unlock() - for _, a := range addrs { - a := a - m.eachPeerRev = append(m.eachPeerRev, a) - } + m.eachPeerRev = append(m.eachPeerRev, addrs...) } // EachConnectedPeer iterates from closest bin to farthest diff --git a/pkg/topology/pslice/pslice_test.go b/pkg/topology/pslice/pslice_test.go index 37e454871ce..f1c8c7afc84 100644 --- a/pkg/topology/pslice/pslice_test.go +++ b/pkg/topology/pslice/pslice_test.go @@ -276,7 +276,7 @@ func TestBinPeers(t *testing.T) { label: "full-bins", }, } { - tc := tc + t.Run(tc.label, func(t *testing.T) { t.Parallel() diff --git a/pkg/traversal/traversal_test.go b/pkg/traversal/traversal_test.go index 7d9d473e1e4..f4cf0369d53 100644 --- a/pkg/traversal/traversal_test.go +++ b/pkg/traversal/traversal_test.go @@ -147,7 +147,7 @@ func TestTraversalBytes(t *testing.T) { } for _, tc := range testCases { - tc := tc + chunkCount := int(math.Ceil(float64(tc.dataSize) / swarm.ChunkSize)) t.Run(fmt.Sprintf("%d-chunk-%d-bytes", chunkCount, tc.dataSize), func(t *testing.T) { t.Parallel() @@ -242,7 +242,7 @@ func TestTraversalFiles(t *testing.T) { } for _, tc := range testCases { - tc := tc + chunkCount := int(math.Ceil(float64(tc.filesSize) / swarm.ChunkSize)) t.Run(fmt.Sprintf("%d-chunk-%d-bytes", chunkCount, tc.filesSize), func(t *testing.T) { t.Parallel() @@ -403,7 +403,7 @@ func TestTraversalManifest(t *testing.T) { } for _, tc := range testCases { - tc := tc + t.Run(fmt.Sprintf("%s-%d-files-%d-chunks", defaultMediaType, len(tc.files), tc.wantHashCount), func(t *testing.T) { t.Parallel()