all: remove loopvar workarounds in tests

pull/30382/head
Håvard Anda Estensen 2 months ago
parent b6b46ffebd
commit 0e46960f62
  1. 1
      accounts/abi/abi_test.go
  2. 1
      accounts/abi/event_test.go
  3. 1
      accounts/abi/pack_test.go
  4. 1
      accounts/abi/reflect_test.go
  5. 3
      accounts/abi/topics_test.go
  6. 1
      accounts/abi/unpack_test.go
  7. 4
      cmd/devp2p/internal/ethtest/snap.go
  8. 1
      cmd/geth/accountcmd_test.go
  9. 1
      cmd/geth/version_check_test.go
  10. 1
      cmd/utils/flags_test.go
  11. 1
      cmd/utils/prompt_test.go
  12. 1
      core/types/transaction_test.go
  13. 2
      eth/tracers/internal/tracetest/calltrace_test.go
  14. 1
      eth/tracers/internal/tracetest/flat_calltrace_test.go
  15. 1
      eth/tracers/internal/tracetest/prestate_test.go
  16. 1
      node/api_test.go
  17. 1
      node/node_test.go
  18. 1
      node/rpcstack_test.go
  19. 1
      p2p/discover/v5wire/encoding_test.go
  20. 1
      rlp/decode_test.go
  21. 1
      rlp/rlpgen/gen_test.go
  22. 1
      rpc/types_test.go

@ -1199,7 +1199,6 @@ func TestUnpackRevert(t *testing.T) {
{"4e487b7100000000000000000000000000000000000000000000000000000000000000ff", "unknown panic code: 0xff", nil}, {"4e487b7100000000000000000000000000000000000000000000000000000000000000ff", "unknown panic code: 0xff", nil},
} }
for index, c := range cases { for index, c := range cases {
index, c := index, c
t.Run(fmt.Sprintf("case %d", index), func(t *testing.T) { t.Run(fmt.Sprintf("case %d", index), func(t *testing.T) {
t.Parallel() t.Parallel()
got, err := UnpackRevert(common.Hex2Bytes(c.input)) got, err := UnpackRevert(common.Hex2Bytes(c.input))

@ -331,7 +331,6 @@ func TestEventTupleUnpack(t *testing.T) {
for _, tc := range testCases { for _, tc := range testCases {
assert := assert.New(t) assert := assert.New(t)
tc := tc
t.Run(tc.name, func(t *testing.T) { t.Run(tc.name, func(t *testing.T) {
err := unpackTestEventData(tc.dest, tc.data, tc.jsonLog, assert) err := unpackTestEventData(tc.dest, tc.data, tc.jsonLog, assert)
if tc.error == "" { if tc.error == "" {

@ -34,7 +34,6 @@ import (
func TestPack(t *testing.T) { func TestPack(t *testing.T) {
t.Parallel() t.Parallel()
for i, test := range packUnpackTests { for i, test := range packUnpackTests {
i, test := i, test
t.Run(strconv.Itoa(i), func(t *testing.T) { t.Run(strconv.Itoa(i), func(t *testing.T) {
t.Parallel() t.Parallel()
encb, err := hex.DecodeString(test.packed) encb, err := hex.DecodeString(test.packed)

@ -172,7 +172,6 @@ var reflectTests = []reflectTest{
func TestReflectNameToStruct(t *testing.T) { func TestReflectNameToStruct(t *testing.T) {
t.Parallel() t.Parallel()
for _, test := range reflectTests { for _, test := range reflectTests {
test := test
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
t.Parallel() t.Parallel()
m, err := mapArgNamesToStructFields(test.args, reflect.ValueOf(test.struc)) m, err := mapArgNamesToStructFields(test.args, reflect.ValueOf(test.struc))

@ -137,7 +137,6 @@ func TestMakeTopics(t *testing.T) {
}, },
} }
for _, tt := range tests { for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
t.Parallel() t.Parallel()
got, err := MakeTopics(tt.args.query...) got, err := MakeTopics(tt.args.query...)
@ -373,7 +372,6 @@ func TestParseTopics(t *testing.T) {
tests := setupTopicsTests() tests := setupTopicsTests()
for _, tt := range tests { for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
t.Parallel() t.Parallel()
createObj := tt.args.createObj() createObj := tt.args.createObj()
@ -393,7 +391,6 @@ func TestParseTopicsIntoMap(t *testing.T) {
tests := setupTopicsTests() tests := setupTopicsTests()
for _, tt := range tests { for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
t.Parallel() t.Parallel()
outMap := make(map[string]interface{}) outMap := make(map[string]interface{})

@ -389,7 +389,6 @@ func TestMethodMultiReturn(t *testing.T) {
"Can not unpack into a slice with wrong types", "Can not unpack into a slice with wrong types",
}} }}
for _, tc := range testCases { for _, tc := range testCases {
tc := tc
t.Run(tc.name, func(t *testing.T) { t.Run(tc.name, func(t *testing.T) {
require := require.New(t) require := require.New(t)
err := abi.UnpackIntoInterface(tc.dest, "multi", data) err := abi.UnpackIntoInterface(tc.dest, "multi", data)

@ -286,7 +286,6 @@ a key before startingHash (wrong order). The server should return the first avai
} }
for i, tc := range tests { for i, tc := range tests {
tc := tc
if i > 0 { if i > 0 {
t.Log("\n") t.Log("\n")
} }
@ -429,7 +428,6 @@ of the test account. The server should return slots [2,3] (i.e. the 'next availa
} }
for i, tc := range tests { for i, tc := range tests {
tc := tc
if i > 0 { if i > 0 {
t.Log("\n") t.Log("\n")
} }
@ -526,7 +524,6 @@ func (s *Suite) TestSnapGetByteCodes(t *utesting.T) {
} }
for i, tc := range tests { for i, tc := range tests {
tc := tc
if i > 0 { if i > 0 {
t.Log("\n") t.Log("\n")
} }
@ -723,7 +720,6 @@ The server should reject the request.`,
} }
for i, tc := range tests { for i, tc := range tests {
tc := tc
if i > 0 { if i > 0 {
t.Log("\n") t.Log("\n")
} }

@ -113,7 +113,6 @@ func TestAccountImport(t *testing.T) {
}, },
} }
for _, test := range tests { for _, test := range tests {
test := test
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
t.Parallel() t.Parallel()
importAccountWithExpect(t, test.key, test.output) importAccountWithExpect(t, test.key, test.output)

@ -170,7 +170,6 @@ func TestKeyID(t *testing.T) {
{"third key", args{id: extractKeyId(gethPubKeys[2])}, "FD9813B2D2098484"}, {"third key", args{id: extractKeyId(gethPubKeys[2])}, "FD9813B2D2098484"},
} }
for _, tt := range tests { for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
t.Parallel() t.Parallel()
if got := keyID(tt.args.id); got != tt.want { if got := keyID(tt.args.id); got != tt.want {

@ -56,7 +56,6 @@ func Test_SplitTagsFlag(t *testing.T) {
}, },
} }
for _, tt := range tests { for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
t.Parallel() t.Parallel()
if got := SplitTagsFlag(tt.args); !reflect.DeepEqual(got, tt.want) { if got := SplitTagsFlag(tt.args); !reflect.DeepEqual(got, tt.want) {

@ -66,7 +66,6 @@ func TestGetPassPhraseWithList(t *testing.T) {
}, },
} }
for _, tt := range tests { for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
t.Parallel() t.Parallel()
if got := GetPassPhraseWithList(tt.args.text, tt.args.confirmation, tt.args.index, tt.args.passwords); got != tt.want { if got := GetPassPhraseWithList(tt.args.text, tt.args.confirmation, tt.args.index, tt.args.passwords); got != tt.want {

@ -548,7 +548,6 @@ func TestYParityJSONUnmarshalling(t *testing.T) {
} { } {
txType := txType txType := txType
for _, test := range tests { for _, test := range tests {
test := test
t.Run(fmt.Sprintf("txType=%d: %s", txType, test.name), func(t *testing.T) { t.Run(fmt.Sprintf("txType=%d: %s", txType, test.name), func(t *testing.T) {
// Copy the base json // Copy the base json
testJson := maps.Clone(baseJson) testJson := maps.Clone(baseJson)

@ -96,7 +96,6 @@ func testCallTracer(tracerName string, dirPath string, t *testing.T) {
if !strings.HasSuffix(file.Name(), ".json") { if !strings.HasSuffix(file.Name(), ".json") {
continue continue
} }
file := file // capture range variable
t.Run(camel(strings.TrimSuffix(file.Name(), ".json")), func(t *testing.T) { t.Run(camel(strings.TrimSuffix(file.Name(), ".json")), func(t *testing.T) {
t.Parallel() t.Parallel()
@ -183,7 +182,6 @@ func BenchmarkTracers(b *testing.B) {
if !strings.HasSuffix(file.Name(), ".json") { if !strings.HasSuffix(file.Name(), ".json") {
continue continue
} }
file := file // capture range variable
b.Run(camel(strings.TrimSuffix(file.Name(), ".json")), func(b *testing.B) { b.Run(camel(strings.TrimSuffix(file.Name(), ".json")), func(b *testing.B) {
blob, err := os.ReadFile(filepath.Join("testdata", "call_tracer", file.Name())) blob, err := os.ReadFile(filepath.Join("testdata", "call_tracer", file.Name()))
if err != nil { if err != nil {

@ -151,7 +151,6 @@ func testFlatCallTracer(tracerName string, dirPath string, t *testing.T) {
if !strings.HasSuffix(file.Name(), ".json") { if !strings.HasSuffix(file.Name(), ".json") {
continue continue
} }
file := file // capture range variable
t.Run(camel(strings.TrimSuffix(file.Name(), ".json")), func(t *testing.T) { t.Run(camel(strings.TrimSuffix(file.Name(), ".json")), func(t *testing.T) {
t.Parallel() t.Parallel()

@ -73,7 +73,6 @@ func testPrestateDiffTracer(tracerName string, dirPath string, t *testing.T) {
if !strings.HasSuffix(file.Name(), ".json") { if !strings.HasSuffix(file.Name(), ".json") {
continue continue
} }
file := file // capture range variable
t.Run(camel(strings.TrimSuffix(file.Name(), ".json")), func(t *testing.T) { t.Run(camel(strings.TrimSuffix(file.Name(), ".json")), func(t *testing.T) {
t.Parallel() t.Parallel()

@ -244,7 +244,6 @@ func TestStartRPC(t *testing.T) {
} }
for _, test := range tests { for _, test := range tests {
test := test
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
t.Parallel() t.Parallel()

@ -513,7 +513,6 @@ func TestNodeRPCPrefix(t *testing.T) {
} }
for _, test := range tests { for _, test := range tests {
test := test
name := fmt.Sprintf("http=%s ws=%s", test.httpPrefix, test.wsPrefix) name := fmt.Sprintf("http=%s ws=%s", test.httpPrefix, test.wsPrefix)
t.Run(name, func(t *testing.T) { t.Run(name, func(t *testing.T) {
cfg := &Config{ cfg := &Config{

@ -522,7 +522,6 @@ func TestGzipHandler(t *testing.T) {
} }
for _, test := range tests { for _, test := range tests {
test := test
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
srv := httptest.NewServer(newGzipHandler(test.handler)) srv := httptest.NewServer(newGzipHandler(test.handler))
defer srv.Close() defer srv.Close()

@ -395,7 +395,6 @@ func TestTestVectorsV5(t *testing.T) {
} }
for _, test := range tests { for _, test := range tests {
test := test
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
net := newHandshakeTest() net := newHandshakeTest()
defer net.close() defer net.close()

@ -307,7 +307,6 @@ func TestStreamReadBytes(t *testing.T) {
} }
for _, test := range tests { for _, test := range tests {
test := test
name := fmt.Sprintf("input_%s/size_%d", test.input, test.size) name := fmt.Sprintf("input_%s/size_%d", test.input, test.size)
t.Run(name, func(t *testing.T) { t.Run(name, func(t *testing.T) {
s := NewStream(bytes.NewReader(unhex(test.input)), 0) s := NewStream(bytes.NewReader(unhex(test.input)), 0)

@ -51,7 +51,6 @@ var tests = []string{"uints", "nil", "rawvalue", "optional", "bigint", "uint256"
func TestOutput(t *testing.T) { func TestOutput(t *testing.T) {
for _, test := range tests { for _, test := range tests {
test := test
t.Run(test, func(t *testing.T) { t.Run(test, func(t *testing.T) {
inputFile := filepath.Join("testdata", test+".in.txt") inputFile := filepath.Join("testdata", test+".in.txt")
outputFile := filepath.Join("testdata", test+".out.txt") outputFile := filepath.Join("testdata", test+".out.txt")

@ -143,7 +143,6 @@ func TestBlockNumberOrHash_WithNumber_MarshalAndUnmarshal(t *testing.T) {
{"finalized", int64(FinalizedBlockNumber)}, {"finalized", int64(FinalizedBlockNumber)},
} }
for _, test := range tests { for _, test := range tests {
test := test
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
bnh := BlockNumberOrHashWithNumber(BlockNumber(test.number)) bnh := BlockNumberOrHashWithNumber(BlockNumber(test.number))
marshalled, err := json.Marshal(bnh) marshalled, err := json.Marshal(bnh)

Loading…
Cancel
Save