Skip to content

Commit

Permalink
fix how Networks array is overriden for Seth (#12372)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tofel authored Mar 11, 2024
1 parent fef8d29 commit 2d44015
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 8 deletions.
4 changes: 2 additions & 2 deletions integration-tests/testconfig/default.toml
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ transaction_timeout = "3m"
transfer_gas_fee = 40_000
gas_limit = 30_000_000
# legacy transactions
gas_price = 20_000_000_000
gas_price = 50_000_000_000
# EIP-1559 transactions
# eip_1559_dynamic_fees = true2
# eip_1559_dynamic_fees = true
gas_fee_cap = 45_000_000_000
gas_tip_cap = 10_000_000_000

Expand Down
37 changes: 31 additions & 6 deletions integration-tests/testconfig/testconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,12 +304,7 @@ func GetConfig(configurationName string, product Product) (TestConfig, error) {
case Automation:
return handleAutomationConfigOverride(logger, filename, configurationName, target, content)
default:
err := ctf_config.BytesToAnyTomlStruct(logger, filename, configurationName, &testConfig, content)
if err != nil {
return errors.Wrapf(err, "error reading file %s", filename)
}

return nil
return handleDefaultConfigOverride(logger, filename, configurationName, target, content)
}
}

Expand Down Expand Up @@ -570,3 +565,33 @@ func handleAutomationConfigOverride(logger zerolog.Logger, filename, configurati

return nil
}

func handleDefaultConfigOverride(logger zerolog.Logger, filename, configurationName string, target *TestConfig, content []byte) error {
logger.Debug().Msgf("Handling default config override for %s", filename)
oldConfig := MustCopy(target)
newConfig := TestConfig{}

err := ctf_config.BytesToAnyTomlStruct(logger, filename, configurationName, &target, content)
if err != nil {
return errors.Wrapf(err, "error reading file %s", filename)
}

err = ctf_config.BytesToAnyTomlStruct(logger, filename, configurationName, &newConfig, content)
if err != nil {
return errors.Wrapf(err, "error reading file %s", filename)
}

// override instead of merging
if (newConfig.Seth != nil && len(newConfig.Seth.Networks) > 0) && (oldConfig != nil && oldConfig.Seth != nil && len(oldConfig.Seth.Networks) > 0) {
for i, old_network := range oldConfig.Seth.Networks {
for _, new_network := range newConfig.Seth.Networks {
if old_network.ChainID == new_network.ChainID {
oldConfig.Seth.Networks[i] = new_network
}
}
}
target.Seth.Networks = oldConfig.Seth.Networks
}

return nil
}

0 comments on commit 2d44015

Please sign in to comment.