From da267d876d9eae3974c2de464a4f85c6eedbe691 Mon Sep 17 00:00:00 2001 From: Bartek Tofel Date: Wed, 24 Apr 2024 11:37:19 +0200 Subject: [PATCH] do not fail, when on testnet and ephemeral keys are !=0, set them 0 instead --- .../workflows/automation-benchmark-tests.yml | 4 +-- integration-tests/actions/seth/actions.go | 25 +++++++++++++++++++ integration-tests/benchmark/keeper_test.go | 2 +- .../chaos/automation_chaos_test.go | 2 +- .../docker/test_env/test_env_builder.go | 4 +-- 5 files changed, 31 insertions(+), 6 deletions(-) diff --git a/.github/workflows/automation-benchmark-tests.yml b/.github/workflows/automation-benchmark-tests.yml index 1faf8cea969..bad37e314be 100644 --- a/.github/workflows/automation-benchmark-tests.yml +++ b/.github/workflows/automation-benchmark-tests.yml @@ -48,7 +48,7 @@ jobs: - name: Parse base64 config uses: ./.github/actions/setup-parse-base64-config with: - base64Config: ${{ env.BASE64_CONFIG_OVERRIDE }} + base64Config: ${{ env.BASE64_CONFIG_OVERRIDE }} - name: Send details to Step Summary shell: bash run: | @@ -57,7 +57,7 @@ jobs: echo "### chainlink-tests image tag for this test run :ship:" >>$GITHUB_STEP_SUMMARY echo "\`${GITHUB_SHA}\`" >>$GITHUB_STEP_SUMMARY echo "### Networks on which test was run" >>$GITHUB_STEP_SUMMARY - echo "\`${{ env.NETWORKS }}\`" >>$GITHUB_STEP_SUMMARY + echo "\`${{ env.NETWORKS }}\`" >>$GITHUB_STEP_SUMMARY - name: Build Test Image uses: ./.github/actions/build-test-image with: diff --git a/integration-tests/actions/seth/actions.go b/integration-tests/actions/seth/actions.go index 1386892f373..8b9b4b56102 100644 --- a/integration-tests/actions/seth/actions.go +++ b/integration-tests/actions/seth/actions.go @@ -981,6 +981,31 @@ var OneEphemeralKeysLiveTestnetCheckFn = func(sethCfg *seth.Config) error { return nil } +// OneEphemeralKeysLiveTestnetAutoFixFn checks whether there's at least one ephemeral key on a simulated network or at least one static key on a live network, +// and that there are no epehemeral keys on a live network (if ephemeral keys count is different from zero, it will disable them). Root key is excluded from the check. +var OneEphemeralKeysLiveTestnetAutoFixFn = func(sethCfg *seth.Config) error { + concurrency := sethCfg.GetMaxConcurrency() + + if sethCfg.IsSimulatedNetwork() { + if concurrency < 1 { + return fmt.Errorf(INSUFFICIENT_EPHEMERAL_KEYS, 0) + } + + return nil + } + + if sethCfg.EphemeralAddrs != nil && int(*sethCfg.EphemeralAddrs) > 0 { + var zero int64 = 0 + sethCfg.EphemeralAddrs = &zero + } + + if concurrency < 1 { + return fmt.Errorf(INSUFFICIENT_STATIC_KEYS, len(sethCfg.Network.PrivateKeys)) + } + + return nil +} + // GetChainClient returns a seth client for the given network after validating the config func GetChainClient(config tc.SethConfig, network blockchain.EVMNetwork) (*seth.Client, error) { return GetChainClientWithConfigFunction(config, network, noOpSethConfigFn) diff --git a/integration-tests/benchmark/keeper_test.go b/integration-tests/benchmark/keeper_test.go index 54dd1e71276..75d70917911 100644 --- a/integration-tests/benchmark/keeper_test.go +++ b/integration-tests/benchmark/keeper_test.go @@ -145,7 +145,7 @@ func TestAutomationBenchmark(t *testing.T) { l.Info().Str("Namespace", testEnvironment.Cfg.Namespace).Msg("Connected to Keepers Benchmark Environment") testNetwork := utils.MustReplaceSimulatedNetworkUrlWithK8(l, benchmarkNetwork, *testEnvironment) - chainClient, err := actions_seth.GetChainClientWithConfigFunction(&config, testNetwork, actions_seth.OneEphemeralKeysLiveTestnetCheckFn) + chainClient, err := actions_seth.GetChainClientWithConfigFunction(&config, testNetwork, actions_seth.OneEphemeralKeysLiveTestnetAutoFixFn) require.NoError(t, err, "Error getting Seth client") registryVersions := addRegistry(&config) diff --git a/integration-tests/chaos/automation_chaos_test.go b/integration-tests/chaos/automation_chaos_test.go index 605f7f083f4..2226a2c4c00 100644 --- a/integration-tests/chaos/automation_chaos_test.go +++ b/integration-tests/chaos/automation_chaos_test.go @@ -246,7 +246,7 @@ func TestAutomationChaos(t *testing.T) { network = utils.MustReplaceSimulatedNetworkUrlWithK8(l, network, *testEnvironment) - chainClient, err := actions_seth.GetChainClientWithConfigFunction(&config, network, actions_seth.OneEphemeralKeysLiveTestnetCheckFn) + chainClient, err := actions_seth.GetChainClientWithConfigFunction(&config, network, actions_seth.OneEphemeralKeysLiveTestnetAutoFixFn) require.NoError(t, err, "Error creating seth client") // Register cleanup for any test diff --git a/integration-tests/docker/test_env/test_env_builder.go b/integration-tests/docker/test_env/test_env_builder.go index 0e18f0c22b7..7e6c43bf371 100644 --- a/integration-tests/docker/test_env/test_env_builder.go +++ b/integration-tests/docker/test_env/test_env_builder.go @@ -323,7 +323,7 @@ func (b *CLTestEnvBuilder) Build() (*CLClusterTestEnv, error) { } if b.hasSeth { - seth, err := actions_seth.GetChainClientWithConfigFunction(b.testConfig, networkConfig, actions_seth.OneEphemeralKeysLiveTestnetCheckFn) + seth, err := actions_seth.GetChainClientWithConfigFunction(b.testConfig, networkConfig, actions_seth.OneEphemeralKeysLiveTestnetAutoFixFn) if err != nil { return nil, err } @@ -416,7 +416,7 @@ func (b *CLTestEnvBuilder) Build() (*CLClusterTestEnv, error) { if b.hasSeth { b.te.sethClients = make(map[int64]*seth.Client) - seth, err := actions_seth.GetChainClientWithConfigFunction(b.testConfig, networkConfig, actions_seth.OneEphemeralKeysLiveTestnetCheckFn) + seth, err := actions_seth.GetChainClientWithConfigFunction(b.testConfig, networkConfig, actions_seth.OneEphemeralKeysLiveTestnetAutoFixFn) if err != nil { return nil, err }