diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index 049636bc2..33782f2f3 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -19,7 +19,7 @@ jobs: - name: golangci-lint uses: golangci/golangci-lint-action@v6 with: - version: v1.62.2 + version: v1.63.4 - name: notify failure if: failure() && github.ref == 'refs/heads/main' env: diff --git a/.pre-commit/run_linter.sh b/.pre-commit/run_linter.sh index d792c78ce..93e7e7b09 100755 --- a/.pre-commit/run_linter.sh +++ b/.pre-commit/run_linter.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -VERSION="1.62.2" +VERSION="1.63.4" if ! command -v golangci-lint &> /dev/null then diff --git a/cmd/test.go b/cmd/test.go index 134c21192..614098139 100644 --- a/cmd/test.go +++ b/cmd/test.go @@ -7,6 +7,7 @@ import ( "encoding/json" "fmt" "io" + "maps" "net/http" "net/http/httptrace" "os" @@ -21,7 +22,6 @@ import ( "github.com/spf13/cobra" "github.com/spf13/pflag" - "golang.org/x/exp/maps" "github.com/obolnetwork/charon/app/errors" "github.com/obolnetwork/charon/app/log" @@ -85,25 +85,25 @@ func listTestCases(cmd *cobra.Command) []string { var testCaseNames []testCaseName switch cmd.Name() { case peersTestCategory: - testCaseNames = maps.Keys(supportedPeerTestCases()) - testCaseNames = append(testCaseNames, maps.Keys(supportedSelfTestCases())...) + testCaseNames = slices.Collect(maps.Keys(supportedPeerTestCases())) + testCaseNames = append(testCaseNames, slices.Collect(maps.Keys(supportedSelfTestCases()))...) case beaconTestCategory: - testCaseNames = maps.Keys(supportedBeaconTestCases()) + testCaseNames = slices.Collect(maps.Keys(supportedBeaconTestCases())) case validatorTestCategory: - testCaseNames = maps.Keys(supportedValidatorTestCases()) + testCaseNames = slices.Collect(maps.Keys(supportedValidatorTestCases())) case mevTestCategory: - testCaseNames = maps.Keys(supportedMEVTestCases()) + testCaseNames = slices.Collect(maps.Keys(supportedMEVTestCases())) case infraTestCategory: - testCaseNames = maps.Keys(supportedInfraTestCases()) + testCaseNames = slices.Collect(maps.Keys(supportedInfraTestCases())) case allTestCategory: testCaseNames = slices.Concat( - maps.Keys(supportedPeerTestCases()), - maps.Keys(supportedSelfTestCases()), - maps.Keys(supportedRelayTestCases()), - maps.Keys(supportedBeaconTestCases()), - maps.Keys(supportedValidatorTestCases()), - maps.Keys(supportedMEVTestCases()), - maps.Keys(supportedInfraTestCases()), + slices.Collect(maps.Keys(supportedPeerTestCases())), + slices.Collect(maps.Keys(supportedSelfTestCases())), + slices.Collect(maps.Keys(supportedRelayTestCases())), + slices.Collect(maps.Keys(supportedBeaconTestCases())), + slices.Collect(maps.Keys(supportedValidatorTestCases())), + slices.Collect(maps.Keys(supportedMEVTestCases())), + slices.Collect(maps.Keys(supportedInfraTestCases())), ) default: log.Warn(cmd.Context(), "Unknown command for listing test cases", nil, z.Str("name", cmd.Name())) @@ -315,7 +315,7 @@ func writeResultToWriter(res testCategoryResult, w io.Writer) error { lines = append(lines, "") lines = append(lines, fmt.Sprintf("%-64s%s", "TEST NAME", "RESULT")) suggestions := []string{} - targets := maps.Keys(res.Targets) + targets := slices.Collect(maps.Keys(res.Targets)) slices.Sort(targets) for _, target := range targets { if target != "" && len(res.Targets[target]) > 0 { diff --git a/cmd/testbeacon.go b/cmd/testbeacon.go index 61f09d98f..cdc71f2db 100644 --- a/cmd/testbeacon.go +++ b/cmd/testbeacon.go @@ -7,11 +7,13 @@ import ( "encoding/json" "fmt" "io" + "maps" "math" "math/rand" "net/http" "os" "path/filepath" + "slices" "sort" "strconv" "strings" @@ -20,7 +22,6 @@ import ( eth2v1 "github.com/attestantio/go-eth2-client/api/v1" "github.com/spf13/cobra" - "golang.org/x/exp/maps" "golang.org/x/sync/errgroup" "github.com/obolnetwork/charon/app/errors" @@ -210,7 +211,7 @@ func runTestBeacon(ctx context.Context, w io.Writer, cfg testBeaconConfig) (res log.Info(ctx, "Starting beacon node test") testCases := supportedBeaconTestCases() - queuedTests := filterTests(maps.Keys(testCases), cfg.testConfig) + queuedTests := filterTests(slices.Collect(maps.Keys(testCases)), cfg.testConfig) if len(queuedTests) == 0 { return res, errors.New("test case not supported") } diff --git a/cmd/testinfra.go b/cmd/testinfra.go index 968c0f7c1..79ee83027 100644 --- a/cmd/testinfra.go +++ b/cmd/testinfra.go @@ -9,6 +9,7 @@ import ( "encoding/json" "fmt" "io" + "maps" "os" "os/exec" "runtime" @@ -19,7 +20,6 @@ import ( "github.com/showwin/speedtest-go/speedtest" "github.com/spf13/cobra" - "golang.org/x/exp/maps" "github.com/obolnetwork/charon/app/errors" "github.com/obolnetwork/charon/app/log" @@ -123,7 +123,7 @@ func runTestInfra(ctx context.Context, w io.Writer, cfg testInfraConfig) (res te log.Info(ctx, "Starting hardware performance and network connectivity test") testCases := supportedInfraTestCases() - queuedTests := filterTests(maps.Keys(testCases), cfg.testConfig) + queuedTests := filterTests(slices.Collect(maps.Keys(testCases)), cfg.testConfig) if len(queuedTests) == 0 { return res, errors.New("test case not supported") } diff --git a/cmd/testmev.go b/cmd/testmev.go index 6dff83451..955bfe6c5 100644 --- a/cmd/testmev.go +++ b/cmd/testmev.go @@ -9,8 +9,10 @@ import ( "encoding/json" "fmt" "io" + "maps" "net/http" "net/http/httptrace" + "slices" "strconv" "strings" "time" @@ -20,7 +22,6 @@ import ( eth2a "github.com/attestantio/go-eth2-client/spec/altair" eth2p0 "github.com/attestantio/go-eth2-client/spec/phase0" "github.com/spf13/cobra" - "golang.org/x/exp/maps" "golang.org/x/sync/errgroup" "github.com/obolnetwork/charon/app/errors" @@ -105,7 +106,7 @@ func runTestMEV(ctx context.Context, w io.Writer, cfg testMEVConfig) (res testCa log.Info(ctx, "Starting MEV relays test") testCases := supportedMEVTestCases() - queuedTests := filterTests(maps.Keys(testCases), cfg.testConfig) + queuedTests := filterTests(slices.Collect(maps.Keys(testCases)), cfg.testConfig) if len(queuedTests) == 0 { return res, errors.New("test case not supported") } diff --git a/cmd/testpeers.go b/cmd/testpeers.go index adcd57008..eda1bab61 100644 --- a/cmd/testpeers.go +++ b/cmd/testpeers.go @@ -9,6 +9,7 @@ import ( "encoding/json" "fmt" "io" + "maps" "math" "math/rand" "net" @@ -25,7 +26,6 @@ import ( "github.com/libp2p/go-libp2p/core/peer" "github.com/libp2p/go-libp2p/p2p/protocol/ping" "github.com/spf13/cobra" - "golang.org/x/exp/maps" "golang.org/x/sync/errgroup" "github.com/obolnetwork/charon/app/errors" @@ -151,15 +151,15 @@ func runTestPeers(ctx context.Context, w io.Writer, conf testPeersConfig) (res t log.Info(ctx, "Starting charon peers and relays test") relayTestCases := supportedRelayTestCases() - queuedTestsRelay := filterTests(maps.Keys(relayTestCases), conf.testConfig) + queuedTestsRelay := filterTests(slices.Collect(maps.Keys(relayTestCases)), conf.testConfig) sortTests(queuedTestsRelay) peerTestCases := supportedPeerTestCases() - queuedTestsPeer := filterTests(maps.Keys(peerTestCases), conf.testConfig) + queuedTestsPeer := filterTests(slices.Collect(maps.Keys(peerTestCases)), conf.testConfig) sortTests(queuedTestsPeer) selfTestCases := supportedSelfTestCases() - queuedTestsSelf := filterTests(maps.Keys(selfTestCases), conf.testConfig) + queuedTestsSelf := filterTests(slices.Collect(maps.Keys(selfTestCases)), conf.testConfig) sortTests(queuedTestsSelf) if len(queuedTestsPeer) == 0 && len(queuedTestsSelf) == 0 { diff --git a/cmd/testpeers_internal_test.go b/cmd/testpeers_internal_test.go index e2bd12908..1631087b7 100644 --- a/cmd/testpeers_internal_test.go +++ b/cmd/testpeers_internal_test.go @@ -9,6 +9,7 @@ import ( "encoding/json" "fmt" "io" + "maps" "net/http" "os" "slices" @@ -19,7 +20,6 @@ import ( k1 "github.com/decred/dcrd/dcrec/secp256k1/v4" "github.com/libp2p/go-libp2p/core/peer" "github.com/stretchr/testify/require" - "golang.org/x/exp/maps" "github.com/obolnetwork/charon/app/k1util" "github.com/obolnetwork/charon/app/log" @@ -352,8 +352,8 @@ func testWriteOut(t *testing.T, expectedRes testCategoryResult, buf bytes.Buffer bufTests = slices.Delete(bufTests, 0, 8) bufTests = slices.Delete(bufTests, len(bufTests)-4, len(bufTests)) - nTargets := len(maps.Keys(expectedRes.Targets)) - require.Len(t, bufTests, len(slices.Concat(maps.Values(expectedRes.Targets)...))+nTargets*2) + nTargets := len(slices.Collect(maps.Keys(expectedRes.Targets))) + require.Len(t, bufTests, len(slices.Concat(slices.Collect(maps.Values(expectedRes.Targets))...))+nTargets*2) for range nTargets { bufTests = bufTests[1:] diff --git a/cmd/testvalidator.go b/cmd/testvalidator.go index 42c734223..fb6567c41 100644 --- a/cmd/testvalidator.go +++ b/cmd/testvalidator.go @@ -5,14 +5,15 @@ package cmd import ( "context" "io" + "maps" "math" "math/rand" "net" + "slices" "sync" "time" "github.com/spf13/cobra" - "golang.org/x/exp/maps" "github.com/obolnetwork/charon/app/errors" "github.com/obolnetwork/charon/app/log" @@ -72,7 +73,7 @@ func runTestValidator(ctx context.Context, w io.Writer, cfg testValidatorConfig) log.Info(ctx, "Starting validator client test") testCases := supportedValidatorTestCases() - queuedTests := filterTests(maps.Keys(testCases), cfg.testConfig) + queuedTests := filterTests(slices.Collect(maps.Keys(testCases)), cfg.testConfig) if len(queuedTests) == 0 { err = errors.New("test case not supported") return res, err diff --git a/core/validatorapi/validatorapi_test.go b/core/validatorapi/validatorapi_test.go index 79ff1d81c..d5304b491 100644 --- a/core/validatorapi/validatorapi_test.go +++ b/core/validatorapi/validatorapi_test.go @@ -5,6 +5,7 @@ package validatorapi_test import ( "context" "fmt" + "maps" "sort" "strconv" "sync" @@ -24,7 +25,6 @@ import ( eth2p0 "github.com/attestantio/go-eth2-client/spec/phase0" "github.com/prysmaticlabs/go-bitfield" "github.com/stretchr/testify/require" - "golang.org/x/exp/maps" "github.com/obolnetwork/charon/app/errors" "github.com/obolnetwork/charon/app/eth2wrap" diff --git a/go.mod b/go.mod index 98d1cf175..e332419ce 100644 --- a/go.mod +++ b/go.mod @@ -42,7 +42,6 @@ require ( go.uber.org/goleak v1.3.0 go.uber.org/zap v1.27.0 golang.org/x/crypto v0.32.0 - golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c golang.org/x/sync v0.10.0 golang.org/x/term v0.28.0 golang.org/x/time v0.8.0 @@ -209,6 +208,7 @@ require ( go.uber.org/fx v1.23.0 // indirect go.uber.org/mock v0.5.0 // indirect go.uber.org/multierr v1.11.0 // indirect + golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c // indirect golang.org/x/mod v0.22.0 // indirect golang.org/x/net v0.34.0 // indirect golang.org/x/sys v0.29.0 // indirect diff --git a/testutil/compose/fuzz/fuzz_test.go b/testutil/compose/fuzz/fuzz_test.go index 0dca9245f..bce615f36 100644 --- a/testutil/compose/fuzz/fuzz_test.go +++ b/testutil/compose/fuzz/fuzz_test.go @@ -61,8 +61,7 @@ func TestFuzzers(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { - dir, err := os.MkdirTemp("", "") - require.NoError(t, err) + dir := t.TempDir() config := test.configFunc(defaultConfig) require.NoError(t, compose.WriteConfig(dir, config)) @@ -79,7 +78,7 @@ func TestFuzzers(t *testing.T) { autoConfig.LogFile = path.Join(*logDir, test.name+".log") } - err = compose.Auto(context.Background(), autoConfig) + err := compose.Auto(context.Background(), autoConfig) testutil.RequireNoError(t, err) }) } diff --git a/testutil/integration/simnet_test.go b/testutil/integration/simnet_test.go index 2b4ff0378..ed199553d 100644 --- a/testutil/integration/simnet_test.go +++ b/testutil/integration/simnet_test.go @@ -464,7 +464,7 @@ func startTeku(t *testing.T, args simnetArgs, node int) simnetArgs { // Support specifying a custom base directory for docker mounts (required if running colima on macOS). if dir, ok := os.LookupEnv("TEST_DOCKER_DIR"); ok { var err error - tempDir, err = os.MkdirTemp(dir, "") + tempDir, err = os.MkdirTemp(dir, "") //nolint: usetesting // support custom base directory require.NoError(t, err) }