From 1dd1b9afd5be50cdbbdf6b33fb9a8d5175f0897c Mon Sep 17 00:00:00 2001 From: Bartek Tofel Date: Mon, 10 Jun 2024 11:53:09 +0200 Subject: [PATCH] remove now-unnecessary custom logic from testconfig; toml library version bump fixes the issue --- integration-tests/go.mod | 4 +- integration-tests/go.sum | 8 +- integration-tests/load/go.mod | 4 +- integration-tests/load/go.sum | 8 +- integration-tests/testconfig/testconfig.go | 91 +--------------------- 5 files changed, 16 insertions(+), 99 deletions(-) diff --git a/integration-tests/go.mod b/integration-tests/go.mod index 3a97428c1d7..324b5c4a81a 100644 --- a/integration-tests/go.mod +++ b/integration-tests/go.mod @@ -19,7 +19,7 @@ require ( github.com/manifoldco/promptui v0.9.0 github.com/montanaflynn/stats v0.7.1 github.com/onsi/gomega v1.30.0 - github.com/pelletier/go-toml/v2 v2.1.1 + github.com/pelletier/go-toml/v2 v2.2.2 github.com/pkg/errors v0.9.1 github.com/rs/zerolog v1.30.0 github.com/scylladb/go-reflectx v1.0.1 @@ -28,7 +28,7 @@ require ( github.com/slack-go/slack v0.12.2 github.com/smartcontractkit/chainlink-automation v1.0.3 github.com/smartcontractkit/chainlink-common v0.1.7-0.20240607135320-c9bc0a2ac0ce - github.com/smartcontractkit/chainlink-testing-framework v1.30.1 + github.com/smartcontractkit/chainlink-testing-framework v1.30.3-0.20240610093648-6c2eb6f0be7f github.com/smartcontractkit/chainlink-vrf v0.0.0-20231120191722-fef03814f868 github.com/smartcontractkit/chainlink/v2 v2.0.0-00010101000000-000000000000 github.com/smartcontractkit/libocr v0.0.0-20240419185742-fd3cab206b2c diff --git a/integration-tests/go.sum b/integration-tests/go.sum index 7d919450ff0..3229eb058d7 100644 --- a/integration-tests/go.sum +++ b/integration-tests/go.sum @@ -1354,8 +1354,8 @@ github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/9 github.com/pelletier/go-toml v1.7.0/go.mod h1:vwGMzjaWMwyfHwgIBhI2YUM4fB6nL6lVAvS1LBMMhTE= github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8= github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= -github.com/pelletier/go-toml/v2 v2.1.1 h1:LWAJwfNvjQZCFIDKWYQaM62NcYeYViCmWIwmOStowAI= -github.com/pelletier/go-toml/v2 v2.1.1/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc= +github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM= +github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs= github.com/peterbourgon/diskv v2.0.1+incompatible h1:UBdAOUP5p4RWqPBg048CAvpKN+vxiaj6gdUUzhl4XmI= github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU= github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5/go.mod h1:jvVRKCrJTQWu0XVbaOlby/2lO20uSCHEMzzplHXte1o= @@ -1524,8 +1524,8 @@ github.com/smartcontractkit/chainlink-solana v1.0.3-0.20240605170242-555ff582f36 github.com/smartcontractkit/chainlink-solana v1.0.3-0.20240605170242-555ff582f36a/go.mod h1:QqcZSwLgEIn7YraAIRmomnBMAuVFephiHrIWVlkWbFI= github.com/smartcontractkit/chainlink-starknet/relayer v0.0.1-beta-test.0.20240531021326-99118e47f696 h1:h1E87+z+JcUEfvbJVF56SnZA/YUFE5ewUE61MaR/Ewg= github.com/smartcontractkit/chainlink-starknet/relayer v0.0.1-beta-test.0.20240531021326-99118e47f696/go.mod h1:OiWUTrrpSLLTMh7FINWjEh6mmDJCVPaC4yEsDCVaWdU= -github.com/smartcontractkit/chainlink-testing-framework v1.30.1 h1:JFoeSuOvdx8Rmfh5Z4KOH0FnjiLw3M2p7T4GLzTPLMk= -github.com/smartcontractkit/chainlink-testing-framework v1.30.1/go.mod h1:oEIggLGWyWfLkjWvuXLol8inUT4YbBb06fJx/S60gQ4= +github.com/smartcontractkit/chainlink-testing-framework v1.30.3-0.20240610093648-6c2eb6f0be7f h1:7DwJvplUqxn8L9PEtAwQ5m2tTIJwnXL6JXPzWM4wJMQ= +github.com/smartcontractkit/chainlink-testing-framework v1.30.3-0.20240610093648-6c2eb6f0be7f/go.mod h1:E6uNEZhZZid9PHv6/Kq5Vn63GlO61ZcKB+/f0DKo3Q4= github.com/smartcontractkit/chainlink-testing-framework/grafana v0.0.0-20240328204215-ac91f55f1449 h1:fX/xmGm1GBsD1ZZnooNT+eWA0hiTAqFlHzOC5CY4dy8= github.com/smartcontractkit/chainlink-testing-framework/grafana v0.0.0-20240328204215-ac91f55f1449/go.mod h1:DC8sQMyTlI/44UCTL8QWFwb0bYNoXCfjwCv2hMivYZU= github.com/smartcontractkit/chainlink-vrf v0.0.0-20231120191722-fef03814f868 h1:FFdvEzlYwcuVHkdZ8YnZR/XomeMGbz5E2F2HZI3I3w8= diff --git a/integration-tests/load/go.mod b/integration-tests/load/go.mod index 14e3902780f..141e9745eb1 100644 --- a/integration-tests/load/go.mod +++ b/integration-tests/load/go.mod @@ -11,13 +11,13 @@ require ( github.com/K-Phoen/grabana v0.22.1 github.com/ethereum/go-ethereum v1.13.8 github.com/go-resty/resty/v2 v2.11.0 - github.com/pelletier/go-toml/v2 v2.1.1 + github.com/pelletier/go-toml/v2 v2.2.2 github.com/pkg/errors v0.9.1 github.com/rs/zerolog v1.30.0 github.com/slack-go/slack v0.12.2 github.com/smartcontractkit/chainlink-automation v1.0.3 github.com/smartcontractkit/chainlink-common v0.1.7-0.20240607135320-c9bc0a2ac0ce - github.com/smartcontractkit/chainlink-testing-framework v1.30.1 + github.com/smartcontractkit/chainlink-testing-framework v1.30.3-0.20240610093648-6c2eb6f0be7f github.com/smartcontractkit/chainlink/integration-tests v0.0.0-20240214231432-4ad5eb95178c github.com/smartcontractkit/chainlink/v2 v2.9.0-beta0.0.20240216210048-da02459ddad8 github.com/smartcontractkit/libocr v0.0.0-20240419185742-fd3cab206b2c diff --git a/integration-tests/load/go.sum b/integration-tests/load/go.sum index a9a975f2bb3..42921345d7d 100644 --- a/integration-tests/load/go.sum +++ b/integration-tests/load/go.sum @@ -1344,8 +1344,8 @@ github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/9 github.com/pelletier/go-toml v1.7.0/go.mod h1:vwGMzjaWMwyfHwgIBhI2YUM4fB6nL6lVAvS1LBMMhTE= github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8= github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= -github.com/pelletier/go-toml/v2 v2.1.1 h1:LWAJwfNvjQZCFIDKWYQaM62NcYeYViCmWIwmOStowAI= -github.com/pelletier/go-toml/v2 v2.1.1/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc= +github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM= +github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs= github.com/peterbourgon/diskv v2.0.1+incompatible h1:UBdAOUP5p4RWqPBg048CAvpKN+vxiaj6gdUUzhl4XmI= github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU= github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5/go.mod h1:jvVRKCrJTQWu0XVbaOlby/2lO20uSCHEMzzplHXte1o= @@ -1514,8 +1514,8 @@ github.com/smartcontractkit/chainlink-solana v1.0.3-0.20240605170242-555ff582f36 github.com/smartcontractkit/chainlink-solana v1.0.3-0.20240605170242-555ff582f36a/go.mod h1:QqcZSwLgEIn7YraAIRmomnBMAuVFephiHrIWVlkWbFI= github.com/smartcontractkit/chainlink-starknet/relayer v0.0.1-beta-test.0.20240531021326-99118e47f696 h1:h1E87+z+JcUEfvbJVF56SnZA/YUFE5ewUE61MaR/Ewg= github.com/smartcontractkit/chainlink-starknet/relayer v0.0.1-beta-test.0.20240531021326-99118e47f696/go.mod h1:OiWUTrrpSLLTMh7FINWjEh6mmDJCVPaC4yEsDCVaWdU= -github.com/smartcontractkit/chainlink-testing-framework v1.30.1 h1:JFoeSuOvdx8Rmfh5Z4KOH0FnjiLw3M2p7T4GLzTPLMk= -github.com/smartcontractkit/chainlink-testing-framework v1.30.1/go.mod h1:oEIggLGWyWfLkjWvuXLol8inUT4YbBb06fJx/S60gQ4= +github.com/smartcontractkit/chainlink-testing-framework v1.30.3-0.20240610093648-6c2eb6f0be7f h1:7DwJvplUqxn8L9PEtAwQ5m2tTIJwnXL6JXPzWM4wJMQ= +github.com/smartcontractkit/chainlink-testing-framework v1.30.3-0.20240610093648-6c2eb6f0be7f/go.mod h1:E6uNEZhZZid9PHv6/Kq5Vn63GlO61ZcKB+/f0DKo3Q4= github.com/smartcontractkit/chainlink-testing-framework/grafana v0.0.0-20240328204215-ac91f55f1449 h1:fX/xmGm1GBsD1ZZnooNT+eWA0hiTAqFlHzOC5CY4dy8= github.com/smartcontractkit/chainlink-testing-framework/grafana v0.0.0-20240328204215-ac91f55f1449/go.mod h1:DC8sQMyTlI/44UCTL8QWFwb0bYNoXCfjwCv2hMivYZU= github.com/smartcontractkit/chainlink-vrf v0.0.0-20231120191722-fef03814f868 h1:FFdvEzlYwcuVHkdZ8YnZR/XomeMGbz5E2F2HZI3I3w8= diff --git a/integration-tests/testconfig/testconfig.go b/integration-tests/testconfig/testconfig.go index ff2ddf3a449..aeddcd1733d 100644 --- a/integration-tests/testconfig/testconfig.go +++ b/integration-tests/testconfig/testconfig.go @@ -13,7 +13,6 @@ import ( "github.com/google/uuid" "github.com/pelletier/go-toml/v2" "github.com/pkg/errors" - "github.com/rs/zerolog" "golang.org/x/text/cases" "golang.org/x/text/language" @@ -279,15 +278,6 @@ func GetConfig(configurationName string, product Product) (TestConfig, error) { testConfig.ConfigurationName = configurationName logger.Debug().Msgf("Will apply configuration named '%s' if it is found in any of the configs", configurationName) - var handleSpecialOverrides = func(logger zerolog.Logger, filename, configurationName string, target *TestConfig, content []byte, product Product) error { - switch product { - case Automation: - return handleAutomationConfigOverride(logger, filename, configurationName, target, content) - default: - return handleDefaultConfigOverride(logger, filename, configurationName, target, content) - } - } - // read embedded configs is build tag "embed" is set // this makes our life much easier when using a binary if areConfigsEmbedded { @@ -302,7 +292,7 @@ func GetConfig(configurationName string, product Product) (TestConfig, error) { return TestConfig{}, errors.Wrapf(err, "error reading embedded config") } - err = handleSpecialOverrides(logger, fileName, configurationName, &testConfig, file, product) + err = ctf_config.BytesToAnyTomlStruct(logger, fileName, configurationName, &testConfig, file) if err != nil { return TestConfig{}, errors.Wrapf(err, "error unmarshalling embedded config") } @@ -327,7 +317,7 @@ func GetConfig(configurationName string, product Product) (TestConfig, error) { return TestConfig{}, errors.Wrapf(err, "error reading file %s", filePath) } - err = handleSpecialOverrides(logger, fileName, configurationName, &testConfig, content, product) + err = ctf_config.BytesToAnyTomlStruct(logger, fileName, configurationName, &testConfig, content) if err != nil { return TestConfig{}, errors.Wrapf(err, "error reading file %s", filePath) } @@ -342,7 +332,7 @@ func GetConfig(configurationName string, product Product) (TestConfig, error) { return TestConfig{}, err } - err = handleSpecialOverrides(logger, Base64OverrideEnvVarName, configurationName, &testConfig, decoded, product) + err = ctf_config.BytesToAnyTomlStruct(logger, Base64OverrideEnvVarName, configurationName, &testConfig, decoded) if err != nil { return TestConfig{}, errors.Wrapf(err, "error unmarshaling base64 config") } @@ -350,7 +340,7 @@ func GetConfig(configurationName string, product Product) (TestConfig, error) { logger.Debug().Msg("Base64 config override from environment variable not found") } - // it neede some custom logic, so we do it separately + // it needs some custom logic, so we do it separately err := testConfig.readNetworkConfiguration() if err != nil { return TestConfig{}, errors.Wrapf(err, "error reading network config") @@ -570,76 +560,3 @@ func readFile(filePath string) ([]byte, error) { return content, nil } - -func handleAutomationConfigOverride(logger zerolog.Logger, filename, configurationName string, target *TestConfig, content []byte) error { - logger.Debug().Msgf("Handling automation 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.Automation != nil && len(newConfig.Automation.Load) > 0) && (oldConfig != nil && oldConfig.Automation != nil && len(oldConfig.Automation.Load) > 0) { - target.Automation.Load = newConfig.Automation.Load - } - - 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) - } - - // temporary fix for Duration not being correctly copied - if oldConfig != nil && oldConfig.Seth != nil && oldConfig.Seth.Networks != nil { - for i, old_network := range oldConfig.Seth.Networks { - for _, target_network := range target.Seth.Networks { - if old_network.ChainID == target_network.ChainID { - oldConfig.Seth.Networks[i].TxnTimeout = target_network.TxnTimeout - } - } - } - } - - // override instead of merging - if (newConfig.Seth != nil && len(newConfig.Seth.Networks) > 0) && (oldConfig != nil && oldConfig.Seth != nil && len(oldConfig.Seth.Networks) > 0) { - networksToUse := map[string]*seth.Network{} - 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 - break - } - if _, ok := networksToUse[new_network.ChainID]; !ok { - networksToUse[new_network.ChainID] = new_network - } - } - networksToUse[old_network.ChainID] = oldConfig.Seth.Networks[i] - } - target.Seth.Networks = []*seth.Network{} - for _, network := range networksToUse { - target.Seth.Networks = append(target.Seth.Networks, network) - } - } - - return nil -}