Skip to content

Commit

Permalink
do not fail, when on testnet and ephemeral keys are !=0, set them 0 i…
Browse files Browse the repository at this point in the history
…nstead
  • Loading branch information
Tofel committed Apr 24, 2024
1 parent 5fd4d3d commit da267d8
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 6 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/automation-benchmark-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand All @@ -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:
Expand Down
25 changes: 25 additions & 0 deletions integration-tests/actions/seth/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/benchmark/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/chaos/automation_chaos_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions integration-tests/docker/test_env/test_env_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit da267d8

Please sign in to comment.