diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index 74ce6edac25..8c1d5be828c 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -803,7 +803,7 @@ jobs: pull-requests: write id-token: write contents: read - needs: [build-chainlink, build-test-image] + needs: [build-chainlink] env: SELECTED_NETWORKS: ${{ matrix.testnet }} CHAINLINK_COMMIT_SHA: ${{ github.sha }} @@ -812,11 +812,11 @@ jobs: EVM_KEYS: ${{ secrets.QA_EVM_KEYS }} TEST_EVM_KEYS: ${{ secrets.QA_EVM_KEYS }} - TEST_OPTIMISM_GOERLI_URLS: ${{ secrets.QA_OPTIMISM_GOERLI_URLS }} - TEST_OPTIMISM_GOERLI_HTTP_URLS: ${{ secrets.QA_OPTIMISM_GOERLI_HTTP_URLS }} + OPTIMISM_GOERLI_URLS: ${{ secrets.QA_OPTIMISM_GOERLI_URLS }} + OPTIMISM_GOERLI_HTTP_URLS: ${{ secrets.QA_OPTIMISM_GOERLI_HTTP_URLS }} - TEST_ARBITRUM_GOERLI_URLS: ${{ secrets.QA_ARBITRUM_GOERLI_URLS }} - TEST_ARBITRUM_GOERLI_HTTP_URLS: ${{ secrets.QA_ARBITRUM_GOERLI_HTTP_URLS }} + ARBITRUM_GOERLI_URLS: ${{ secrets.QA_ARBITRUM_GOERLI_URLS }} + ARBITRUM_GOERLI_HTTP_URLS: ${{ secrets.QA_ARBITRUM_GOERLI_HTTP_URLS }} strategy: fail-fast: false matrix: diff --git a/integration-tests/actions/actions.go b/integration-tests/actions/actions.go index ffb71cb7424..82187fd0cb8 100644 --- a/integration-tests/actions/actions.go +++ b/integration-tests/actions/actions.go @@ -263,7 +263,7 @@ func TeardownSuite( for _, c := range clients { if c != nil && chainlinkNodes != nil && len(chainlinkNodes) > 0 { - if err := returnFunds(chainlinkNodes, c); err != nil { + if err := ReturnFunds(chainlinkNodes, c); err != nil { // This printed line is required for tests that use real funds to propagate the failure // out to the system running the test. Do not remove fmt.Println(environment.FAILED_FUND_RETURN) @@ -306,7 +306,7 @@ func TeardownRemoteSuite( l.Warn().Msgf("Error deleting jobs %+v", err) } - if err = returnFunds(chainlinkNodes, client); err != nil { + if err = ReturnFunds(chainlinkNodes, client); err != nil { l.Error().Err(err).Str("Namespace", namespace). Msg("Error attempting to return funds from chainlink nodes to network's default wallet. " + "Environment is left running so you can try manually!") @@ -337,8 +337,9 @@ func DeleteAllJobs(chainlinkNodes []*client.ChainlinkK8sClient) error { return nil } -// Returns all the funds from the chainlink nodes to the networks default address -func returnFunds(chainlinkNodes []*client.ChainlinkK8sClient, blockchainClient blockchain.EVMClient) error { +// ReturnFunds attempts to return all the funds from the chainlink nodes to the network's default address +// all from a remote, k8s style environment +func ReturnFunds(chainlinkNodes []*client.ChainlinkK8sClient, blockchainClient blockchain.EVMClient) error { if blockchainClient == nil { return errors.New("blockchain client is nil, unable to return funds from chainlink nodes") } diff --git a/integration-tests/actions/automation_ocr_helpers.go b/integration-tests/actions/automation_ocr_helpers.go index a2f2633f68d..bfea6ec302c 100644 --- a/integration-tests/actions/automation_ocr_helpers.go +++ b/integration-tests/actions/automation_ocr_helpers.go @@ -11,25 +11,23 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/lib/pq" - ocr3 "github.com/smartcontractkit/libocr/offchainreporting2plus/ocr3confighelper" - "github.com/stretchr/testify/require" - "gopkg.in/guregu/null.v4" "github.com/smartcontractkit/chainlink-testing-framework/blockchain" "github.com/smartcontractkit/chainlink-testing-framework/utils" + "github.com/smartcontractkit/chainlink/v2/core/services/job" + "github.com/smartcontractkit/chainlink/v2/core/services/keystore/chaintype" + "github.com/smartcontractkit/chainlink/v2/core/store/models" ocr2 "github.com/smartcontractkit/libocr/offchainreporting2plus/confighelper" + ocr3 "github.com/smartcontractkit/libocr/offchainreporting2plus/ocr3confighelper" + "github.com/smartcontractkit/libocr/offchainreporting2plus/types" ocr2keepers20config "github.com/smartcontractkit/ocr2keepers/pkg/v2/config" ocr2keepers30config "github.com/smartcontractkit/ocr2keepers/pkg/v3/config" + "github.com/stretchr/testify/require" + "gopkg.in/guregu/null.v4" "github.com/smartcontractkit/chainlink/integration-tests/client" "github.com/smartcontractkit/chainlink/integration-tests/contracts" "github.com/smartcontractkit/chainlink/integration-tests/contracts/ethereum" - - "github.com/smartcontractkit/libocr/offchainreporting2plus/types" - - "github.com/smartcontractkit/chainlink/v2/core/services/job" - "github.com/smartcontractkit/chainlink/v2/core/services/keystore/chaintype" - "github.com/smartcontractkit/chainlink/v2/core/store/models" ) func BuildAutoOCR2ConfigVars( diff --git a/integration-tests/docker/test_env/cl_node.go b/integration-tests/docker/test_env/cl_node.go index 0ec62808feb..a78f9e52ad6 100644 --- a/integration-tests/docker/test_env/cl_node.go +++ b/integration-tests/docker/test_env/cl_node.go @@ -18,17 +18,16 @@ import ( "github.com/pelletier/go-toml/v2" "github.com/pkg/errors" "github.com/rs/zerolog/log" - "github.com/smartcontractkit/chainlink-testing-framework/docker/test_env" tc "github.com/testcontainers/testcontainers-go" tcwait "github.com/testcontainers/testcontainers-go/wait" "github.com/smartcontractkit/chainlink-testing-framework/blockchain" + "github.com/smartcontractkit/chainlink-testing-framework/docker/test_env" "github.com/smartcontractkit/chainlink-testing-framework/logwatch" - ocrtypes "github.com/smartcontractkit/libocr/offchainreporting2/types" - "github.com/smartcontractkit/libocr/offchainreporting2plus/confighelper" - "github.com/smartcontractkit/chainlink/v2/core/services/chainlink" "github.com/smartcontractkit/chainlink/v2/core/services/keystore/chaintype" + ocrtypes "github.com/smartcontractkit/libocr/offchainreporting2/types" + "github.com/smartcontractkit/libocr/offchainreporting2plus/confighelper" "github.com/smartcontractkit/chainlink/integration-tests/client" "github.com/smartcontractkit/chainlink/integration-tests/utils" diff --git a/integration-tests/docker/test_env/test_env.go b/integration-tests/docker/test_env/test_env.go index c056e92b9fc..e90bf5618ab 100644 --- a/integration-tests/docker/test_env/test_env.go +++ b/integration-tests/docker/test_env/test_env.go @@ -1,8 +1,10 @@ package test_env import ( + "encoding/json" "math/big" + "github.com/ethereum/go-ethereum/accounts/keystore" "github.com/ethereum/go-ethereum/common" "github.com/pkg/errors" "github.com/rs/zerolog/log" @@ -12,7 +14,6 @@ import ( "github.com/smartcontractkit/chainlink-testing-framework/blockchain" "github.com/smartcontractkit/chainlink-testing-framework/docker/test_env" "github.com/smartcontractkit/chainlink-testing-framework/logwatch" - "github.com/smartcontractkit/chainlink/v2/core/services/chainlink" "github.com/smartcontractkit/chainlink/integration-tests/client" @@ -194,3 +195,43 @@ func (te *CLClusterTestEnv) Terminate() error { // the containers and the Network return nil } + +// Cleanup cleans the environment up after it's done being used, mainly for returning funds when on live networks. +// Intended to be used as part of t.Cleanup() in tests. +func (te *CLClusterTestEnv) Cleanup() error { + log.Info().Msg("Attempting to return Chainlink node funds to default network wallets") + if te.EVMClient == nil { + return errors.New("blockchain client is nil, unable to return funds from chainlink nodes") + } + if te.CLNodes == nil { + return errors.New("chainlink nodes are nil, unable to return funds from chainlink nodes") + } + if te.EVMClient.NetworkSimulated() { + log.Info().Str("Network Name", te.EVMClient.GetNetworkName()). + Msg("Network is a simulated network. Skipping fund return.") + return nil + } + + for _, chainlinkNode := range te.CLNodes { + fundedKeys, err := chainlinkNode.API.ExportEVMKeysForChain(te.EVMClient.GetChainID().String()) + if err != nil { + return err + } + for _, key := range fundedKeys { + keyToDecrypt, err := json.Marshal(key) + if err != nil { + return err + } + // This can take up a good bit of RAM and time. When running on the remote-test-runner, this can lead to OOM + // issues. So we avoid running in parallel; slower, but safer. + decryptedKey, err := keystore.DecryptKey(keyToDecrypt, client.ChainlinkKeyPassword) + if err != nil { + return err + } + if err = te.EVMClient.ReturnFunds(decryptedKey.PrivateKey); err != nil { + return err + } + } + } + return nil +} diff --git a/integration-tests/docker/test_env/test_env_builder.go b/integration-tests/docker/test_env/test_env_builder.go index bacee0c956f..27f98b36139 100644 --- a/integration-tests/docker/test_env/test_env_builder.go +++ b/integration-tests/docker/test_env/test_env_builder.go @@ -6,11 +6,10 @@ import ( "github.com/pkg/errors" "github.com/rs/zerolog/log" - "github.com/smartcontractkit/chainlink-testing-framework/docker/test_env" "github.com/smartcontractkit/chainlink-testing-framework/blockchain" + "github.com/smartcontractkit/chainlink-testing-framework/docker/test_env" "github.com/smartcontractkit/chainlink-testing-framework/logwatch" - "github.com/smartcontractkit/chainlink/v2/core/services/chainlink" "github.com/smartcontractkit/chainlink/integration-tests/contracts" diff --git a/integration-tests/networks/known_networks.go b/integration-tests/networks/known_networks.go index 41148ba2043..4d12d6b5b60 100644 --- a/integration-tests/networks/known_networks.go +++ b/integration-tests/networks/known_networks.go @@ -558,17 +558,18 @@ func setKeys(prefix string, network *blockchain.EVMNetwork) { } envVar := fmt.Sprintf("%s_KEYS", prefix) - keysEnv, err := utils.GetEnv(envVar) + keysFromEnv, err := utils.GetEnv(envVar) if err != nil { log.Fatal().Err(err).Str("env var", envVar).Msg("Error getting env var") } - if keysEnv == "" { - keys := strings.Split(os.Getenv("EVM_KEYS"), ",") + if keysFromEnv == "" { log.Warn().Msg(fmt.Sprintf("No '%s' env var defined, defaulting to 'EVM_KEYS'", envVar)) - network.PrivateKeys = keys - return + keysFromEnv = os.Getenv("EVM_KEYS") + } + keys := strings.Split(keysFromEnv, ",") + for i, key := range keys { + keys[i] = strings.TrimPrefix(key, "0x") } - keys := strings.Split(keysEnv, ",") network.PrivateKeys = keys // log public keys for debugging diff --git a/integration-tests/smoke/automation_test.go b/integration-tests/smoke/automation_test.go index 8855a8a125d..5aa7668d151 100644 --- a/integration-tests/smoke/automation_test.go +++ b/integration-tests/smoke/automation_test.go @@ -11,6 +11,7 @@ import ( "time" "github.com/onsi/gomega" + "github.com/rs/zerolog/log" "github.com/stretchr/testify/require" "go.uber.org/zap/zapcore" @@ -108,7 +109,9 @@ func SetupAutomationBasic(t *testing.T, nodeUpgrade bool) { "registry_2_1_logtrigger": ethereum.RegistryVersion_2_1, } - for name, registryVersion := range registryVersions { + for n, rv := range registryVersions { + name := n + registryVersion := rv t.Run(name, func(t *testing.T) { t.Parallel() @@ -234,7 +237,9 @@ func TestAutomationAddFunds(t *testing.T) { "registry_2_1": ethereum.RegistryVersion_2_1, } - for name, registryVersion := range registryVersions { + for n, rv := range registryVersions { + name := n + registryVersion := rv t.Run(name, func(t *testing.T) { t.Parallel() @@ -288,7 +293,9 @@ func TestAutomationPauseUnPause(t *testing.T) { "registry_2_1": ethereum.RegistryVersion_2_1, } - for name, registryVersion := range registryVersions { + for n, rv := range registryVersions { + name := n + registryVersion := rv t.Run(name, func(t *testing.T) { t.Parallel() @@ -303,7 +310,7 @@ func TestAutomationPauseUnPause(t *testing.T) { gom := gomega.NewGomegaWithT(t) gom.Eventually(func(g gomega.Gomega) { - // Check if the upkeeps are performing multiple times by analysing their counters and checking they are greater than 5 + // Check if the upkeeps are performing multiple times by analyzing their counters and checking they are greater than 5 for i := 0; i < len(upkeepIDs); i++ { counter, err := consumers[i].Counter(context.Background()) g.Expect(err).ShouldNot(gomega.HaveOccurred(), "Failed to retrieve consumer counter for upkeep at index %d", i) @@ -374,7 +381,9 @@ func TestAutomationRegisterUpkeep(t *testing.T) { "registry_2_1": ethereum.RegistryVersion_2_1, } - for name, registryVersion := range registryVersions { + for n, rv := range registryVersions { + name := n + registryVersion := rv t.Run(name, func(t *testing.T) { t.Parallel() @@ -448,7 +457,9 @@ func TestAutomationPauseRegistry(t *testing.T) { "registry_2_1": ethereum.RegistryVersion_2_1, } - for name, registryVersion := range registryVersions { + for n, rv := range registryVersions { + name := n + registryVersion := rv t.Run(name, func(t *testing.T) { t.Parallel() chainClient, _, contractDeployer, linkToken, registry, registrar, onlyStartRunner, _ := setupAutomationTest( @@ -508,7 +519,9 @@ func TestAutomationKeeperNodesDown(t *testing.T) { "registry_2_1": ethereum.RegistryVersion_2_1, } - for name, registryVersion := range registryVersions { + for n, rv := range registryVersions { + name := n + registryVersion := rv t.Run(name, func(t *testing.T) { t.Parallel() @@ -596,7 +609,9 @@ func TestAutomationPerformSimulation(t *testing.T) { "registry_2_1": ethereum.RegistryVersion_2_1, } - for name, registryVersion := range registryVersions { + for n, rv := range registryVersions { + name := n + registryVersion := rv t.Run(name, func(t *testing.T) { t.Parallel() @@ -663,7 +678,9 @@ func TestAutomationCheckPerformGasLimit(t *testing.T) { "registry_2_1": ethereum.RegistryVersion_2_1, } - for name, registryVersion := range registryVersions { + for n, rv := range registryVersions { + name := n + registryVersion := rv t.Run(name, func(t *testing.T) { t.Parallel() @@ -779,7 +796,9 @@ func TestUpdateCheckData(t *testing.T) { "registry_2_1": ethereum.RegistryVersion_2_1, } - for name, registryVersion := range registryVersions { + for n, rv := range registryVersions { + name := n + registryVersion := rv t.Run(name, func(t *testing.T) { t.Parallel() @@ -902,6 +921,11 @@ func setupAutomationTest( require.NoError(t, err, "Error building contract deployer") chainlinkNodes, err = client.ConnectChainlinkNodes(testEnvironment) require.NoError(t, err, "Error connecting to Chainlink nodes") + t.Cleanup(func() { + if err := actions.ReturnFunds(chainlinkNodes, chainClient); err != nil { + log.Error().Err(err).Msg("Error returning funds") + } + }) chainClient.ParallelTransactions(true) txCost, err := chainClient.EstimateCostForChainlinkOperations(1000) diff --git a/integration-tests/smoke/cron_test.go b/integration-tests/smoke/cron_test.go index 30eadb8f16b..0285e2d23c7 100644 --- a/integration-tests/smoke/cron_test.go +++ b/integration-tests/smoke/cron_test.go @@ -2,16 +2,21 @@ package smoke import ( "fmt" + "testing" + "github.com/google/uuid" "github.com/onsi/gomega" + "github.com/stretchr/testify/require" + + "github.com/smartcontractkit/chainlink-testing-framework/utils" + "github.com/smartcontractkit/chainlink/integration-tests/client" "github.com/smartcontractkit/chainlink/integration-tests/docker/test_env" - "github.com/stretchr/testify/require" - "testing" ) func TestCronBasic(t *testing.T) { t.Parallel() + l := utils.GetTestLogger(t) env, err := test_env.NewCLTestEnvBuilder(). WithGeth(). @@ -19,6 +24,12 @@ func TestCronBasic(t *testing.T) { WithCLNodes(1). Build() require.NoError(t, err) + t.Cleanup(func() { + if err := env.Cleanup(); err != nil { + l.Error().Err(err).Msg("Error cleaning up test environment") + } + }) + err = env.MockServer.Client.SetValuePath("/variable", 5) require.NoError(t, err, "Setting value path in mockserver shouldn't fail") diff --git a/integration-tests/smoke/flux_test.go b/integration-tests/smoke/flux_test.go index da06fc4b57a..c4cd02b857d 100644 --- a/integration-tests/smoke/flux_test.go +++ b/integration-tests/smoke/flux_test.go @@ -3,18 +3,21 @@ package smoke import ( "context" "fmt" + "math/big" + "strings" + "testing" + "time" + "github.com/ethereum/go-ethereum/common" "github.com/google/uuid" + "github.com/stretchr/testify/require" + "github.com/smartcontractkit/chainlink-testing-framework/utils" + "github.com/smartcontractkit/chainlink/integration-tests/actions" "github.com/smartcontractkit/chainlink/integration-tests/client" "github.com/smartcontractkit/chainlink/integration-tests/contracts" "github.com/smartcontractkit/chainlink/integration-tests/docker/test_env" - "github.com/stretchr/testify/require" - "math/big" - "strings" - "testing" - "time" ) func TestFluxBasic(t *testing.T) { @@ -27,6 +30,12 @@ func TestFluxBasic(t *testing.T) { WithCLNodes(3). Build() require.NoError(t, err) + t.Cleanup(func() { + if err := env.Cleanup(); err != nil { + l.Error().Err(err).Msg("Error cleaning up test environment") + } + }) + nodeAddresses, err := env.ChainlinkNodeAddresses() require.NoError(t, err, "Retrieving on-chain wallet addresses for chainlink nodes shouldn't fail") env.EVMClient.ParallelTransactions(true) diff --git a/integration-tests/smoke/forwarder_ocr_test.go b/integration-tests/smoke/forwarder_ocr_test.go index 0b58be41d74..e4cf5cb0527 100644 --- a/integration-tests/smoke/forwarder_ocr_test.go +++ b/integration-tests/smoke/forwarder_ocr_test.go @@ -1,26 +1,37 @@ package smoke import ( + "context" "math/big" "testing" - "context" "github.com/ethereum/go-ethereum/common" + "github.com/stretchr/testify/require" + + "github.com/smartcontractkit/chainlink-testing-framework/utils" + "github.com/smartcontractkit/chainlink/integration-tests/actions" "github.com/smartcontractkit/chainlink/integration-tests/docker/test_env" - "github.com/stretchr/testify/require" ) func TestForwarderOCRBasic(t *testing.T) { t.Parallel() + l := utils.GetTestLogger(t) + env, err := test_env.NewCLTestEnvBuilder(). WithGeth(). WithMockServer(1). WithForwarders(). WithCLNodes(6). - WithFunding(big.NewFloat(10)). + WithFunding(big.NewFloat(.1)). Build() require.NoError(t, err) + t.Cleanup(func() { + if err := env.Cleanup(); err != nil { + l.Error().Err(err).Msg("Error cleaning up test environment") + } + }) + env.ParallelTransactions(true) nodeClients := env.GetAPIs() @@ -55,6 +66,7 @@ func TestForwarderOCRBasic(t *testing.T) { authorizedForwarders, env.EVMClient, ) + require.NoError(t, err, "Error deploying OCR contracts") err = actions.CreateOCRJobsWithForwarderLocal(ocrInstances, bootstrapNode, workerNodes, 5, env.MockServer.Client) require.NoError(t, err, "failed to setup forwarder jobs") diff --git a/integration-tests/smoke/forwarders_ocr2_test.go b/integration-tests/smoke/forwarders_ocr2_test.go index cb6a3f0556d..81c521ff387 100644 --- a/integration-tests/smoke/forwarders_ocr2_test.go +++ b/integration-tests/smoke/forwarders_ocr2_test.go @@ -10,6 +10,8 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/stretchr/testify/require" + "github.com/smartcontractkit/chainlink-testing-framework/utils" + "github.com/smartcontractkit/chainlink/integration-tests/actions" "github.com/smartcontractkit/chainlink/integration-tests/docker/test_env" "github.com/smartcontractkit/chainlink/integration-tests/types/config/node" @@ -17,6 +19,8 @@ import ( func TestForwarderOCR2Basic(t *testing.T) { t.Parallel() + l := utils.GetTestLogger(t) + env, err := test_env.NewCLTestEnvBuilder(). WithGeth(). WithMockServer(1). @@ -26,9 +30,15 @@ func TestForwarderOCR2Basic(t *testing.T) { )). WithForwarders(). WithCLNodes(6). - WithFunding(big.NewFloat(10)). + WithFunding(big.NewFloat(.1)). Build() require.NoError(t, err) + t.Cleanup(func() { + if err := env.Cleanup(); err != nil { + l.Error().Err(err).Msg("Error cleaning up test environment") + } + }) + env.ParallelTransactions(true) nodeClients := env.GetAPIs() diff --git a/integration-tests/smoke/keeper_test.go b/integration-tests/smoke/keeper_test.go index 00cbe07eb0f..f07c42ab3d8 100644 --- a/integration-tests/smoke/keeper_test.go +++ b/integration-tests/smoke/keeper_test.go @@ -14,6 +14,7 @@ import ( "github.com/smartcontractkit/chainlink-testing-framework/blockchain" "github.com/smartcontractkit/chainlink-testing-framework/utils" + "github.com/smartcontractkit/chainlink/v2/core/store/models" "github.com/smartcontractkit/chainlink/integration-tests/actions" "github.com/smartcontractkit/chainlink/integration-tests/client" @@ -21,7 +22,6 @@ import ( "github.com/smartcontractkit/chainlink/integration-tests/contracts/ethereum" "github.com/smartcontractkit/chainlink/integration-tests/docker/test_env" "github.com/smartcontractkit/chainlink/integration-tests/types/config/node" - "github.com/smartcontractkit/chainlink/v2/core/store/models" ) const ( @@ -105,7 +105,7 @@ func TestKeeperBasicSmoke(t *testing.T) { require.NoError(t, err, "Error creating keeper jobs") gom.Eventually(func(g gomega.Gomega) error { - // Check if the upkeeps are performing multiple times by analysing their counters and checking they are greater than 10 + // Check if the upkeeps are performing multiple times by analyzing their counters and checking they are greater than 10 for i := 0; i < len(upkeepIDs); i++ { counter, err := consumers[i].Counter(context.Background()) g.Expect(err).ShouldNot(gomega.HaveOccurred(), "Failed to retrieve consumer counter for upkeep at index %d", i) @@ -1089,6 +1089,7 @@ func setupKeeperTest(t *testing.T) ( clNodeConfig.Keeper.TurnLookBack = &turnLookBack clNodeConfig.Keeper.Registry.SyncInterval = &syncInterval clNodeConfig.Keeper.Registry.PerformGasOverhead = &performGasOverhead + l := utils.GetTestLogger(t) env, err := test_env.NewCLTestEnvBuilder(). WithGeth(). @@ -1098,6 +1099,11 @@ func setupKeeperTest(t *testing.T) ( WithFunding(big.NewFloat(.5)). Build() require.NoError(t, err, "Error deploying test environment") + t.Cleanup(func() { + if err := env.Cleanup(); err != nil { + l.Error().Err(err).Msg("Error cleaning up test environment") + } + }) env.ParallelTransactions(true) diff --git a/integration-tests/smoke/ocr2_test.go b/integration-tests/smoke/ocr2_test.go index 7dd0b23223c..6588586c39d 100644 --- a/integration-tests/smoke/ocr2_test.go +++ b/integration-tests/smoke/ocr2_test.go @@ -4,27 +4,32 @@ import ( "context" "fmt" "math/big" + "strings" "testing" "time" + "github.com/stretchr/testify/require" + "github.com/smartcontractkit/chainlink-env/environment" "github.com/smartcontractkit/chainlink-env/pkg/helm/chainlink" "github.com/smartcontractkit/chainlink-env/pkg/helm/ethereum" "github.com/smartcontractkit/chainlink-env/pkg/helm/mockserver" mockservercfg "github.com/smartcontractkit/chainlink-env/pkg/helm/mockserver-cfg" "github.com/smartcontractkit/chainlink-testing-framework/blockchain" + "github.com/smartcontractkit/chainlink-testing-framework/utils" + "github.com/smartcontractkit/chainlink/integration-tests/actions" "github.com/smartcontractkit/chainlink/integration-tests/client" "github.com/smartcontractkit/chainlink/integration-tests/config" "github.com/smartcontractkit/chainlink/integration-tests/docker/test_env" "github.com/smartcontractkit/chainlink/integration-tests/networks" "github.com/smartcontractkit/chainlink/integration-tests/types/config/node" - "github.com/stretchr/testify/require" - "strings" ) // Tests a basic OCRv2 median feed func TestOCRv2Basic(t *testing.T) { + l := utils.GetTestLogger(t) + env, err := test_env.NewCLTestEnvBuilder(). WithGeth(). WithMockServer(1). @@ -33,9 +38,15 @@ func TestOCRv2Basic(t *testing.T) { node.WithP2Pv2(), )). WithCLNodes(6). - WithFunding(big.NewFloat(10)). + WithFunding(big.NewFloat(.1)). Build() require.NoError(t, err) + t.Cleanup(func() { + if err := env.Cleanup(); err != nil { + l.Error().Err(err).Msg("Error cleaning up test environment") + } + }) + env.ParallelTransactions(true) nodeClients := env.GetAPIs() diff --git a/integration-tests/smoke/ocr_test.go b/integration-tests/smoke/ocr_test.go index 1ae52ade305..50d6abe662b 100644 --- a/integration-tests/smoke/ocr_test.go +++ b/integration-tests/smoke/ocr_test.go @@ -1,24 +1,35 @@ package smoke import ( + "context" + "math/big" "testing" - "context" + "github.com/stretchr/testify/require" + + "github.com/smartcontractkit/chainlink-testing-framework/utils" + "github.com/smartcontractkit/chainlink/integration-tests/actions" "github.com/smartcontractkit/chainlink/integration-tests/docker/test_env" - "github.com/stretchr/testify/require" - "math/big" ) func TestOCRBasic(t *testing.T) { t.Parallel() + l := utils.GetTestLogger(t) + env, err := test_env.NewCLTestEnvBuilder(). WithGeth(). WithMockServer(1). WithCLNodes(6). - WithFunding(big.NewFloat(10)). + WithFunding(big.NewFloat(.1)). Build() require.NoError(t, err) + t.Cleanup(func() { + if err := env.Cleanup(); err != nil { + l.Error().Err(err).Msg("Error cleaning up test environment") + } + }) + env.ParallelTransactions(true) nodeClients := env.GetAPIs() @@ -27,9 +38,6 @@ func TestOCRBasic(t *testing.T) { linkTokenContract, err := env.ContractDeployer.DeployLinkTokenContract() require.NoError(t, err, "Deploying Link Token Contract shouldn't fail") - err = actions.FundChainlinkNodesLocal(workerNodes, env.EVMClient, big.NewFloat(.05)) - require.NoError(t, err, "Error funding Chainlink nodes") - ocrInstances, err := actions.DeployOCRContractsLocal(1, linkTokenContract, env.ContractDeployer, workerNodes, env.EVMClient) require.NoError(t, err) err = env.EVMClient.WaitForEvents() @@ -38,7 +46,7 @@ func TestOCRBasic(t *testing.T) { err = actions.CreateOCRJobsLocal(ocrInstances, bootstrapNode, workerNodes, 5, env.MockServer.Client) require.NoError(t, err) - _ = actions.StartNewRound(1, ocrInstances, env.EVMClient) + err = actions.StartNewRound(1, ocrInstances, env.EVMClient) require.NoError(t, err) answer, err := ocrInstances[0].GetLatestAnswer(context.Background()) diff --git a/integration-tests/smoke/runlog_test.go b/integration-tests/smoke/runlog_test.go index d40d5677fde..cd2a099b142 100644 --- a/integration-tests/smoke/runlog_test.go +++ b/integration-tests/smoke/runlog_test.go @@ -3,27 +3,36 @@ package smoke import ( "context" "fmt" + "math/big" + "strings" + "testing" + "github.com/google/uuid" "github.com/onsi/gomega" + "github.com/stretchr/testify/require" + "github.com/smartcontractkit/chainlink-testing-framework/utils" + "github.com/smartcontractkit/chainlink/integration-tests/client" "github.com/smartcontractkit/chainlink/integration-tests/docker/test_env" - "github.com/stretchr/testify/require" - "math/big" - "strings" - "testing" ) func TestRunLogBasic(t *testing.T) { t.Parallel() l := utils.GetTestLogger(t) + env, err := test_env.NewCLTestEnvBuilder(). WithGeth(). WithMockServer(1). WithCLNodes(1). - WithFunding(big.NewFloat(1)). + WithFunding(big.NewFloat(.1)). Build() require.NoError(t, err) + t.Cleanup(func() { + if err := env.Cleanup(); err != nil { + l.Error().Err(err).Msg("Error cleaning up test environment") + } + }) lt, err := env.ContractDeployer.DeployLinkTokenContract() require.NoError(t, err, "Deploying Link Token Contract shouldn't fail") diff --git a/integration-tests/smoke/vrf_test.go b/integration-tests/smoke/vrf_test.go index 2f3a8bb40f5..0e12b185a6a 100644 --- a/integration-tests/smoke/vrf_test.go +++ b/integration-tests/smoke/vrf_test.go @@ -3,29 +3,38 @@ package smoke import ( "context" "fmt" + "math/big" + "testing" + "time" + "github.com/google/uuid" "github.com/onsi/gomega" + "github.com/stretchr/testify/require" + "github.com/smartcontractkit/chainlink-testing-framework/utils" + "github.com/smartcontractkit/chainlink/integration-tests/actions" "github.com/smartcontractkit/chainlink/integration-tests/actions/vrfv1" "github.com/smartcontractkit/chainlink/integration-tests/client" "github.com/smartcontractkit/chainlink/integration-tests/docker/test_env" - "github.com/stretchr/testify/require" - "math/big" - "testing" - "time" ) func TestVRFBasic(t *testing.T) { t.Parallel() l := utils.GetTestLogger(t) + env, err := test_env.NewCLTestEnvBuilder(). WithGeth(). WithMockServer(1). WithCLNodes(1). - WithFunding(big.NewFloat(1)). + WithFunding(big.NewFloat(.1)). Build() require.NoError(t, err) + t.Cleanup(func() { + if err := env.Cleanup(); err != nil { + l.Error().Err(err).Msg("Error cleaning up test environment") + } + }) env.ParallelTransactions(true) lt, err := actions.DeployLINKToken(env.ContractDeployer) diff --git a/integration-tests/smoke/vrfv2_test.go b/integration-tests/smoke/vrfv2_test.go index ed9b9f16318..41f9d2ee5ee 100644 --- a/integration-tests/smoke/vrfv2_test.go +++ b/integration-tests/smoke/vrfv2_test.go @@ -7,9 +7,10 @@ import ( "time" "github.com/onsi/gomega" - "github.com/smartcontractkit/chainlink-testing-framework/utils" "github.com/stretchr/testify/require" + "github.com/smartcontractkit/chainlink-testing-framework/utils" + "github.com/smartcontractkit/chainlink/integration-tests/actions" "github.com/smartcontractkit/chainlink/integration-tests/actions/vrfv2_actions" vrfConst "github.com/smartcontractkit/chainlink/integration-tests/actions/vrfv2_actions/vrfv2_constants" @@ -27,6 +28,11 @@ func TestVRFv2Basic(t *testing.T) { WithFunding(vrfConst.ChainlinkNodeFundingAmountEth). Build() require.NoError(t, err) + t.Cleanup(func() { + if err := env.Cleanup(); err != nil { + l.Error().Err(err).Msg("Error cleaning up test environment") + } + }) env.ParallelTransactions(true) mockFeed, err := actions.DeployMockETHLinkFeed(env.ContractDeployer, vrfConst.LinkEthFeedResponse) diff --git a/integration-tests/smoke/vrfv2plus_test.go b/integration-tests/smoke/vrfv2plus_test.go index b3a99f8ca4e..9b6dc5a8626 100644 --- a/integration-tests/smoke/vrfv2plus_test.go +++ b/integration-tests/smoke/vrfv2plus_test.go @@ -2,16 +2,18 @@ package smoke import ( "context" - "github.com/smartcontractkit/chainlink/integration-tests/actions" - "github.com/smartcontractkit/chainlink/integration-tests/actions/vrfv2plus" - "github.com/smartcontractkit/chainlink/integration-tests/actions/vrfv2plus/vrfv2plus_constants" - "github.com/smartcontractkit/chainlink/integration-tests/docker/test_env" "math/big" "testing" "time" - "github.com/smartcontractkit/chainlink-testing-framework/utils" "github.com/stretchr/testify/require" + + "github.com/smartcontractkit/chainlink-testing-framework/utils" + + "github.com/smartcontractkit/chainlink/integration-tests/actions" + "github.com/smartcontractkit/chainlink/integration-tests/actions/vrfv2plus" + "github.com/smartcontractkit/chainlink/integration-tests/actions/vrfv2plus/vrfv2plus_constants" + "github.com/smartcontractkit/chainlink/integration-tests/docker/test_env" ) func TestVRFv2PlusBilling(t *testing.T) { @@ -23,8 +25,12 @@ func TestVRFv2PlusBilling(t *testing.T) { WithCLNodes(1). WithFunding(vrfv2plus_constants.ChainlinkNodeFundingAmountEth). Build() - require.NoError(t, err, "error creating test env") + t.Cleanup(func() { + if err := env.Cleanup(); err != nil { + l.Error().Err(err).Msg("Error cleaning up test environment") + } + }) env.ParallelTransactions(true) @@ -51,6 +57,7 @@ func TestVRFv2PlusBilling(t *testing.T) { subBalanceBeforeRequest := subscription.Balance jobRunsBeforeTest, err := env.CLNodes[0].API.MustReadRunsByJob(job.Job.Data.ID) + require.NoError(t, err, "error reading job runs") // test and assert err = vrfv2PlusContracts.LoadTestConsumer.RequestRandomness( diff --git a/integration-tests/types/config/node/core.go b/integration-tests/types/config/node/core.go index 4e60e1ece5c..0d433daa1b4 100644 --- a/integration-tests/types/config/node/core.go +++ b/integration-tests/types/config/node/core.go @@ -10,8 +10,6 @@ import ( "go.uber.org/zap/zapcore" "github.com/smartcontractkit/chainlink-testing-framework/blockchain" - - utils2 "github.com/smartcontractkit/chainlink/integration-tests/utils" "github.com/smartcontractkit/chainlink/v2/core/assets" evmcfg "github.com/smartcontractkit/chainlink/v2/core/chains/evm/config/toml" "github.com/smartcontractkit/chainlink/v2/core/config/toml" @@ -22,6 +20,7 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/utils/config" "github.com/smartcontractkit/chainlink/integration-tests/actions/vrfv2_actions/vrfv2_constants" + utils2 "github.com/smartcontractkit/chainlink/integration-tests/utils" ) var (