From 5d59226c963f32bd4c8cae902a28c679674f1ad1 Mon Sep 17 00:00:00 2001 From: Tate Date: Tue, 7 Nov 2023 13:02:02 -0700 Subject: [PATCH 01/12] Add build and lint to integration-tests --- .github/workflows/integration-tests.yml | 69 +++-- integration-tests/.golangci.yml | 85 +++++++ integration-tests/.tool-versions | 3 +- integration-tests/Makefile | 3 + .../actions/automation_ocr_helpers.go | 5 +- integration-tests/actions/ocr2_helpers.go | 7 +- .../actions/ocr2_helpers_local.go | 11 +- .../ocr2vrf_actions/ocr2vrf_config_helpers.go | 7 +- .../actions/ocr2vrf_actions/ocr2vrf_steps.go | 5 +- .../actions/ocr_helpers_local.go | 3 +- .../actions/vrfv2plus/vrfv2plus_steps.go | 5 +- .../chaos/automation_chaos_test.go | 7 +- integration-tests/chaos/ocr2vrf_chaos_test.go | 5 +- integration-tests/client/chainlink_k8s.go | 2 +- .../contracts/contract_deployer.go | 32 +-- .../contracts/contract_loader.go | 1 + .../contracts/contract_vrf_models.go | 13 +- .../contracts/ethereum_contracts.go | 9 +- .../contracts/ethereum_keeper_contracts.go | 89 +++---- integration-tests/contracts/test_contracts.go | 1 + integration-tests/docker/cmd/test_env.go | 7 +- integration-tests/docker/test_env/cl_node.go | 48 ++-- integration-tests/docker/test_env/test_env.go | 3 +- .../docker/test_env/test_env_builder.go | 4 +- integration-tests/load/functions/config.go | 4 +- .../load/functions/functions_test.go | 5 +- integration-tests/load/functions/gateway.go | 5 +- .../load/functions/gateway_gun.go | 9 +- .../load/functions/onchain_monitoring.go | 5 +- .../load/functions/request_gun.go | 19 +- integration-tests/load/functions/setup.go | 3 +- .../load/log_poller/log_poller_test.go | 3 +- integration-tests/load/vrfv2/cmd/dashboard.go | 3 +- integration-tests/load/vrfv2/config.go | 1 + integration-tests/load/vrfv2/gun.go | 3 +- .../load/vrfv2/onchain_monitoring.go | 8 +- integration-tests/load/vrfv2/vrfv2_test.go | 3 +- integration-tests/load/vrfv2/vu.go | 3 +- .../load/vrfv2plus/cmd/dashboard.go | 3 +- integration-tests/load/vrfv2plus/config.go | 4 + integration-tests/load/vrfv2plus/gun.go | 8 +- .../load/vrfv2plus/onchain_monitoring.go | 8 +- .../load/vrfv2plus/vrfv2plus_test.go | 16 +- .../migration/upgrade_version_test.go | 3 +- integration-tests/performance/keeper_test.go | 2 +- .../reorg/automation_reorg_test.go | 5 +- .../reorg/log_poller_maybe_reorg_test.go | 1 + integration-tests/reorg/reorg_test.go | 1 + integration-tests/smoke/automation_test.go | 9 +- integration-tests/smoke/log_poller_test.go | 1 + .../testreporters/keeper_benchmark.go | 2 +- integration-tests/testreporters/ocr.go | 4 +- integration-tests/testreporters/vrfv2plus.go | 5 +- .../testsetups/keeper_benchmark.go | 1 + integration-tests/testsetups/ocr.go | 3 +- integration-tests/testsetups/vrfv2.go | 2 +- integration-tests/types/envcommon/common.go | 4 +- .../universal/log_poller/config.go | 1 + integration-tests/universal/log_poller/gun.go | 7 +- .../universal/log_poller/helpers.go | 237 +++++++++--------- .../universal/log_poller/scenarios.go | 3 +- integration-tests/utils/cl_node_jobs.go | 3 +- integration-tests/utils/log.go | 19 -- integration-tests/utils/templates/secrets.go | 1 + 64 files changed, 508 insertions(+), 343 deletions(-) create mode 100644 integration-tests/.golangci.yml delete mode 100644 integration-tests/utils/log.go diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index 382e9cbbcf8..141396db4d8 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -74,9 +74,38 @@ jobs: hostname: ${{ secrets.GRAFANA_CLOUD_HOST }} this-job-name: Check Paths That Require Tests To Run continue-on-error: true - outputs: src: ${{ steps.changes.outputs.src }} + + build-lint-integration-tests: + name: Build and Lint integration-tests + runs-on: ubuntu20.04-16cores-64GB + steps: + - name: Checkout the repo + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + - name: Setup Go + uses: smartcontractkit/chainlink-github-actions/chainlink-testing-framework/setup-go@e865e376b8c2d594028c8d645dd6c47169b72974 # v2.2.16 + with: + test_download_vendor_packages_command: cd ./integration-tests && go mod download + go_mod_path: ./integration-tests/go.mod + cache_key_id: core-e2e-${{ env.MOD_CACHE_VERSION }} + cache_restore_only: "true" + - name: Build Go + run: | + cd ./integration-tests + go build ./... + - name: Lint Go + uses: golangci/golangci-lint-action@3a919529898de77ec3da873e3063ca4b10e7f5cc # v3.7.0 + with: + version: v1.55.0 + # We already cache these directories in setup-go + skip-pkg-cache: true + skip-build-cache: true + # only-new-issues is only applicable to PRs, otherwise it is always set to false + only-new-issues: false # disabled for PRs due to unreliability + args: --out-format colored-line-number,checkstyle:golangci-lint-report.xml + working-directory: ./integration-tests + build-chainlink: environment: integration permissions: @@ -382,16 +411,16 @@ jobs: run: | PORT_BASE=3001 MAX_PORT=8000 - + # Use PR number as offset. Given GitHub PRs are incremental, this guarantees uniqueness for at least 5000 PRs. OFFSET=$GITHUB_PR_NUMBER echo "PR Number: $OFFSET" - + # Ensure that we don't exceed the max port if (( OFFSET > (MAX_PORT - PORT_BASE) )); then OFFSET=$((OFFSET % (MAX_PORT - PORT_BASE))) fi - + # Map the offset to the port range REMOTE_PORT=$((PORT_BASE + OFFSET)) echo "REMOTE_PORT=$REMOTE_PORT" >> $GITHUB_OUTPUT @@ -402,25 +431,25 @@ jobs: TRACING_SSH_SERVER: ${{ secrets.TRACING_SSH_SERVER }} REMOTE_PORT: ${{ steps.generate-port.outputs.REMOTE_PORT }} run: | - eval $(ssh-agent) - echo "test" - echo "$TRACING_SSH_KEY" | wc -c - echo "$TRACING_SSH_KEY" | tr -d '\r' | wc -c - echo "$TRACING_SSH_KEY" | tr -d '\r' | base64 --decode | ssh-add - - # f: background process - # N: do not execute a remote command - # R: remote port forwarding - ssh -o StrictHostKeyChecking=no -f -N -R $REMOTE_PORT:127.0.0.1:3000 user-gha@$TRACING_SSH_SERVER - echo "To view Grafana locally:" - echo "ssh -N -L 8000:localhost:$REMOTE_PORT user-gha@$TRACING_SSH_SERVER" - echo "Then visit http://localhost:8000 in a browser." - echo "If you are unable to connect, check with the security team that you have access to the tracing server." + eval $(ssh-agent) + echo "test" + echo "$TRACING_SSH_KEY" | wc -c + echo "$TRACING_SSH_KEY" | tr -d '\r' | wc -c + echo "$TRACING_SSH_KEY" | tr -d '\r' | base64 --decode | ssh-add - + # f: background process + # N: do not execute a remote command + # R: remote port forwarding + ssh -o StrictHostKeyChecking=no -f -N -R $REMOTE_PORT:127.0.0.1:3000 user-gha@$TRACING_SSH_SERVER + echo "To view Grafana locally:" + echo "ssh -N -L 8000:localhost:$REMOTE_PORT user-gha@$TRACING_SSH_SERVER" + echo "Then visit http://localhost:8000 in a browser." + echo "If you are unable to connect, check with the security team that you have access to the tracing server." - name: Show Grafana Logs if: steps.check-label.outputs.trace == 'true' && matrix.product.name == 'ocr2' && matrix.product.tag_suffix == '-plugins' run: | - docker logs grafana - docker logs tempo - docker logs otel-collector + docker logs grafana + docker logs tempo + docker logs otel-collector - name: Set sleep time to use in future steps if: steps.check-label.outputs.trace == 'true' && matrix.product.name == 'ocr2' && matrix.product.tag_suffix == '-plugins' run: | diff --git a/integration-tests/.golangci.yml b/integration-tests/.golangci.yml new file mode 100644 index 00000000000..9ee5942e300 --- /dev/null +++ b/integration-tests/.golangci.yml @@ -0,0 +1,85 @@ +run: + timeout: 15m0s +linters: + enable: + - exhaustive + - exportloopref + - revive + - goimports + - gosec + - misspell + - rowserrcheck + - errorlint +linters-settings: + exhaustive: + default-signifies-exhaustive: true + goimports: + local-prefixes: github.com/smartcontractkit/chainlink + golint: + min-confidence: 1.0 + gosec: + excludes: + - G101 + - G104 + # - G204 + # - G304 + # - G404 + govet: + # report about shadowed variables + check-shadowing: true + errorlint: + # Allow formatting of errors without %w + errorf: false + revive: + confidence: 0.8 + rules: + - name: blank-imports + - name: context-as-argument + - name: context-keys-type + - name: dot-imports + - name: error-return + - name: error-strings + - name: error-naming + - name: if-return + - name: increment-decrement + # - name: var-naming + - name: var-declaration + - name: package-comments + - name: range + - name: receiver-naming + - name: time-naming + # - name: unexported-return + - name: indent-error-flow + - name: errorf + - name: empty-block + - name: superfluous-else + # - name: unused-parameter + - name: unreachable-code + - name: redefines-builtin-id + - name: waitgroup-by-value + - name: unconditional-recursion + - name: struct-tag + # - name: string-format + - name: string-of-int + # - name: range-val-address + - name: range-val-in-closure + - name: modifies-value-receiver + - name: modifies-parameter + - name: identical-branches + - name: get-return + # - name: flag-parameter + # - name: early-return + - name: defer + - name: constant-logical-expr + # - name: confusing-naming + # - name: confusing-results + - name: bool-literal-in-expr + - name: atomic +issues: + exclude-rules: + - text: "^G404: Use of weak random number generator" + linters: + - gosec + - linters: + - govet + text: "declaration of \"err\" shadows" diff --git a/integration-tests/.tool-versions b/integration-tests/.tool-versions index 68b6d994197..ed888c14d28 100644 --- a/integration-tests/.tool-versions +++ b/integration-tests/.tool-versions @@ -1,4 +1,5 @@ -golang 1.21.1 +golang 1.21.3 k3d 5.4.6 kubectl 1.25.5 nodejs 18.13.0 +golangci-lint 1.55.0 diff --git a/integration-tests/Makefile b/integration-tests/Makefile index 257331afcfd..a9257686104 100644 --- a/integration-tests/Makefile +++ b/integration-tests/Makefile @@ -56,6 +56,9 @@ install_gotestfmt: go install github.com/gotesttools/gotestfmt/v2/cmd/gotestfmt@latest set -euo pipefail +lint: + golangci-lint --color=always run ./... --fix -v + # Builds the test image # tag: the tag for the test image being built, example: tag=tate # base_tag: the tag for the base-test-image to use, example: base_tag=latest diff --git a/integration-tests/actions/automation_ocr_helpers.go b/integration-tests/actions/automation_ocr_helpers.go index 998b1ee89cf..e1635902db5 100644 --- a/integration-tests/actions/automation_ocr_helpers.go +++ b/integration-tests/actions/automation_ocr_helpers.go @@ -14,14 +14,15 @@ import ( "github.com/stretchr/testify/require" "gopkg.in/guregu/null.v4" - "github.com/smartcontractkit/chainlink-testing-framework/blockchain" - "github.com/smartcontractkit/chainlink-testing-framework/logging" 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/smartcontractkit/chainlink-testing-framework/blockchain" + "github.com/smartcontractkit/chainlink-testing-framework/logging" + "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" diff --git a/integration-tests/actions/ocr2_helpers.go b/integration-tests/actions/ocr2_helpers.go index aead74f2bdd..02ce73e813e 100644 --- a/integration-tests/actions/ocr2_helpers.go +++ b/integration-tests/actions/ocr2_helpers.go @@ -15,14 +15,15 @@ import ( "golang.org/x/sync/errgroup" "gopkg.in/guregu/null.v4" + "github.com/smartcontractkit/libocr/offchainreporting2/reportingplugin/median" + "github.com/smartcontractkit/libocr/offchainreporting2plus/confighelper" + "github.com/smartcontractkit/libocr/offchainreporting2plus/types" + "github.com/smartcontractkit/chainlink-testing-framework/blockchain" ctfClient "github.com/smartcontractkit/chainlink-testing-framework/client" "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" - "github.com/smartcontractkit/libocr/offchainreporting2/reportingplugin/median" - "github.com/smartcontractkit/libocr/offchainreporting2plus/confighelper" - "github.com/smartcontractkit/libocr/offchainreporting2plus/types" "github.com/smartcontractkit/chainlink/integration-tests/client" "github.com/smartcontractkit/chainlink/integration-tests/contracts" diff --git a/integration-tests/actions/ocr2_helpers_local.go b/integration-tests/actions/ocr2_helpers_local.go index b3fe6eb041f..65e0a466bee 100644 --- a/integration-tests/actions/ocr2_helpers_local.go +++ b/integration-tests/actions/ocr2_helpers_local.go @@ -12,6 +12,12 @@ import ( "github.com/google/uuid" "github.com/lib/pq" "github.com/rs/zerolog/log" + "github.com/smartcontractkit/libocr/offchainreporting2/reportingplugin/median" + "github.com/smartcontractkit/libocr/offchainreporting2plus/confighelper" + "github.com/smartcontractkit/libocr/offchainreporting2plus/types" + "golang.org/x/sync/errgroup" + "gopkg.in/guregu/null.v4" + "github.com/smartcontractkit/chainlink-testing-framework/docker/test_env" "github.com/smartcontractkit/chainlink/integration-tests/client" "github.com/smartcontractkit/chainlink/integration-tests/contracts" @@ -19,11 +25,6 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/services/keystore/chaintype" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/testhelpers" "github.com/smartcontractkit/chainlink/v2/core/store/models" - "github.com/smartcontractkit/libocr/offchainreporting2/reportingplugin/median" - "github.com/smartcontractkit/libocr/offchainreporting2plus/confighelper" - "github.com/smartcontractkit/libocr/offchainreporting2plus/types" - "golang.org/x/sync/errgroup" - "gopkg.in/guregu/null.v4" ) func CreateOCRv2JobsLocal( diff --git a/integration-tests/actions/ocr2vrf_actions/ocr2vrf_config_helpers.go b/integration-tests/actions/ocr2vrf_actions/ocr2vrf_config_helpers.go index ce693964323..e424aaa11b3 100644 --- a/integration-tests/actions/ocr2vrf_actions/ocr2vrf_config_helpers.go +++ b/integration-tests/actions/ocr2vrf_actions/ocr2vrf_config_helpers.go @@ -16,9 +16,6 @@ import ( "go.dedis.ch/kyber/v3/group/edwards25519" "gopkg.in/guregu/null.v4" - "github.com/smartcontractkit/chainlink-testing-framework/logging" - "github.com/smartcontractkit/chainlink/v2/core/services/job" - "github.com/smartcontractkit/chainlink/v2/core/services/keystore/chaintype" "github.com/smartcontractkit/libocr/offchainreporting2plus/confighelper" "github.com/smartcontractkit/libocr/offchainreporting2plus/types" "github.com/smartcontractkit/ocr2vrf/altbn_128" @@ -26,6 +23,10 @@ import ( "github.com/smartcontractkit/ocr2vrf/ocr2vrf" ocr2vrftypes "github.com/smartcontractkit/ocr2vrf/types" + "github.com/smartcontractkit/chainlink-testing-framework/logging" + "github.com/smartcontractkit/chainlink/v2/core/services/job" + "github.com/smartcontractkit/chainlink/v2/core/services/keystore/chaintype" + "github.com/smartcontractkit/chainlink/integration-tests/client" "github.com/smartcontractkit/chainlink/integration-tests/contracts" ) diff --git a/integration-tests/actions/ocr2vrf_actions/ocr2vrf_steps.go b/integration-tests/actions/ocr2vrf_actions/ocr2vrf_steps.go index c123aaff6a2..3aa00123451 100644 --- a/integration-tests/actions/ocr2vrf_actions/ocr2vrf_steps.go +++ b/integration-tests/actions/ocr2vrf_actions/ocr2vrf_steps.go @@ -1,6 +1,7 @@ package ocr2vrf_actions import ( + "context" "math/big" "strings" "testing" @@ -272,14 +273,14 @@ func RequestRandomnessFulfillmentAndWaitForFulfilment( } func getRequestId(t *testing.T, consumer contracts.VRFBeaconConsumer, receipt *types.Receipt, confirmationDelay *big.Int) *big.Int { - periodBlocks, err := consumer.IBeaconPeriodBlocks(nil) + periodBlocks, err := consumer.IBeaconPeriodBlocks(context.Background()) require.NoError(t, err, "Error getting Beacon Period block count") blockNumber := receipt.BlockNumber periodOffset := new(big.Int).Mod(blockNumber, periodBlocks) nextBeaconOutputHeight := new(big.Int).Sub(new(big.Int).Add(blockNumber, periodBlocks), periodOffset) - requestID, err := consumer.GetRequestIdsBy(nil, nextBeaconOutputHeight, confirmationDelay) + requestID, err := consumer.GetRequestIdsBy(context.Background(), nextBeaconOutputHeight, confirmationDelay) require.NoError(t, err, "Error getting requestID from consumer contract") return requestID diff --git a/integration-tests/actions/ocr_helpers_local.go b/integration-tests/actions/ocr_helpers_local.go index 5836ee7945c..e6dd5ae77f6 100644 --- a/integration-tests/actions/ocr_helpers_local.go +++ b/integration-tests/actions/ocr_helpers_local.go @@ -10,9 +10,10 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/google/uuid" "github.com/rs/zerolog" + "golang.org/x/sync/errgroup" + "github.com/smartcontractkit/chainlink-testing-framework/blockchain" "github.com/smartcontractkit/chainlink-testing-framework/docker/test_env" - "golang.org/x/sync/errgroup" "github.com/smartcontractkit/chainlink/integration-tests/client" "github.com/smartcontractkit/chainlink/integration-tests/contracts" diff --git a/integration-tests/actions/vrfv2plus/vrfv2plus_steps.go b/integration-tests/actions/vrfv2plus/vrfv2plus_steps.go index e964623fb2e..28fb2635ff3 100644 --- a/integration-tests/actions/vrfv2plus/vrfv2plus_steps.go +++ b/integration-tests/actions/vrfv2plus/vrfv2plus_steps.go @@ -15,6 +15,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/google/uuid" "github.com/rs/zerolog" + "github.com/smartcontractkit/chainlink-testing-framework/blockchain" "github.com/smartcontractkit/chainlink/integration-tests/actions" "github.com/smartcontractkit/chainlink/integration-tests/actions/vrfv2plus/vrfv2plus_config" @@ -802,7 +803,7 @@ func WaitForRequestCountEqualToFulfilmentCount(consumer contracts.VRFv2PlusLoadT fmt.Errorf("timeout waiting for rand request and fulfilments to be equal AFTER performance test was executed. Request Count: %d, Fulfilment Count: %d", metrics.RequestCount.Uint64(), metrics.FulfilmentCount.Uint64()) case <-ticker.C: - go getLoadTestMetrics(consumer, metricsChannel, metricsErrorChannel) + go retreiveLoadTestMetrics(consumer, metricsChannel, metricsErrorChannel) case metrics = <-metricsChannel: if metrics.RequestCount.Cmp(metrics.FulfilmentCount) == 0 { ticker.Stop() @@ -852,7 +853,7 @@ func ReturnFundsForFulfilledRequests(client blockchain.EVMClient, coordinator co return nil } -func getLoadTestMetrics( +func retreiveLoadTestMetrics( consumer contracts.VRFv2PlusLoadTestConsumer, metricsChannel chan *contracts.VRFLoadTestMetrics, metricsErrorChannel chan error, diff --git a/integration-tests/chaos/automation_chaos_test.go b/integration-tests/chaos/automation_chaos_test.go index 22c9e742f38..ced28a38513 100644 --- a/integration-tests/chaos/automation_chaos_test.go +++ b/integration-tests/chaos/automation_chaos_test.go @@ -116,6 +116,7 @@ func TestAutomationChaos(t *testing.T) { } for name, registryVersion := range registryVersions { + registryVersion := registryVersion t.Run(name, func(t *testing.T) { t.Parallel() @@ -176,9 +177,9 @@ func TestAutomationChaos(t *testing.T) { }, } - for n, tst := range testCases { - name := n - testCase := tst + for name, testCase := range testCases { + name := name + testCase := testCase t.Run(fmt.Sprintf("Automation_%s", name), func(t *testing.T) { t.Parallel() network := networks.MustGetSelectedNetworksFromEnv()[0] // Need a new copy of the network for each test diff --git a/integration-tests/chaos/ocr2vrf_chaos_test.go b/integration-tests/chaos/ocr2vrf_chaos_test.go index ba75974f01a..3b0eb8ebc21 100644 --- a/integration-tests/chaos/ocr2vrf_chaos_test.go +++ b/integration-tests/chaos/ocr2vrf_chaos_test.go @@ -1,6 +1,7 @@ package chaos import ( + "context" "fmt" "math/big" "strings" @@ -185,7 +186,7 @@ func TestOCR2VRFChaos(t *testing.T) { ) for i := uint16(0); i < ocr2vrf_constants.NumberOfRandomWordsToRequest; i++ { - randomness, err := consumerContract.GetRandomnessByRequestId(nil, requestID, big.NewInt(int64(i))) + randomness, err := consumerContract.GetRandomnessByRequestId(context.Background(), requestID, big.NewInt(int64(i))) require.NoError(t, err) l.Info().Interface("Random Number", randomness).Interface("Randomness Number Index", i).Msg("Randomness retrieved from Consumer contract") require.NotEqual(t, 0, randomness.Uint64(), "Randomness retrieved from Consumer contract give an answer other than 0") @@ -212,7 +213,7 @@ func TestOCR2VRFChaos(t *testing.T) { ) for i := uint16(0); i < ocr2vrf_constants.NumberOfRandomWordsToRequest; i++ { - randomness, err := consumerContract.GetRandomnessByRequestId(nil, requestID, big.NewInt(int64(i))) + randomness, err := consumerContract.GetRandomnessByRequestId(context.Background(), requestID, big.NewInt(int64(i))) require.NoError(t, err, "Error getting Randomness result from Consumer Contract") l.Info().Interface("Random Number", randomness).Interface("Randomness Number Index", i).Msg("Randomness retrieved from Consumer contract") require.NotEqual(t, 0, randomness.Uint64(), "Randomness retrieved from Consumer contract give an answer other than 0") diff --git a/integration-tests/client/chainlink_k8s.go b/integration-tests/client/chainlink_k8s.go index 3fbf9eaf73c..27fd956103e 100644 --- a/integration-tests/client/chainlink_k8s.go +++ b/integration-tests/client/chainlink_k8s.go @@ -63,7 +63,7 @@ func (c *ChainlinkK8sClient) UpgradeVersion(testEnvironment *environment.Environ }, }, } - testEnvironment, err := testEnvironment.UpdateHelm(c.ChartName, upgradeVals) + _, err := testEnvironment.UpdateHelm(c.ChartName, upgradeVals) return err } diff --git a/integration-tests/contracts/contract_deployer.go b/integration-tests/contracts/contract_deployer.go index 916971f82d3..45195d327ee 100644 --- a/integration-tests/contracts/contract_deployer.go +++ b/integration-tests/contracts/contract_deployer.go @@ -12,11 +12,12 @@ import ( "github.com/rs/zerolog" "github.com/rs/zerolog/log" - "github.com/smartcontractkit/chainlink-testing-framework/blockchain" "github.com/smartcontractkit/libocr/gethwrappers/offchainaggregator" "github.com/smartcontractkit/libocr/gethwrappers2/ocr2aggregator" ocrConfigHelper "github.com/smartcontractkit/libocr/offchainreporting/confighelper" + "github.com/smartcontractkit/chainlink-testing-framework/blockchain" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/functions/generated/functions_load_test_client" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/functions/generated/functions_v1_events_mock" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/automation_consumer_benchmark" @@ -868,22 +869,21 @@ func (e *EthereumContractDeployer) LoadKeeperRegistrar(address common.Address, r client: e.client, registrar20: instance.(*keeper_registrar_wrapper2_0.KeeperRegistrar), }, err - } else { - instance, err := e.client.LoadContract("AutomationRegistrar", address, func( - address common.Address, - backend bind.ContractBackend, - ) (interface{}, error) { - return registrar21.NewAutomationRegistrar(address, backend) - }) - if err != nil { - return nil, err - } - return &EthereumKeeperRegistrar{ - address: &address, - client: e.client, - registrar21: instance.(*registrar21.AutomationRegistrar), - }, err } + instance, err := e.client.LoadContract("AutomationRegistrar", address, func( + address common.Address, + backend bind.ContractBackend, + ) (interface{}, error) { + return registrar21.NewAutomationRegistrar(address, backend) + }) + if err != nil { + return nil, err + } + return &EthereumKeeperRegistrar{ + address: &address, + client: e.client, + registrar21: instance.(*registrar21.AutomationRegistrar), + }, err } func (e *EthereumContractDeployer) DeployKeeperRegistry( diff --git a/integration-tests/contracts/contract_loader.go b/integration-tests/contracts/contract_loader.go index cfe7a35467e..9a2f20226d3 100644 --- a/integration-tests/contracts/contract_loader.go +++ b/integration-tests/contracts/contract_loader.go @@ -2,6 +2,7 @@ package contracts import ( "errors" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/vrf_coordinator_v2_5" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/vrf_v2plus_load_test_with_metrics" diff --git a/integration-tests/contracts/contract_vrf_models.go b/integration-tests/contracts/contract_vrf_models.go index c82924143b0..e2a3e6630b5 100644 --- a/integration-tests/contracts/contract_vrf_models.go +++ b/integration-tests/contracts/contract_vrf_models.go @@ -262,12 +262,13 @@ type RequestStatus struct { } type LoadTestRequestStatus struct { - Fulfilled bool - RandomWords []*big.Int - requestTimestamp *big.Int - fulfilmentTimestamp *big.Int - requestBlockNumber *big.Int - fulfilmentBlockNumber *big.Int + Fulfilled bool + RandomWords []*big.Int + // Unused??? + // requestTimestamp *big.Int + // fulfilmentTimestamp *big.Int + // requestBlockNumber *big.Int + // fulfilmentBlockNumber *big.Int } type VRFLoadTestMetrics struct { diff --git a/integration-tests/contracts/ethereum_contracts.go b/integration-tests/contracts/ethereum_contracts.go index cde6e325f2a..147442f73b4 100644 --- a/integration-tests/contracts/ethereum_contracts.go +++ b/integration-tests/contracts/ethereum_contracts.go @@ -16,6 +16,11 @@ import ( "github.com/rs/zerolog" "github.com/rs/zerolog/log" + "github.com/smartcontractkit/libocr/gethwrappers/offchainaggregator" + "github.com/smartcontractkit/libocr/gethwrappers2/ocr2aggregator" + ocrConfigHelper "github.com/smartcontractkit/libocr/offchainreporting/confighelper" + ocrTypes "github.com/smartcontractkit/libocr/offchainreporting/types" + "github.com/smartcontractkit/chainlink-testing-framework/blockchain" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/functions/generated/functions_coordinator" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/functions/generated/functions_load_test_client" @@ -43,10 +48,6 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/llo-feeds/generated/verifier" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/llo-feeds/generated/verifier_proxy" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/shared/generated/werc20_mock" - "github.com/smartcontractkit/libocr/gethwrappers/offchainaggregator" - "github.com/smartcontractkit/libocr/gethwrappers2/ocr2aggregator" - ocrConfigHelper "github.com/smartcontractkit/libocr/offchainreporting/confighelper" - ocrTypes "github.com/smartcontractkit/libocr/offchainreporting/types" "github.com/smartcontractkit/chainlink/integration-tests/client" eth_contracts "github.com/smartcontractkit/chainlink/integration-tests/contracts/ethereum" diff --git a/integration-tests/contracts/ethereum_keeper_contracts.go b/integration-tests/contracts/ethereum_keeper_contracts.go index 135b016ee55..2a26024b9cc 100644 --- a/integration-tests/contracts/ethereum_keeper_contracts.go +++ b/integration-tests/contracts/ethereum_keeper_contracts.go @@ -250,25 +250,25 @@ func (rcs *KeeperRegistrySettings) EncodeOnChainConfig(registrar string, registr encodedOnchainConfig, err := utilsABI.Methods["_onChainConfig"].Inputs.Pack(&onchainConfigStruct) return encodedOnchainConfig, err - } else { - configType := goabi.MustNewType("tuple(uint32 paymentPremiumPPB,uint32 flatFeeMicroLink,uint32 checkGasLimit,uint24 stalenessSeconds,uint16 gasCeilingMultiplier,uint96 minUpkeepSpend,uint32 maxPerformGas,uint32 maxCheckDataSize,uint32 maxPerformDataSize,uint256 fallbackGasPrice,uint256 fallbackLinkPrice,address transcoder,address registrar)") - onchainConfig, err := goabi.Encode(map[string]interface{}{ - "paymentPremiumPPB": rcs.PaymentPremiumPPB, - "flatFeeMicroLink": rcs.FlatFeeMicroLINK, - "checkGasLimit": rcs.CheckGasLimit, - "stalenessSeconds": rcs.StalenessSeconds, - "gasCeilingMultiplier": rcs.GasCeilingMultiplier, - "minUpkeepSpend": rcs.MinUpkeepSpend, - "maxPerformGas": rcs.MaxPerformGas, - "maxCheckDataSize": rcs.MaxCheckDataSize, - "maxPerformDataSize": rcs.MaxPerformDataSize, - "fallbackGasPrice": rcs.FallbackGasPrice, - "fallbackLinkPrice": rcs.FallbackLinkPrice, - "transcoder": common.Address{}, - "registrar": registrar, - }, configType) - return onchainConfig, err } + configType := goabi.MustNewType("tuple(uint32 paymentPremiumPPB,uint32 flatFeeMicroLink,uint32 checkGasLimit,uint24 stalenessSeconds,uint16 gasCeilingMultiplier,uint96 minUpkeepSpend,uint32 maxPerformGas,uint32 maxCheckDataSize,uint32 maxPerformDataSize,uint256 fallbackGasPrice,uint256 fallbackLinkPrice,address transcoder,address registrar)") + onchainConfig, err := goabi.Encode(map[string]interface{}{ + "paymentPremiumPPB": rcs.PaymentPremiumPPB, + "flatFeeMicroLink": rcs.FlatFeeMicroLINK, + "checkGasLimit": rcs.CheckGasLimit, + "stalenessSeconds": rcs.StalenessSeconds, + "gasCeilingMultiplier": rcs.GasCeilingMultiplier, + "minUpkeepSpend": rcs.MinUpkeepSpend, + "maxPerformGas": rcs.MaxPerformGas, + "maxCheckDataSize": rcs.MaxCheckDataSize, + "maxPerformDataSize": rcs.MaxPerformDataSize, + "fallbackGasPrice": rcs.FallbackGasPrice, + "fallbackLinkPrice": rcs.FallbackLinkPrice, + "transcoder": common.Address{}, + "registrar": registrar, + }, configType) + return onchainConfig, err + } func (v *EthereumKeeperRegistry) RegistryOwnerAddress() common.Address { @@ -276,6 +276,7 @@ func (v *EthereumKeeperRegistry) RegistryOwnerAddress() common.Address { Pending: false, } + //nolint: exhaustive switch v.version { case ethereum.RegistryVersion_2_1: ownerAddress, _ := v.registry2_1.Owner(callOpts) @@ -283,6 +284,8 @@ func (v *EthereumKeeperRegistry) RegistryOwnerAddress() common.Address { case ethereum.RegistryVersion_2_0: ownerAddress, _ := v.registry2_0.Owner(callOpts) return ownerAddress + case ethereum.RegistryVersion_1_0, ethereum.RegistryVersion_1_1, ethereum.RegistryVersion_1_2, ethereum.RegistryVersion_1_3: + return common.HexToAddress(v.client.GetDefaultWallet().Address()) } return common.HexToAddress(v.client.GetDefaultWallet().Address()) @@ -664,7 +667,7 @@ func (v *EthereumKeeperRegistry) GetKeeperInfo(ctx context.Context, keeperAddr s info, err = v.registry1_2.GetKeeperInfo(opts, common.HexToAddress(keeperAddr)) case ethereum.RegistryVersion_1_3: info, err = v.registry1_3.GetKeeperInfo(opts, common.HexToAddress(keeperAddr)) - case ethereum.RegistryVersion_2_0: + case ethereum.RegistryVersion_2_0, ethereum.RegistryVersion_2_1: // this is not used anywhere return nil, fmt.Errorf("not supported") } @@ -710,6 +713,8 @@ func (v *EthereumKeeperRegistry) SetKeepers(keepers []string, payees []string, o ocrConfig.OffchainConfigVersion, ocrConfig.OffchainConfig, ) + case ethereum.RegistryVersion_2_1: + return fmt.Errorf("not supported") } if err != nil { @@ -760,6 +765,8 @@ func (v *EthereumKeeperRegistry) RegisterUpkeep(target string, gasLimit uint32, checkData, nil, //offchain config ) + case ethereum.RegistryVersion_2_1: + return fmt.Errorf("not supported") } if err != nil { @@ -877,6 +884,8 @@ func (v *EthereumKeeperRegistry) GetKeeperList(ctx context.Context) ([]string, e return []string{}, err } list = state.Transmitters + case ethereum.RegistryVersion_2_1: + return nil, fmt.Errorf("not supported") } if err != nil { @@ -1112,6 +1121,7 @@ func (v *EthereumKeeperRegistry) ParseUpkeepPerformedLog(log *types.Log) (*Upkee // ParseStaleUpkeepReportLog Parses Stale upkeep report log func (v *EthereumKeeperRegistry) ParseStaleUpkeepReportLog(log *types.Log) (*StaleUpkeepReportLog, error) { + //nolint:exhaustive switch v.version { case ethereum.RegistryVersion_2_0: parsedLog, err := v.registry2_0.ParseStaleUpkeepReport(*log) @@ -1129,7 +1139,6 @@ func (v *EthereumKeeperRegistry) ParseStaleUpkeepReportLog(log *types.Log) (*Sta return &StaleUpkeepReportLog{ Id: parsedLog.Id, }, nil - } return nil, fmt.Errorf("keeper registry version %d is not supported", v.version) } @@ -2041,31 +2050,23 @@ func (v *EthereumKeeperRegistrar) EncodeRegisterRequest(name string, email []byt common.HexToAddress(senderAddr), ) - if err != nil { - return nil, err - } - return req, nil - } else { - req, err := registrarABI.Pack( - "register", - name, - email, - common.HexToAddress(upkeepAddr), - gasLimit, - common.HexToAddress(adminAddr), - uint8(0), // trigger type - checkData, - []byte{}, // triggerConfig - []byte{}, // offchainConfig - amount, - common.HexToAddress(senderAddr), - ) - - if err != nil { - return nil, err - } - return req, nil + return req, err } + req, err := registrarABI.Pack( + "register", + name, + email, + common.HexToAddress(upkeepAddr), + gasLimit, + common.HexToAddress(adminAddr), + uint8(0), // trigger type + checkData, + []byte{}, // triggerConfig + []byte{}, // offchainConfig + amount, + common.HexToAddress(senderAddr), + ) + return req, err } registryABI, err := abi.JSON(strings.NewReader(keeper_registrar_wrapper1_2.KeeperRegistrarMetaData.ABI)) if err != nil { diff --git a/integration-tests/contracts/test_contracts.go b/integration-tests/contracts/test_contracts.go index ccdd2989e49..3080668da69 100644 --- a/integration-tests/contracts/test_contracts.go +++ b/integration-tests/contracts/test_contracts.go @@ -6,6 +6,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/rs/zerolog" + "github.com/smartcontractkit/chainlink-testing-framework/blockchain" le "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/log_emitter" diff --git a/integration-tests/docker/cmd/test_env.go b/integration-tests/docker/cmd/test_env.go index f760f45f8d0..5fe2001350e 100644 --- a/integration-tests/docker/cmd/test_env.go +++ b/integration-tests/docker/cmd/test_env.go @@ -9,10 +9,11 @@ import ( "github.com/rs/zerolog" "github.com/rs/zerolog/log" - "github.com/smartcontractkit/chainlink/integration-tests/docker/test_env" - "github.com/smartcontractkit/chainlink/integration-tests/utils" "github.com/spf13/cobra" "github.com/testcontainers/testcontainers-go" + + "github.com/smartcontractkit/chainlink-testing-framework/logging" + "github.com/smartcontractkit/chainlink/integration-tests/docker/test_env" ) func main() { @@ -31,7 +32,7 @@ func main() { Use: "cl-cluster", Short: "Basic CL cluster", RunE: func(cmd *cobra.Command, args []string) error { - utils.SetupCoreDockerEnvLogger() + log.Logger = logging.GetLogger(nil, "CORE_DOCKER_ENV_LOG_LEVEL") log.Info().Msg("Starting CL cluster test environment..") _, err := test_env.NewCLTestEnvBuilder(). diff --git a/integration-tests/docker/test_env/cl_node.go b/integration-tests/docker/test_env/cl_node.go index 4de3d27d754..8ce238369a3 100644 --- a/integration-tests/docker/test_env/cl_node.go +++ b/integration-tests/docker/test_env/cl_node.go @@ -22,6 +22,9 @@ import ( tc "github.com/testcontainers/testcontainers-go" tcwait "github.com/testcontainers/testcontainers-go/wait" + ocrtypes "github.com/smartcontractkit/libocr/offchainreporting2/types" + "github.com/smartcontractkit/libocr/offchainreporting2plus/confighelper" + "github.com/smartcontractkit/chainlink-testing-framework/blockchain" "github.com/smartcontractkit/chainlink-testing-framework/docker" "github.com/smartcontractkit/chainlink-testing-framework/docker/test_env" @@ -29,8 +32,6 @@ import ( "github.com/smartcontractkit/chainlink-testing-framework/logwatch" "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" @@ -411,19 +412,21 @@ func (n *ClNode) getContainerRequest(secrets string) ( }, nil } -func GetOracleIdentities(chainlinkNodes []*ClNode) ([]int, []confighelper.OracleIdentityExtra) { +func GetOracleIdentities(chainlinkNodes []*ClNode) ([]int, []confighelper.OracleIdentityExtra, error) { S := make([]int, len(chainlinkNodes)) oracleIdentities := make([]confighelper.OracleIdentityExtra, len(chainlinkNodes)) sharedSecretEncryptionPublicKeys := make([]ocrtypes.ConfigEncryptionPublicKey, len(chainlinkNodes)) var wg sync.WaitGroup + errCh := make(chan error, len(chainlinkNodes)) // Buffered error channel to avoid blocking for i, cl := range chainlinkNodes { wg.Add(1) - go func(i int, cl *ClNode) error { + go func(i int, cl *ClNode) { defer wg.Done() ocr2Keys, err := cl.API.MustReadOCR2Keys() if err != nil { - return err + errCh <- err + return } var ocr2Config client.OCR2KeyAttributes for _, key := range ocr2Keys.Data { @@ -435,40 +438,47 @@ func GetOracleIdentities(chainlinkNodes []*ClNode) ([]int, []confighelper.Oracle keys, err := cl.API.MustReadP2PKeys() if err != nil { - return err + errCh <- err + return } p2pKeyID := keys.Data[0].Attributes.PeerID offchainPkBytes, err := hex.DecodeString(strings.TrimPrefix(ocr2Config.OffChainPublicKey, "ocr2off_evm_")) if err != nil { - return err + errCh <- err + return } offchainPkBytesFixed := [ed25519.PublicKeySize]byte{} copy(offchainPkBytesFixed[:], offchainPkBytes) if err != nil { - return err + errCh <- err + return } configPkBytes, err := hex.DecodeString(strings.TrimPrefix(ocr2Config.ConfigPublicKey, "ocr2cfg_evm_")) if err != nil { - return err + errCh <- err + return } configPkBytesFixed := [ed25519.PublicKeySize]byte{} copy(configPkBytesFixed[:], configPkBytes) if err != nil { - return err + errCh <- err + return } onchainPkBytes, err := hex.DecodeString(strings.TrimPrefix(ocr2Config.OnChainPublicKey, "ocr2on_evm_")) if err != nil { - return err + errCh <- err + return } csaKeys, _, err := cl.API.ReadCSAKeys() if err != nil { - return err + errCh <- err + return } sharedSecretEncryptionPublicKeys[i] = configPkBytesFixed @@ -482,11 +492,17 @@ func GetOracleIdentities(chainlinkNodes []*ClNode) ([]int, []confighelper.Oracle ConfigEncryptionPublicKey: configPkBytesFixed, } S[i] = 1 - - return nil }(i, cl) } wg.Wait() - - return S, oracleIdentities + close(errCh) // Close the error channel + // Check for errors sent to the error channel + var firstErr error + for err := range errCh { + if err != nil { + firstErr = err + break + } + } + return S, oracleIdentities, firstErr } diff --git a/integration-tests/docker/test_env/test_env.go b/integration-tests/docker/test_env/test_env.go index a6495bed540..fd5f96e287e 100644 --- a/integration-tests/docker/test_env/test_env.go +++ b/integration-tests/docker/test_env/test_env.go @@ -27,7 +27,6 @@ import ( "github.com/smartcontractkit/chainlink/integration-tests/client" "github.com/smartcontractkit/chainlink/integration-tests/contracts" - "github.com/smartcontractkit/chainlink/integration-tests/utils" ) var ( @@ -52,7 +51,7 @@ type CLClusterTestEnv struct { } func NewTestEnv() (*CLClusterTestEnv, error) { - utils.SetupCoreDockerEnvLogger() + log.Logger = logging.GetLogger(nil, "CORE_DOCKER_ENV_LOG_LEVEL") network, err := docker.CreateNetwork(log.Logger) if err != nil { return nil, err diff --git a/integration-tests/docker/test_env/test_env_builder.go b/integration-tests/docker/test_env/test_env_builder.go index 9f64ab64c98..53b97141bca 100644 --- a/integration-tests/docker/test_env/test_env_builder.go +++ b/integration-tests/docker/test_env/test_env_builder.go @@ -168,7 +168,7 @@ func (b *CLTestEnvBuilder) WithCustomCleanup(customFn func()) *CLTestEnvBuilder type ChainOption = func(*evmcfg.Chain) *evmcfg.Chain func (b *CLTestEnvBuilder) WithChainOptions(opts ...ChainOption) *CLTestEnvBuilder { - b.chainOptionsFn = make([]ChainOption, 0, 0) + b.chainOptionsFn = make([]ChainOption, 0) b.chainOptionsFn = append(b.chainOptionsFn, opts...) return b @@ -177,7 +177,7 @@ func (b *CLTestEnvBuilder) WithChainOptions(opts ...ChainOption) *CLTestEnvBuild type EVMClientNetworkOption = func(*blockchain.EVMNetwork) *blockchain.EVMNetwork func (b *CLTestEnvBuilder) EVMClientNetworkOptions(opts ...EVMClientNetworkOption) *CLTestEnvBuilder { - b.evmClientNetworkOption = make([]EVMClientNetworkOption, 0, 0) + b.evmClientNetworkOption = make([]EVMClientNetworkOption, 0) b.evmClientNetworkOption = append(b.evmClientNetworkOption, opts...) return b diff --git a/integration-tests/load/functions/config.go b/integration-tests/load/functions/config.go index 451d01a6c89..ad7e7446afb 100644 --- a/integration-tests/load/functions/config.go +++ b/integration-tests/load/functions/config.go @@ -7,6 +7,7 @@ import ( "github.com/pelletier/go-toml/v2" "github.com/rs/zerolog/log" + "github.com/smartcontractkit/chainlink/v2/core/store/models" ) @@ -118,8 +119,7 @@ func ReadConfig() (*PerformanceConfig, error) { return nil, fmt.Errorf( "ensure variables are set:\nMUMBAI_KEYS variable, private keys, comma separated\nSELECTED_NETWORKS=MUMBAI\nMUMBAI_URLS variable, websocket urls, comma separated", ) - } else { - cfg.MumbaiPrivateKey = mpk } + cfg.MumbaiPrivateKey = mpk return cfg, nil } diff --git a/integration-tests/load/functions/functions_test.go b/integration-tests/load/functions/functions_test.go index 7822035208e..dc52846d3c9 100644 --- a/integration-tests/load/functions/functions_test.go +++ b/integration-tests/load/functions/functions_test.go @@ -1,10 +1,11 @@ package loadfunctions import ( - "github.com/smartcontractkit/wasp" - "github.com/stretchr/testify/require" "testing" "time" + + "github.com/smartcontractkit/wasp" + "github.com/stretchr/testify/require" ) func TestFunctionsLoad(t *testing.T) { diff --git a/integration-tests/load/functions/gateway.go b/integration-tests/load/functions/gateway.go index 78b0f14cf18..ac5f895ac18 100644 --- a/integration-tests/load/functions/gateway.go +++ b/integration-tests/load/functions/gateway.go @@ -14,10 +14,11 @@ import ( "github.com/ethereum/go-ethereum/crypto/ecies" "github.com/go-resty/resty/v2" "github.com/rs/zerolog/log" + "github.com/smartcontractkit/tdh2/go/tdh2/tdh2easy" + "github.com/smartcontractkit/chainlink/v2/core/services/gateway/api" "github.com/smartcontractkit/chainlink/v2/core/services/gateway/handlers/functions" "github.com/smartcontractkit/chainlink/v2/core/services/s4" - "github.com/smartcontractkit/tdh2/go/tdh2/tdh2easy" ) type RPCResponse struct { @@ -115,7 +116,7 @@ func UploadS4Secrets(rc *resty.Client, s4Cfg *S4SecretsCfg) (uint8, uint64, erro log.Debug().Interface("Result", result).Msg("S4 secrets_set response result") for _, nodeResponse := range result.Result.Body.Payload.NodeResponses { if !nodeResponse.Body.Payload.Success { - return 0, 0, fmt.Errorf("node response was not succesful") + return 0, 0, fmt.Errorf("node response was not successful") } } return uint8(envelope.SlotID), envelope.Version, nil diff --git a/integration-tests/load/functions/gateway_gun.go b/integration-tests/load/functions/gateway_gun.go index fd13922d0a7..3dafb458a50 100644 --- a/integration-tests/load/functions/gateway_gun.go +++ b/integration-tests/load/functions/gateway_gun.go @@ -3,14 +3,15 @@ package loadfunctions import ( "crypto/ecdsa" "fmt" - "github.com/go-resty/resty/v2" - "github.com/rs/zerolog/log" - "github.com/smartcontractkit/tdh2/go/tdh2/tdh2easy" - "github.com/smartcontractkit/wasp" "math/rand" "os" "strconv" "time" + + "github.com/go-resty/resty/v2" + "github.com/rs/zerolog/log" + "github.com/smartcontractkit/tdh2/go/tdh2/tdh2easy" + "github.com/smartcontractkit/wasp" ) /* SingleFunctionCallGun is a gun that constantly requests randomness for one feed */ diff --git a/integration-tests/load/functions/onchain_monitoring.go b/integration-tests/load/functions/onchain_monitoring.go index 0a8b4cef46a..c4b4bdb78c0 100644 --- a/integration-tests/load/functions/onchain_monitoring.go +++ b/integration-tests/load/functions/onchain_monitoring.go @@ -1,10 +1,11 @@ package loadfunctions import ( - "github.com/rs/zerolog/log" - "github.com/smartcontractkit/wasp" "testing" "time" + + "github.com/rs/zerolog/log" + "github.com/smartcontractkit/wasp" ) /* Monitors on-chain stats of LoadConsumer and pushes them to Loki every second */ diff --git a/integration-tests/load/functions/request_gun.go b/integration-tests/load/functions/request_gun.go index d9987eaa756..bd4cf5f35aa 100644 --- a/integration-tests/load/functions/request_gun.go +++ b/integration-tests/load/functions/request_gun.go @@ -13,16 +13,15 @@ const ( ) type SingleFunctionCallGun struct { - ft *FunctionsTest - mode TestMode - times uint32 - source string - slotID uint8 - slotVersion uint64 - encryptedSecrets []byte - args []string - subscriptionId uint64 - jobId [32]byte + ft *FunctionsTest + mode TestMode + times uint32 + source string + slotID uint8 + slotVersion uint64 + args []string + subscriptionId uint64 + jobId [32]byte } func NewSingleFunctionCallGun( diff --git a/integration-tests/load/functions/setup.go b/integration-tests/load/functions/setup.go index 81bc660b35e..c0be47ca836 100644 --- a/integration-tests/load/functions/setup.go +++ b/integration-tests/load/functions/setup.go @@ -12,9 +12,10 @@ import ( "github.com/ethereum/go-ethereum/crypto" "github.com/go-resty/resty/v2" "github.com/rs/zerolog/log" + "github.com/smartcontractkit/tdh2/go/tdh2/tdh2easy" + "github.com/smartcontractkit/chainlink-testing-framework/blockchain" "github.com/smartcontractkit/chainlink-testing-framework/networks" - "github.com/smartcontractkit/tdh2/go/tdh2/tdh2easy" "github.com/smartcontractkit/chainlink/integration-tests/contracts" chainlinkutils "github.com/smartcontractkit/chainlink/v2/core/utils" diff --git a/integration-tests/load/log_poller/log_poller_test.go b/integration-tests/load/log_poller/log_poller_test.go index ec67815832c..04366848f0e 100644 --- a/integration-tests/load/log_poller/log_poller_test.go +++ b/integration-tests/load/log_poller/log_poller_test.go @@ -5,8 +5,9 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi" - lp_helpers "github.com/smartcontractkit/chainlink/integration-tests/universal/log_poller" "github.com/stretchr/testify/require" + + lp_helpers "github.com/smartcontractkit/chainlink/integration-tests/universal/log_poller" ) func TestLoadTestLogPoller(t *testing.T) { diff --git a/integration-tests/load/vrfv2/cmd/dashboard.go b/integration-tests/load/vrfv2/cmd/dashboard.go index 3035da0422f..0fb7be2b78b 100644 --- a/integration-tests/load/vrfv2/cmd/dashboard.go +++ b/integration-tests/load/vrfv2/cmd/dashboard.go @@ -1,6 +1,8 @@ package main import ( + "os" + "github.com/K-Phoen/grabana/dashboard" "github.com/K-Phoen/grabana/logs" "github.com/K-Phoen/grabana/row" @@ -8,7 +10,6 @@ import ( "github.com/K-Phoen/grabana/timeseries" "github.com/K-Phoen/grabana/timeseries/axis" "github.com/smartcontractkit/wasp" - "os" ) func main() { diff --git a/integration-tests/load/vrfv2/config.go b/integration-tests/load/vrfv2/config.go index 0c62cc351b4..0a595f753c2 100644 --- a/integration-tests/load/vrfv2/config.go +++ b/integration-tests/load/vrfv2/config.go @@ -7,6 +7,7 @@ import ( "github.com/pelletier/go-toml/v2" "github.com/rs/zerolog/log" + "github.com/smartcontractkit/chainlink/v2/core/store/models" ) diff --git a/integration-tests/load/vrfv2/gun.go b/integration-tests/load/vrfv2/gun.go index d6a8977738b..4e1c82bf3aa 100644 --- a/integration-tests/load/vrfv2/gun.go +++ b/integration-tests/load/vrfv2/gun.go @@ -1,9 +1,10 @@ package loadvrfv2 import ( + "github.com/smartcontractkit/wasp" + "github.com/smartcontractkit/chainlink/integration-tests/actions/vrfv2_actions" vrfConst "github.com/smartcontractkit/chainlink/integration-tests/actions/vrfv2_actions/vrfv2_constants" - "github.com/smartcontractkit/wasp" ) /* SingleHashGun is a gun that constantly requests randomness for one feed */ diff --git a/integration-tests/load/vrfv2/onchain_monitoring.go b/integration-tests/load/vrfv2/onchain_monitoring.go index b4503d27fad..72a3e7bcd77 100644 --- a/integration-tests/load/vrfv2/onchain_monitoring.go +++ b/integration-tests/load/vrfv2/onchain_monitoring.go @@ -2,11 +2,13 @@ package loadvrfv2 import ( "context" - "github.com/rs/zerolog/log" - "github.com/smartcontractkit/chainlink/integration-tests/actions/vrfv2_actions" - "github.com/smartcontractkit/wasp" "testing" "time" + + "github.com/rs/zerolog/log" + "github.com/smartcontractkit/wasp" + + "github.com/smartcontractkit/chainlink/integration-tests/actions/vrfv2_actions" ) /* Monitors on-chain stats of LoadConsumer and pushes them to Loki every second */ diff --git a/integration-tests/load/vrfv2/vrfv2_test.go b/integration-tests/load/vrfv2/vrfv2_test.go index a9fb80a72ad..44325965bd7 100644 --- a/integration-tests/load/vrfv2/vrfv2_test.go +++ b/integration-tests/load/vrfv2/vrfv2_test.go @@ -3,9 +3,10 @@ package loadvrfv2 import ( "testing" - "github.com/smartcontractkit/chainlink/integration-tests/actions/vrfv2_actions" "github.com/smartcontractkit/wasp" "github.com/stretchr/testify/require" + + "github.com/smartcontractkit/chainlink/integration-tests/actions/vrfv2_actions" ) func TestVRFV2Load(t *testing.T) { diff --git a/integration-tests/load/vrfv2/vu.go b/integration-tests/load/vrfv2/vu.go index 4658388d400..7eb02ae330f 100644 --- a/integration-tests/load/vrfv2/vu.go +++ b/integration-tests/load/vrfv2/vu.go @@ -4,11 +4,12 @@ import ( "fmt" "time" + "github.com/smartcontractkit/wasp" + "github.com/smartcontractkit/chainlink-testing-framework/blockchain" "github.com/smartcontractkit/chainlink/integration-tests/actions/vrfv2_actions" vrfConst "github.com/smartcontractkit/chainlink/integration-tests/actions/vrfv2_actions/vrfv2_constants" "github.com/smartcontractkit/chainlink/integration-tests/client" - "github.com/smartcontractkit/wasp" ) /* JobVolumeVU is a "virtual user" that creates a VRFv2 job and constantly requesting new randomness only for this job instance */ diff --git a/integration-tests/load/vrfv2plus/cmd/dashboard.go b/integration-tests/load/vrfv2plus/cmd/dashboard.go index 9a0ba682a18..049ee9ff2e9 100644 --- a/integration-tests/load/vrfv2plus/cmd/dashboard.go +++ b/integration-tests/load/vrfv2plus/cmd/dashboard.go @@ -1,6 +1,8 @@ package main import ( + "os" + "github.com/K-Phoen/grabana/dashboard" "github.com/K-Phoen/grabana/logs" "github.com/K-Phoen/grabana/row" @@ -8,7 +10,6 @@ import ( "github.com/K-Phoen/grabana/timeseries" "github.com/K-Phoen/grabana/timeseries/axis" "github.com/smartcontractkit/wasp" - "os" ) func main() { diff --git a/integration-tests/load/vrfv2plus/config.go b/integration-tests/load/vrfv2plus/config.go index cba3fdcde59..96dbf99c6b2 100644 --- a/integration-tests/load/vrfv2plus/config.go +++ b/integration-tests/load/vrfv2plus/config.go @@ -7,6 +7,7 @@ import ( "github.com/pelletier/go-toml/v2" "github.com/rs/zerolog/log" + "github.com/smartcontractkit/chainlink/integration-tests/actions/vrfv2plus/vrfv2plus_config" "github.com/smartcontractkit/chainlink/v2/core/store/models" ) @@ -100,6 +101,9 @@ func ReadConfig() (*PerformanceConfig, error) { } } else { d, err = base64.StdEncoding.DecodeString(rawConfig) + if err != nil { + return nil, fmt.Errorf("%s, err: %w", ErrReadPerfConfig, err) + } } err = toml.Unmarshal(d, &cfg) if err != nil { diff --git a/integration-tests/load/vrfv2plus/gun.go b/integration-tests/load/vrfv2plus/gun.go index 21be1c74ca7..2aecc69365e 100644 --- a/integration-tests/load/vrfv2plus/gun.go +++ b/integration-tests/load/vrfv2plus/gun.go @@ -1,12 +1,14 @@ package loadvrfv2plus import ( + "math/big" + "math/rand" + "github.com/rs/zerolog" + "github.com/smartcontractkit/wasp" + "github.com/smartcontractkit/chainlink/integration-tests/actions/vrfv2plus" "github.com/smartcontractkit/chainlink/integration-tests/actions/vrfv2plus/vrfv2plus_config" - "github.com/smartcontractkit/wasp" - "math/big" - "math/rand" ) /* SingleHashGun is a gun that constantly requests randomness for one feed */ diff --git a/integration-tests/load/vrfv2plus/onchain_monitoring.go b/integration-tests/load/vrfv2plus/onchain_monitoring.go index c56d835234e..c911546af0c 100644 --- a/integration-tests/load/vrfv2plus/onchain_monitoring.go +++ b/integration-tests/load/vrfv2plus/onchain_monitoring.go @@ -2,11 +2,13 @@ package loadvrfv2plus import ( "context" - "github.com/rs/zerolog/log" - "github.com/smartcontractkit/chainlink/integration-tests/contracts" - "github.com/smartcontractkit/wasp" "testing" "time" + + "github.com/rs/zerolog/log" + "github.com/smartcontractkit/wasp" + + "github.com/smartcontractkit/chainlink/integration-tests/contracts" ) /* Monitors on-chain stats of LoadConsumer and pushes them to Loki every second */ diff --git a/integration-tests/load/vrfv2plus/vrfv2plus_test.go b/integration-tests/load/vrfv2plus/vrfv2plus_test.go index 4d3de014bcd..625510af6f9 100644 --- a/integration-tests/load/vrfv2plus/vrfv2plus_test.go +++ b/integration-tests/load/vrfv2plus/vrfv2plus_test.go @@ -2,19 +2,21 @@ package loadvrfv2plus import ( "context" - "github.com/ethereum/go-ethereum/common" - "github.com/kelseyhightower/envconfig" - "github.com/rs/zerolog/log" - "github.com/smartcontractkit/chainlink-testing-framework/logging" - "github.com/smartcontractkit/chainlink/integration-tests/testreporters" - "github.com/smartcontractkit/wasp" - "github.com/stretchr/testify/require" "math/big" "os" "sync" "testing" "time" + "github.com/ethereum/go-ethereum/common" + "github.com/kelseyhightower/envconfig" + "github.com/rs/zerolog/log" + "github.com/smartcontractkit/wasp" + "github.com/stretchr/testify/require" + + "github.com/smartcontractkit/chainlink-testing-framework/logging" + "github.com/smartcontractkit/chainlink/integration-tests/testreporters" + "github.com/smartcontractkit/chainlink/integration-tests/actions" "github.com/smartcontractkit/chainlink/integration-tests/actions/vrfv2plus" "github.com/smartcontractkit/chainlink/integration-tests/actions/vrfv2plus/vrfv2plus_config" diff --git a/integration-tests/migration/upgrade_version_test.go b/integration-tests/migration/upgrade_version_test.go index bf97f43d058..ddb8b892535 100644 --- a/integration-tests/migration/upgrade_version_test.go +++ b/integration-tests/migration/upgrade_version_test.go @@ -3,9 +3,10 @@ package migration import ( "testing" - "github.com/smartcontractkit/chainlink-testing-framework/utils" "github.com/stretchr/testify/require" + "github.com/smartcontractkit/chainlink-testing-framework/utils" + "os" "github.com/smartcontractkit/chainlink/integration-tests/docker/test_env" diff --git a/integration-tests/performance/keeper_test.go b/integration-tests/performance/keeper_test.go index cd9818f99d3..0d693181080 100644 --- a/integration-tests/performance/keeper_test.go +++ b/integration-tests/performance/keeper_test.go @@ -84,7 +84,7 @@ func TestKeeperPerformance(t *testing.T) { // Cancel all the registered upkeeps via the registry for i := 0; i < len(upkeepIDs); i++ { - err := registry.CancelUpkeep(upkeepIDs[i]) + err = registry.CancelUpkeep(upkeepIDs[i]) require.NoError(t, err, "Could not cancel upkeep at index %d", i) } diff --git a/integration-tests/reorg/automation_reorg_test.go b/integration-tests/reorg/automation_reorg_test.go index 697ae28ce3b..888afc21e65 100644 --- a/integration-tests/reorg/automation_reorg_test.go +++ b/integration-tests/reorg/automation_reorg_test.go @@ -133,6 +133,8 @@ func TestAutomationReorg(t *testing.T) { } for name, registryVersion := range registryVersions { + name := name + registryVersion := registryVersion t.Run(name, func(t *testing.T) { t.Parallel() network := networks.MustGetSelectedNetworksFromEnv()[0] @@ -250,7 +252,8 @@ func TestAutomationReorg(t *testing.T) { }, "5m", "1s").Should(gomega.Succeed()) l.Info().Msg("Upkeep performed during unstable chain, waiting for reorg to finish") - rc.WaitDepthReached() + err = rc.WaitDepthReached() + require.NoError(t, err) l.Info().Msg("Reorg finished, chain should be stable now. Expecting upkeeps to keep getting performed") gom.Eventually(func(g gomega.Gomega) { diff --git a/integration-tests/reorg/log_poller_maybe_reorg_test.go b/integration-tests/reorg/log_poller_maybe_reorg_test.go index 4e802bdb09c..26e676f27e7 100644 --- a/integration-tests/reorg/log_poller_maybe_reorg_test.go +++ b/integration-tests/reorg/log_poller_maybe_reorg_test.go @@ -4,6 +4,7 @@ import ( "testing" "github.com/ethereum/go-ethereum/accounts/abi" + logpoller "github.com/smartcontractkit/chainlink/integration-tests/universal/log_poller" ) diff --git a/integration-tests/reorg/reorg_test.go b/integration-tests/reorg/reorg_test.go index f92becfa50a..ba754864b3d 100644 --- a/integration-tests/reorg/reorg_test.go +++ b/integration-tests/reorg/reorg_test.go @@ -26,6 +26,7 @@ import ( "github.com/onsi/gomega" "github.com/rs/zerolog/log" + "github.com/smartcontractkit/chainlink-testing-framework/networks" "github.com/smartcontractkit/chainlink/integration-tests/actions" diff --git a/integration-tests/smoke/automation_test.go b/integration-tests/smoke/automation_test.go index 9e35b24df1e..349a104697f 100644 --- a/integration-tests/smoke/automation_test.go +++ b/integration-tests/smoke/automation_test.go @@ -187,7 +187,8 @@ func SetupAutomationBasic(t *testing.T, nodeUpgrade bool) { expect := 5 // Upgrade the nodes one at a time and check that the upkeeps are still being performed for i := 0; i < 5; i++ { - actions.UpgradeChainlinkNodeVersionsLocal(upgradeImage, upgradeVersion, testEnv.ClCluster.Nodes[i]) + err = actions.UpgradeChainlinkNodeVersionsLocal(upgradeImage, upgradeVersion, testEnv.ClCluster.Nodes[i]) + require.NoError(t, err, "Error when upgrading node %d", i) time.Sleep(time.Second * 10) expect = expect + 5 gom.Eventually(func(g gomega.Gomega) { @@ -1086,11 +1087,13 @@ func setupAutomationTestDocker( if isMercuryV02 { output := `{"chainlinkBlob":"0x0001c38d71fed6c320b90e84b6f559459814d068e2a1700adc931ca9717d4fe70000000000000000000000000000000000000000000000000000000001a80b52b4bf1233f9cb71144a253a1791b202113c4ab4a92fa1b176d684b4959666ff8200000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000260000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001004254432d5553442d415242495452554d2d544553544e4554000000000000000000000000000000000000000000000000000000000000000000000000645570be000000000000000000000000000000000000000000000000000002af2b818dc5000000000000000000000000000000000000000000000000000002af2426faf3000000000000000000000000000000000000000000000000000002af32dc209700000000000000000000000000000000000000000000000000000000012130f8df0a9745bb6ad5e2df605e158ba8ad8a33ef8a0acf9851f0f01668a3a3f2b68600000000000000000000000000000000000000000000000000000000012130f60000000000000000000000000000000000000000000000000000000000000002c4a7958dce105089cf5edb68dad7dcfe8618d7784eb397f97d5a5fade78c11a58275aebda478968e545f7e3657aba9dcbe8d44605e4c6fde3e24edd5e22c94270000000000000000000000000000000000000000000000000000000000000002459c12d33986018a8959566d145225f0c4a4e61a9a3f50361ccff397899314f0018162cf10cd89897635a0bb62a822355bd199d09f4abe76e4d05261bb44733d"}` - env.MockAdapter.SetStringValuePath("/client", []string{http.MethodGet, http.MethodPost}, map[string]string{"Content-Type": "application/json"}, output) + err = env.MockAdapter.SetStringValuePath("/client", []string{http.MethodGet, http.MethodPost}, map[string]string{"Content-Type": "application/json"}, output) + require.NoError(t, err) } if isMercuryV03 { output := `{"reports":[{"feedID":"0x4554482d5553442d415242495452554d2d544553544e45540000000000000000","validFromTimestamp":0,"observationsTimestamp":0,"fullReport":"0x00066dfcd1ed2d95b18c948dbc5bd64c687afe93e4ca7d663ddec14c20090ad80000000000000000000000000000000000000000000000000000000000081401000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000002200000000000000000000000000000000000000000000000000000000000000280000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001204554482d5553442d415242495452554d2d544553544e455400000000000000000000000000000000000000000000000000000000000000000000000064891c98000000000000000000000000000000000000000000000000000000289ad8d367000000000000000000000000000000000000000000000000000000289acf0b38000000000000000000000000000000000000000000000000000000289b3da40000000000000000000000000000000000000000000000000000000000018ae7ce74d9fa252a8983976eab600dc7590c778d04813430841bc6e765c34cd81a168d00000000000000000000000000000000000000000000000000000000018ae7cb0000000000000000000000000000000000000000000000000000000064891c98000000000000000000000000000000000000000000000000000000000000000260412b94e525ca6cedc9f544fd86f77606d52fe731a5d069dbe836a8bfc0fb8c911963b0ae7a14971f3b4621bffb802ef0605392b9a6c89c7fab1df8633a5ade00000000000000000000000000000000000000000000000000000000000000024500c2f521f83fba5efc2bf3effaaedde43d0a4adff785c1213b712a3aed0d8157642a84324db0cf9695ebd27708d4608eb0337e0dd87b0e43f0fa70c700d911"}]}` - env.MockAdapter.SetStringValuePath("/api/v1/reports/bulk", []string{http.MethodGet, http.MethodPost}, map[string]string{"Content-Type": "application/json"}, output) + err = env.MockAdapter.SetStringValuePath("/api/v1/reports/bulk", []string{http.MethodGet, http.MethodPost}, map[string]string{"Content-Type": "application/json"}, output) + require.NoError(t, err) } } else { env, err = test_env.NewCLTestEnvBuilder(). diff --git a/integration-tests/smoke/log_poller_test.go b/integration-tests/smoke/log_poller_test.go index 0df7817f1e3..4e36b1d45c2 100644 --- a/integration-tests/smoke/log_poller_test.go +++ b/integration-tests/smoke/log_poller_test.go @@ -4,6 +4,7 @@ import ( "testing" "github.com/ethereum/go-ethereum/accounts/abi" + logpoller "github.com/smartcontractkit/chainlink/integration-tests/universal/log_poller" ) diff --git a/integration-tests/testreporters/keeper_benchmark.go b/integration-tests/testreporters/keeper_benchmark.go index c800eb37be2..baf97265c6c 100644 --- a/integration-tests/testreporters/keeper_benchmark.go +++ b/integration-tests/testreporters/keeper_benchmark.go @@ -183,7 +183,7 @@ func (k *KeeperBenchmarkTestReporter) WriteReport(folderLocation string) error { } for contractIndex, report := range k.Reports { - avg, median, ninetyPct, ninetyNinePct, max := intListStats(report.AllCheckDelays) + avg, median, ninetyPct, ninetyNinePct, max = intListStats(report.AllCheckDelays) err = keeperReportWriter.Write([]string{ fmt.Sprint(contractIndex), report.RegistryAddress, diff --git a/integration-tests/testreporters/ocr.go b/integration-tests/testreporters/ocr.go index a04718ea228..abbb261fa74 100644 --- a/integration-tests/testreporters/ocr.go +++ b/integration-tests/testreporters/ocr.go @@ -67,9 +67,7 @@ func (e *OCRRoundState) Time() time.Time { // CSV returns a CSV representation of the test state and all events func (e *OCRRoundState) CSV() [][]string { rows := [][]string{{e.StartTime.Format("2006-01-02 15:04:05.00 MST"), fmt.Sprintf("Expecting new Answer: %d", e.Answer)}} - for _, anomaly := range e.anomalies { - rows = append(rows, anomaly) - } + rows = append(rows, e.anomalies...) return rows } diff --git a/integration-tests/testreporters/vrfv2plus.go b/integration-tests/testreporters/vrfv2plus.go index 83d4678dfdd..38220ca8821 100644 --- a/integration-tests/testreporters/vrfv2plus.go +++ b/integration-tests/testreporters/vrfv2plus.go @@ -2,12 +2,13 @@ package testreporters import ( "fmt" - "github.com/smartcontractkit/chainlink/integration-tests/actions/vrfv2plus/vrfv2plus_config" "math/big" "os" "testing" "time" + "github.com/smartcontractkit/chainlink/integration-tests/actions/vrfv2plus/vrfv2plus_config" + "github.com/slack-go/slack" "github.com/smartcontractkit/chainlink-testing-framework/testreporters" @@ -53,7 +54,7 @@ func (o *VRFV2PlusTestReporter) SendSlackNotification(t *testing.T, slackClient headerText = fmt.Sprintf(":x: VRF %s Test FAILED :x:", o.TestType) } - messageBlocks := testreporters.SlackNotifyBlocks(headerText, fmt.Sprintf("%s", os.Getenv("SELECTED_NETWORKS")), []string{ + messageBlocks := testreporters.SlackNotifyBlocks(headerText, os.Getenv("SELECTED_NETWORKS"), []string{ fmt.Sprintf( "Summary\n"+ "Perf Test Type: %s\n"+ diff --git a/integration-tests/testsetups/keeper_benchmark.go b/integration-tests/testsetups/keeper_benchmark.go index f786cca9bb5..7f6d37c5541 100644 --- a/integration-tests/testsetups/keeper_benchmark.go +++ b/integration-tests/testsetups/keeper_benchmark.go @@ -413,6 +413,7 @@ func (k *KeeperBenchmarkTest) observeUpkeepEvents() { require.NoError(k.t, err, "Subscribing to upkeep performed events log shouldn't fail") interruption := make(chan os.Signal, 1) + //nolint:staticcheck //ignore SA1016 we need to send the os.Kill signal signal.Notify(interruption, os.Kill, os.Interrupt, syscall.SIGTERM) go func() { diff --git a/integration-tests/testsetups/ocr.go b/integration-tests/testsetups/ocr.go index ee8116f3f99..5428d13ca27 100644 --- a/integration-tests/testsetups/ocr.go +++ b/integration-tests/testsetups/ocr.go @@ -343,7 +343,7 @@ func (o *OCRSoakTest) SaveState() error { if err != nil { return err } - // #nosec G306 - let everyone read + //nolint:gosec // G306 - let everyone read if err = os.WriteFile(saveFileLocation, data, 0644); err != nil { return err } @@ -468,6 +468,7 @@ func (o *OCRSoakTest) Interrupted() bool { func (o *OCRSoakTest) testLoop(testDuration time.Duration, newValue int) { endTest := time.After(testDuration) interruption := make(chan os.Signal, 1) + //nolint:staticcheck //ignore SA1016 we need to send the os.Kill signal signal.Notify(interruption, os.Kill, os.Interrupt, syscall.SIGTERM) lastValue := 0 newRoundTrigger := time.NewTimer(0) // Want to trigger a new round ASAP diff --git a/integration-tests/testsetups/vrfv2.go b/integration-tests/testsetups/vrfv2.go index 194c7ff4e6c..ccbce18a7c7 100644 --- a/integration-tests/testsetups/vrfv2.go +++ b/integration-tests/testsetups/vrfv2.go @@ -126,7 +126,7 @@ func (v *VRFV2SoakTest) Run(t *testing.T) { //todo - need to find better way for this time.Sleep(1 * time.Minute) - loadTestMetrics, err := v.Inputs.ConsumerContract.GetLoadTestMetrics(nil) + loadTestMetrics, err := v.Inputs.ConsumerContract.GetLoadTestMetrics(context.Background()) if err != nil { l.Error().Err(err).Msg("Error Occurred when getting Load Test Metrics from Consumer contract") } diff --git a/integration-tests/types/envcommon/common.go b/integration-tests/types/envcommon/common.go index 607c481f33f..bdabcaf96b0 100644 --- a/integration-tests/types/envcommon/common.go +++ b/integration-tests/types/envcommon/common.go @@ -2,7 +2,7 @@ package envcommon import ( "encoding/json" - "io/ioutil" + "io" "os" ) @@ -12,7 +12,7 @@ func ParseJSONFile(path string, v any) error { return err } defer jsonFile.Close() - b, _ := ioutil.ReadAll(jsonFile) + b, _ := io.ReadAll(jsonFile) err = json.Unmarshal(b, v) if err != nil { return err diff --git a/integration-tests/universal/log_poller/config.go b/integration-tests/universal/log_poller/config.go index 623fa6606ed..da75b8d5587 100644 --- a/integration-tests/universal/log_poller/config.go +++ b/integration-tests/universal/log_poller/config.go @@ -9,6 +9,7 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi" "github.com/pelletier/go-toml/v2" "github.com/rs/zerolog/log" + "github.com/smartcontractkit/chainlink/v2/core/store/models" ) diff --git a/integration-tests/universal/log_poller/gun.go b/integration-tests/universal/log_poller/gun.go index 11932330a3b..39286f1b53e 100644 --- a/integration-tests/universal/log_poller/gun.go +++ b/integration-tests/universal/log_poller/gun.go @@ -7,8 +7,9 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi" "github.com/rs/zerolog" - "github.com/smartcontractkit/chainlink/integration-tests/contracts" "github.com/smartcontractkit/wasp" + + "github.com/smartcontractkit/chainlink/integration-tests/contracts" ) /* LogEmitterGun is a gun that constantly emits logs from a contract */ @@ -53,13 +54,13 @@ func (m *LogEmitterGun) Call(l *wasp.Generator) *wasp.CallResult { case "Log3": _, err = logEmitter.EmitLogStrings(getStringSlice(m.eventsPerTx)) default: - err = fmt.Errorf("Unknown event name: %s", event.Name) + err = fmt.Errorf("unknown event name: %s", event.Name) } if err != nil { return &wasp.CallResult{Error: err.Error(), Failed: true} } - localCounter += 1 + localCounter++ } // I don't think that will work as expected, I should atomically read the value and save it, so maybe just a mutex? diff --git a/integration-tests/universal/log_poller/helpers.go b/integration-tests/universal/log_poller/helpers.go index aa488eb1be5..748def98d18 100644 --- a/integration-tests/universal/log_poller/helpers.go +++ b/integration-tests/universal/log_poller/helpers.go @@ -3,7 +3,6 @@ package logpoller import ( "bytes" "context" - "errors" "fmt" "math/big" "math/rand" @@ -18,35 +17,35 @@ import ( "github.com/ethereum/go-ethereum/common" geth_types "github.com/ethereum/go-ethereum/core/types" "github.com/rs/zerolog" + "github.com/smartcontractkit/wasp" + "github.com/smartcontractkit/chainlink-testing-framework/blockchain" - ctf_blockchain "github.com/smartcontractkit/chainlink-testing-framework/blockchain" "github.com/smartcontractkit/chainlink-testing-framework/logging" "github.com/smartcontractkit/chainlink-testing-framework/networks" "github.com/smartcontractkit/chainlink/integration-tests/actions" "github.com/smartcontractkit/chainlink/integration-tests/client" "github.com/smartcontractkit/chainlink/integration-tests/contracts/ethereum" "github.com/smartcontractkit/chainlink/integration-tests/types/config/node" - "github.com/smartcontractkit/wasp" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller" cltypes "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/automation_utils_2_1" "github.com/smartcontractkit/chainlink/v2/core/store/models" + "github.com/stretchr/testify/require" + ctf_test_env "github.com/smartcontractkit/chainlink-testing-framework/docker/test_env" "github.com/smartcontractkit/chainlink/integration-tests/contracts" "github.com/smartcontractkit/chainlink/integration-tests/docker/test_env" - "github.com/stretchr/testify/require" "github.com/scylladb/go-reflectx" + "github.com/smartcontractkit/sqlx" + it_utils "github.com/smartcontractkit/chainlink/integration-tests/utils" - utils2 "github.com/smartcontractkit/chainlink/integration-tests/utils" evmcfg "github.com/smartcontractkit/chainlink/v2/core/chains/evm/config/toml" - lpEvm "github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller" le "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/log_emitter" core_logger "github.com/smartcontractkit/chainlink/v2/core/logger" "github.com/smartcontractkit/chainlink/v2/core/services/pg" - "github.com/smartcontractkit/sqlx" ) var ( @@ -81,63 +80,64 @@ var registerSingleTopicFilter = func(registry contracts.KeeperRegistry, upkeepID } // this is not really possible, log trigger doesn't support multiple topics, even if log poller does -var registerMultipleTopicsFilter = func(registry contracts.KeeperRegistry, upkeepID *big.Int, emitterAddress common.Address, topics []abi.Event) error { - if len(topics) > 4 { - return errors.New("Cannot register more than 4 topics") - } - - var getTopic = func(topics []abi.Event, i int) common.Hash { - if i > len(topics)-1 { - return bytes0 - } - - return topics[i].ID - } - - var getFilterSelector = func(topics []abi.Event) (uint8, error) { - switch len(topics) { - case 0: - return 0, errors.New("Cannot register filter with 0 topics") - case 1: - return 0, nil - case 2: - return 1, nil - case 3: - return 3, nil - case 4: - return 7, nil - default: - return 0, errors.New("Cannot register filter with more than 4 topics") - } - } - - filterSelector, err := getFilterSelector(topics) - if err != nil { - return err - } - - logTriggerConfigStruct := automation_utils_2_1.LogTriggerConfig{ - ContractAddress: emitterAddress, - FilterSelector: filterSelector, - Topic0: getTopic(topics, 0), - Topic1: getTopic(topics, 1), - Topic2: getTopic(topics, 2), - Topic3: getTopic(topics, 3), - } - encodedLogTriggerConfig, err := automationUtilsABI.Methods["_logTriggerConfig"].Inputs.Pack(&logTriggerConfigStruct) - if err != nil { - return err - } - - err = registry.SetUpkeepTriggerConfig(upkeepID, encodedLogTriggerConfig) - if err != nil { - return err - } - - return nil -} - -func NewOrm(logger core_logger.SugaredLogger, chainID *big.Int, postgresDb *ctf_test_env.PostgresDb) (*lpEvm.DbORM, *sqlx.DB, error) { +// Unused??? +// var registerMultipleTopicsFilter = func(registry contracts.KeeperRegistry, upkeepID *big.Int, emitterAddress common.Address, topics []abi.Event) error { +// if len(topics) > 4 { +// return errors.New("Cannot register more than 4 topics") +// } + +// var getTopic = func(topics []abi.Event, i int) common.Hash { +// if i > len(topics)-1 { +// return bytes0 +// } + +// return topics[i].ID +// } + +// var getFilterSelector = func(topics []abi.Event) (uint8, error) { +// switch len(topics) { +// case 0: +// return 0, errors.New("Cannot register filter with 0 topics") +// case 1: +// return 0, nil +// case 2: +// return 1, nil +// case 3: +// return 3, nil +// case 4: +// return 7, nil +// default: +// return 0, errors.New("Cannot register filter with more than 4 topics") +// } +// } + +// filterSelector, err := getFilterSelector(topics) +// if err != nil { +// return err +// } + +// logTriggerConfigStruct := automation_utils_2_1.LogTriggerConfig{ +// ContractAddress: emitterAddress, +// FilterSelector: filterSelector, +// Topic0: getTopic(topics, 0), +// Topic1: getTopic(topics, 1), +// Topic2: getTopic(topics, 2), +// Topic3: getTopic(topics, 3), +// } +// encodedLogTriggerConfig, err := automationUtilsABI.Methods["_logTriggerConfig"].Inputs.Pack(&logTriggerConfigStruct) +// if err != nil { +// return err +// } + +// err = registry.SetUpkeepTriggerConfig(upkeepID, encodedLogTriggerConfig) +// if err != nil { +// return err +// } + +// return nil +// } + +func NewOrm(logger core_logger.SugaredLogger, chainID *big.Int, postgresDb *ctf_test_env.PostgresDb) (*logpoller.DbORM, *sqlx.DB, error) { dsn := fmt.Sprintf("host=%s port=%s user=%s password=%s dbname=%s sslmode=disable", "127.0.0.1", postgresDb.ExternalPort, postgresDb.User, postgresDb.Password, postgresDb.DbName) db, err := sqlx.Open("postgres", dsn) if err != nil { @@ -145,7 +145,7 @@ func NewOrm(logger core_logger.SugaredLogger, chainID *big.Int, postgresDb *ctf_ } db.MapperFunc(reflectx.CamelToSnakeASCII) - return lpEvm.NewORM(chainID, db, logger, pg.NewQConfig(false)), db, nil + return logpoller.NewORM(chainID, db, logger, pg.NewQConfig(false)), db, nil } type ExpectedFilter struct { @@ -189,7 +189,7 @@ var nodeHasExpectedFilters = func(expectedFilters []ExpectedFilter, logger core_ } if !filterFound { - return false, fmt.Errorf("No filter found for emitter %s and topic %s", expectedFilter.emitterAddress.String(), expectedFilter.topic.Hex()) + return false, fmt.Errorf("no filter found for emitter %s and topic %s", expectedFilter.emitterAddress.String(), expectedFilter.topic.Hex()) } } @@ -203,9 +203,10 @@ var randomWait = func(minMilliseconds, maxMilliseconds int) { } type LogEmitterChannel struct { - logsEmitted int - err error - currentIndex int + logsEmitted int + err error + // unused + // currentIndex int } func getIntSlice(length int) []int { @@ -247,7 +248,7 @@ var emitEvents = func(ctx context.Context, l zerolog.Logger, logEmitter *contrac case "Log3": _, err = (*logEmitter).EmitLogStrings(getStringSlice(cfg.General.EventsPerTx)) default: - err = fmt.Errorf("Unknown event name: %s", event.Name) + err = fmt.Errorf("unknown event name: %s", event.Name) } if err != nil { @@ -276,29 +277,30 @@ var emitEvents = func(ctx context.Context, l zerolog.Logger, logEmitter *contrac } } -var waitForEndBlockInLogPoller = func(endBlock int64, chainID *big.Int, l zerolog.Logger, coreLogger core_logger.SugaredLogger, nodes *test_env.ClCluster) (bool, error) { - for i := 1; i < len(nodes.Nodes); i++ { - clNode := nodes.Nodes[i] - orm, db, err := NewOrm(coreLogger, chainID, clNode.PostgresDb) - if err != nil { - return false, err - } - - defer db.Close() - block, err := orm.SelectBlockByNumber(endBlock) - if err != nil { - return false, err - } - - if block == nil { - return false, nil - } - } - - return true, nil -} - -var chainHasFinalisedEndBlock = func(l zerolog.Logger, evmClient ctf_blockchain.EVMClient, endBlock int64) (bool, error) { +// Unused??? +// var waitForEndBlockInLogPoller = func(endBlock int64, chainID *big.Int, l zerolog.Logger, coreLogger core_logger.SugaredLogger, nodes *test_env.ClCluster) (bool, error) { +// for i := 1; i < len(nodes.Nodes); i++ { +// clNode := nodes.Nodes[i] +// orm, db, err := NewOrm(coreLogger, chainID, clNode.PostgresDb) +// if err != nil { +// return false, err +// } + +// defer db.Close() +// block, err := orm.SelectBlockByNumber(endBlock) +// if err != nil { +// return false, err +// } + +// if block == nil { +// return false, nil +// } +// } + +// return true, nil +// } + +var chainHasFinalisedEndBlock = func(l zerolog.Logger, evmClient blockchain.EVMClient, endBlock int64) (bool, error) { effectiveEndBlock := endBlock + 1 lastFinalisedBlockHeader, err := evmClient.GetLatestFinalizedBlockHeader(context.Background()) if err != nil { @@ -512,7 +514,7 @@ func (m *MissingLogs) IsEmpty() bool { return true } -var getMissingLogs = func(startBlock, endBlock int64, logEmitters []*contracts.LogEmitter, evmClient ctf_blockchain.EVMClient, clnodeCluster *test_env.ClCluster, l zerolog.Logger, coreLogger core_logger.SugaredLogger, cfg *Config) (MissingLogs, error) { +var getMissingLogs = func(startBlock, endBlock int64, logEmitters []*contracts.LogEmitter, evmClient blockchain.EVMClient, clnodeCluster *test_env.ClCluster, l zerolog.Logger, coreLogger core_logger.SugaredLogger, cfg *Config) (MissingLogs, error) { wg := &sync.WaitGroup{} type dbQueryResult struct { @@ -696,11 +698,7 @@ var printMissingLogsByType = func(missingLogs map[string][]geth_types.Log, l zer for _, logs := range missingLogs { for _, v := range logs { humanName := findHumanName(v.Topics[0]) - if _, ok := missingByType[humanName]; ok { - missingByType[humanName] += 1 - } else { - missingByType[humanName] = 1 - } + missingByType[humanName]++ } } @@ -709,7 +707,7 @@ var printMissingLogsByType = func(missingLogs map[string][]geth_types.Log, l zer } } -var getEVMLogs = func(startBlock, endBlock int64, logEmitters []*contracts.LogEmitter, evmClient ctf_blockchain.EVMClient, l zerolog.Logger, cfg *Config) ([]geth_types.Log, error) { +var getEVMLogs = func(startBlock, endBlock int64, logEmitters []*contracts.LogEmitter, evmClient blockchain.EVMClient, l zerolog.Logger, cfg *Config) ([]geth_types.Log, error) { allLogsInEVMNode := make([]geth_types.Log, 0) for j := 0; j < len(logEmitters); j++ { address := (*logEmitters[j]).Address() @@ -757,7 +755,7 @@ func runWaspGenerator(t *testing.T, cfg *Config, logEmitters []*contracts.LogEmi RPSprime = cfg.Wasp.Load.LPS / int64(cfg.General.Contracts) / int64(cfg.General.EventsPerTx) / int64(len(cfg.General.EventsToEmit)) if RPSprime < 1 { - return 0, fmt.Errorf("Invalid load configuration, effective RPS would have been zero. Adjust LPS, contracts count, events per tx or events to emit") + return 0, fmt.Errorf("invalid load configuration, effective RPS would have been zero. Adjust LPS, contracts count, events per tx or events to emit") } } @@ -854,9 +852,8 @@ func getExpectedLogCount(cfg *Config) int64 { if cfg.General.Generator == GeneratorType_WASP { if cfg.Wasp.Load.RPS != 0 { return cfg.Wasp.Load.RPS * int64(cfg.Wasp.Load.Duration.Duration().Seconds()) * int64(cfg.General.EventsPerTx) - } else { - return cfg.Wasp.Load.LPS * int64(cfg.Wasp.Load.Duration.Duration().Seconds()) } + return cfg.Wasp.Load.LPS * int64(cfg.Wasp.Load.Duration.Duration().Seconds()) } return int64(len(cfg.General.EventsToEmit) * cfg.LoopedConfig.ExecutionCount * cfg.General.Contracts * cfg.General.EventsPerTx) @@ -903,6 +900,7 @@ var executeChaosExperiment = func(l zerolog.Logger, testEnv *test_env.CLClusterT guardChan := make(chan struct{}, 1) for i := 0; i < cfg.ChaosConfig.ExperimentCount; i++ { + i := i wg.Add(1) guardChan <- struct{}{} go func() { @@ -921,22 +919,21 @@ var executeChaosExperiment = func(l zerolog.Logger, testEnv *test_env.CLClusterT }() go func() { - for { - select { - case err, ok := <-chaosChan: - if !ok { - l.Info().Msg("All chaos experiments finished") - errorCh <- nil - return - } else { - if err != nil { - l.Err(err).Msg("Error encountered during chaos experiment") - errorCh <- err - return - } - } + for err := range chaosChan { + // This will receive errors until chaosChan is closed + if err != nil { + // If an error is encountered, log it, send it to the error channel, and return from the function + l.Err(err).Msg("Error encountered during chaos experiment") + errorCh <- err + return // Return on actual error } + // No need for an else block here, because if err is nil (which happens when the channel is closed), + // the loop will exit and the following log and nil send will execute. } + + // After the loop exits, which it will do when chaosChan is closed, log that all experiments are finished. + l.Info().Msg("All chaos experiments finished") + errorCh <- nil // Only send nil once, after all errors have been handled and the channel is closed }() } @@ -953,7 +950,7 @@ var GetFinalityDepth = func(chainId int64) (int64, error) { case 1337: finalityDepth = 10 default: - return 0, fmt.Errorf("No known finality depth for chain %d", chainId) + return 0, fmt.Errorf("no known finality depth for chain %d", chainId) } return finalityDepth, nil @@ -1057,8 +1054,8 @@ func setupLogPollerTestDocker( var logPolllerSettingsFn = func(chain *evmcfg.Chain) *evmcfg.Chain { chain.LogPollInterval = models.MustNewDuration(lpPollingInterval) - chain.FinalityDepth = utils2.Ptr[uint32](uint32(finalityDepth)) - chain.FinalityTagEnabled = utils2.Ptr[bool](finalityTagEnabled) + chain.FinalityDepth = it_utils.Ptr[uint32](uint32(finalityDepth)) + chain.FinalityTagEnabled = it_utils.Ptr[bool](finalityTagEnabled) return chain } diff --git a/integration-tests/universal/log_poller/scenarios.go b/integration-tests/universal/log_poller/scenarios.go index d14a3bcb2a7..f89193ee228 100644 --- a/integration-tests/universal/log_poller/scenarios.go +++ b/integration-tests/universal/log_poller/scenarios.go @@ -8,12 +8,13 @@ import ( "time" "github.com/onsi/gomega" + "github.com/stretchr/testify/require" + "github.com/smartcontractkit/chainlink-testing-framework/logging" "github.com/smartcontractkit/chainlink/integration-tests/actions" "github.com/smartcontractkit/chainlink/integration-tests/contracts" "github.com/smartcontractkit/chainlink/integration-tests/contracts/ethereum" core_logger "github.com/smartcontractkit/chainlink/v2/core/logger" - "github.com/stretchr/testify/require" ) func ExecuteBasicLogPollerTest(t *testing.T, cfg *Config) { diff --git a/integration-tests/utils/cl_node_jobs.go b/integration-tests/utils/cl_node_jobs.go index 16b0c167cfe..16f3c886170 100644 --- a/integration-tests/utils/cl_node_jobs.go +++ b/integration-tests/utils/cl_node_jobs.go @@ -10,10 +10,11 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/google/uuid" "github.com/lib/pq" + "gopkg.in/guregu/null.v4" + coreClient "github.com/smartcontractkit/chainlink/integration-tests/client" "github.com/smartcontractkit/chainlink/v2/core/services/job" "github.com/smartcontractkit/chainlink/v2/core/store/models" - "gopkg.in/guregu/null.v4" ) func BuildBootstrapSpec(verifierAddr common.Address, chainID int64, fromBlock uint64, feedId [32]byte) *coreClient.OCR2TaskJobSpec { diff --git a/integration-tests/utils/log.go b/integration-tests/utils/log.go deleted file mode 100644 index 499be8002d4..00000000000 --- a/integration-tests/utils/log.go +++ /dev/null @@ -1,19 +0,0 @@ -package utils - -import ( - "github.com/rs/zerolog" - "github.com/rs/zerolog/log" - "os" -) - -func SetupCoreDockerEnvLogger() { - lvlStr := os.Getenv("CORE_DOCKER_ENV_LOG_LEVEL") - if lvlStr == "" { - lvlStr = "info" - } - lvl, err := zerolog.ParseLevel(lvlStr) - if err != nil { - panic(err) - } - log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stderr}).Level(lvl) -} diff --git a/integration-tests/utils/templates/secrets.go b/integration-tests/utils/templates/secrets.go index f81287e871f..45edf0d0127 100644 --- a/integration-tests/utils/templates/secrets.go +++ b/integration-tests/utils/templates/secrets.go @@ -2,6 +2,7 @@ package templates import ( "github.com/google/uuid" + "github.com/smartcontractkit/chainlink-testing-framework/utils/templates" ) From 50b2d40ccf785fe3ebfd674f10d03c346b6d5e7e Mon Sep 17 00:00:00 2001 From: Tate Date: Tue, 7 Nov 2023 15:25:24 -0700 Subject: [PATCH 02/12] Fix the build to actually build all the test files --- .github/workflows/integration-tests.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index e8c6b26bcb2..17a80a0ee7b 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -81,6 +81,7 @@ jobs: run: | cd ./integration-tests go build ./... + SELECTED_NETWORKS=SIMULATED go test -run=^# ./... - name: Lint Go uses: golangci/golangci-lint-action@3a919529898de77ec3da873e3063ca4b10e7f5cc # v3.7.0 with: From 6b728d64643c99b8c2db4887201bf2c60bdd7848 Mon Sep 17 00:00:00 2001 From: Tate Date: Tue, 7 Nov 2023 16:10:09 -0700 Subject: [PATCH 03/12] Add needs for the new job so it will affect required steps --- .github/workflows/integration-tests.yml | 4 ++-- integration-tests/.golangci.yml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index 17a80a0ee7b..b882e3432f4 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -204,7 +204,7 @@ jobs: pull-requests: write id-token: write contents: read - needs: [build-chainlink, changes, compare-tests] + needs: [build-chainlink, changes, compare-tests, build-lint-integration-tests] env: SELECTED_NETWORKS: SIMULATED,SIMULATED_1,SIMULATED_2 CHAINLINK_COMMIT_SHA: ${{ github.sha }} @@ -272,7 +272,7 @@ jobs: pull-requests: write id-token: write contents: read - needs: [build-chainlink, changes] + needs: [build-chainlink, changes, build-lint-integration-tests] env: SELECTED_NETWORKS: SIMULATED,SIMULATED_1,SIMULATED_2 CHAINLINK_COMMIT_SHA: ${{ github.sha }} diff --git a/integration-tests/.golangci.yml b/integration-tests/.golangci.yml index 9ee5942e300..91881a8cf76 100644 --- a/integration-tests/.golangci.yml +++ b/integration-tests/.golangci.yml @@ -1,5 +1,5 @@ run: - timeout: 15m0s + timeout: 15m linters: enable: - exhaustive From c61b836bf072818103d626818516f14db86d24ae Mon Sep 17 00:00:00 2001 From: Tate Date: Wed, 8 Nov 2023 10:40:36 -0700 Subject: [PATCH 04/12] Review comments --- .../actions/ocr2vrf_actions/ocr2vrf_steps.go | 6 +- .../actions/operator_forwarder_helpers.go | 12 +- .../chaos/automation_chaos_test.go | 6 +- integration-tests/chaos/ocr2vrf_chaos_test.go | 6 +- integration-tests/chaos/ocr_chaos_test.go | 4 +- .../contracts/contract_vrf_models.go | 2 +- integration-tests/docker/test_env/cl_node.go | 112 +----------------- integration-tests/docker/test_env/test_env.go | 4 +- .../load/vrfv2/onchain_monitoring.go | 4 +- .../load/vrfv2plus/vrfv2plus_test.go | 6 +- .../performance/directrequest_test.go | 4 +- integration-tests/performance/flux_test.go | 10 +- integration-tests/performance/keeper_test.go | 8 +- integration-tests/performance/ocr_test.go | 6 +- integration-tests/performance/vrf_test.go | 6 +- .../reorg/automation_reorg_test.go | 8 +- integration-tests/reorg/reorg_test.go | 4 +- integration-tests/smoke/automation_test.go | 78 ++++++------ integration-tests/smoke/flux_test.go | 10 +- integration-tests/smoke/forwarder_ocr_test.go | 6 +- .../smoke/forwarders_ocr2_test.go | 6 +- integration-tests/smoke/keeper_test.go | 92 +++++++------- integration-tests/smoke/ocr2_test.go | 6 +- integration-tests/smoke/ocr2vrf_test.go | 6 +- integration-tests/smoke/ocr_test.go | 6 +- integration-tests/smoke/runlog_test.go | 4 +- integration-tests/smoke/vrf_test.go | 6 +- integration-tests/smoke/vrfv2_test.go | 6 +- integration-tests/smoke/vrfv2plus_test.go | 89 +++++++------- .../testsetups/keeper_benchmark.go | 9 +- integration-tests/testsetups/ocr.go | 11 +- integration-tests/testsetups/vrfv2.go | 5 +- .../universal/log_poller/helpers.go | 25 +--- .../universal/log_poller/scenarios.go | 14 +-- integration-tests/utils/common.go | 19 +++ 35 files changed, 251 insertions(+), 355 deletions(-) diff --git a/integration-tests/actions/ocr2vrf_actions/ocr2vrf_steps.go b/integration-tests/actions/ocr2vrf_actions/ocr2vrf_steps.go index 3aa00123451..ab2104d563c 100644 --- a/integration-tests/actions/ocr2vrf_actions/ocr2vrf_steps.go +++ b/integration-tests/actions/ocr2vrf_actions/ocr2vrf_steps.go @@ -1,7 +1,6 @@ package ocr2vrf_actions import ( - "context" "math/big" "strings" "testing" @@ -23,6 +22,7 @@ import ( "github.com/smartcontractkit/chainlink/integration-tests/actions/ocr2vrf_actions/ocr2vrf_constants" "github.com/smartcontractkit/chainlink/integration-tests/client" "github.com/smartcontractkit/chainlink/integration-tests/contracts" + "github.com/smartcontractkit/chainlink/integration-tests/utils" ) func SetAndWaitForVRFBeaconProcessToFinish(t *testing.T, ocr2VRFPluginConfig *OCR2VRFPluginConfig, vrfBeacon contracts.VRFBeacon) { @@ -273,14 +273,14 @@ func RequestRandomnessFulfillmentAndWaitForFulfilment( } func getRequestId(t *testing.T, consumer contracts.VRFBeaconConsumer, receipt *types.Receipt, confirmationDelay *big.Int) *big.Int { - periodBlocks, err := consumer.IBeaconPeriodBlocks(context.Background()) + periodBlocks, err := consumer.IBeaconPeriodBlocks(utils.TestContext(t)) require.NoError(t, err, "Error getting Beacon Period block count") blockNumber := receipt.BlockNumber periodOffset := new(big.Int).Mod(blockNumber, periodBlocks) nextBeaconOutputHeight := new(big.Int).Sub(new(big.Int).Add(blockNumber, periodBlocks), periodOffset) - requestID, err := consumer.GetRequestIdsBy(context.Background(), nextBeaconOutputHeight, confirmationDelay) + requestID, err := consumer.GetRequestIdsBy(utils.TestContext(t), nextBeaconOutputHeight, confirmationDelay) require.NoError(t, err, "Error getting requestID from consumer contract") return requestID diff --git a/integration-tests/actions/operator_forwarder_helpers.go b/integration-tests/actions/operator_forwarder_helpers.go index 37b50c4fa9a..ab9a89f1326 100644 --- a/integration-tests/actions/operator_forwarder_helpers.go +++ b/integration-tests/actions/operator_forwarder_helpers.go @@ -1,7 +1,6 @@ package actions import ( - "context" "math/big" "testing" @@ -17,6 +16,7 @@ import ( "github.com/smartcontractkit/chainlink/integration-tests/client" "github.com/smartcontractkit/chainlink/integration-tests/contracts" + "github.com/smartcontractkit/chainlink/integration-tests/utils" ) func DeployForwarderContracts( @@ -67,7 +67,7 @@ func AcceptAuthorizedReceiversOperator( err = chainClient.WaitForEvents() require.NoError(t, err, "Waiting for events in nodes shouldn't fail") - senders, err := forwarderInstance.GetAuthorizedSenders(context.Background()) + senders, err := forwarderInstance.GetAuthorizedSenders(utils.TestContext(t)) require.NoError(t, err, "Getting authorized senders shouldn't fail") var nodesAddrs []string for _, o := range nodeAddresses { @@ -75,7 +75,7 @@ func AcceptAuthorizedReceiversOperator( } require.Equal(t, nodesAddrs, senders, "Senders addresses should match node addresses") - owner, err := forwarderInstance.Owner(context.Background()) + owner, err := forwarderInstance.Owner(utils.TestContext(t)) require.NoError(t, err, "Getting authorized forwarder owner shouldn't fail") require.Equal(t, operator.Hex(), owner, "Forwarder owner should match operator") } @@ -141,7 +141,7 @@ func SubscribeOperatorFactoryEvents( l := logging.GetTestLogger(t) contractABI, err := operator_factory.OperatorFactoryMetaData.GetAbi() require.NoError(t, err, "Getting contract abi for OperatorFactory shouldn't fail") - latestBlockNum, err := chainClient.LatestBlockNumber(context.Background()) + latestBlockNum, err := chainClient.LatestBlockNumber(utils.TestContext(t)) require.NoError(t, err, "Subscribing to contract event log for OperatorFactory instance shouldn't fail") query := geth.FilterQuery{ FromBlock: big.NewInt(0).SetUint64(latestBlockNum), @@ -149,7 +149,7 @@ func SubscribeOperatorFactoryEvents( } eventLogs := make(chan types.Log) - sub, err := chainClient.SubscribeFilterLogs(context.Background(), query, eventLogs) + sub, err := chainClient.SubscribeFilterLogs(utils.TestContext(t), query, eventLogs) require.NoError(t, err, "Subscribing to contract event log for OperatorFactory instance shouldn't fail") go func() { defer sub.Unsubscribe() @@ -160,7 +160,7 @@ func SubscribeOperatorFactoryEvents( l.Error().Err(err).Msg("Error while watching for new contract events. Retrying Subscription") sub.Unsubscribe() - sub, err = chainClient.SubscribeFilterLogs(context.Background(), query, eventLogs) + sub, err = chainClient.SubscribeFilterLogs(utils.TestContext(t), query, eventLogs) require.NoError(t, err, "Subscribing to contract event log for OperatorFactory instance shouldn't fail") case vLog := <-eventLogs: eventDetails, err := contractABI.EventByID(vLog.Topics[0]) diff --git a/integration-tests/chaos/automation_chaos_test.go b/integration-tests/chaos/automation_chaos_test.go index ced28a38513..2691ce11879 100644 --- a/integration-tests/chaos/automation_chaos_test.go +++ b/integration-tests/chaos/automation_chaos_test.go @@ -1,7 +1,6 @@ package chaos import ( - "context" "fmt" "math/big" "testing" @@ -25,6 +24,7 @@ import ( "github.com/smartcontractkit/chainlink/integration-tests/client" "github.com/smartcontractkit/chainlink/integration-tests/contracts" eth_contracts "github.com/smartcontractkit/chainlink/integration-tests/contracts/ethereum" + it_utils "github.com/smartcontractkit/chainlink/integration-tests/utils" ) var ( @@ -269,7 +269,7 @@ func TestAutomationChaos(t *testing.T) { gom.Eventually(func(g gomega.Gomega) { // 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()) + counter, err := consumers[i].Counter(it_utils.TestContext(t)) require.NoError(t, err, "Failed to retrieve consumer counter for upkeep at index %d", i) expect := 5 l.Info().Int64("Upkeeps Performed", counter.Int64()).Int("Upkeep ID", i).Msg("Number of upkeeps performed") @@ -284,7 +284,7 @@ func TestAutomationChaos(t *testing.T) { gom.Eventually(func(g gomega.Gomega) { // 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()) + counter, err := consumers[i].Counter(it_utils.TestContext(t)) require.NoError(t, err, "Failed to retrieve consumer counter for upkeep at index %d", i) expect := 10 l.Info().Int64("Upkeeps Performed", counter.Int64()).Int("Upkeep ID", i).Msg("Number of upkeeps performed") diff --git a/integration-tests/chaos/ocr2vrf_chaos_test.go b/integration-tests/chaos/ocr2vrf_chaos_test.go index 3b0eb8ebc21..7ee91f69116 100644 --- a/integration-tests/chaos/ocr2vrf_chaos_test.go +++ b/integration-tests/chaos/ocr2vrf_chaos_test.go @@ -1,7 +1,6 @@ package chaos import ( - "context" "fmt" "math/big" "strings" @@ -26,6 +25,7 @@ import ( "github.com/smartcontractkit/chainlink/integration-tests/client" "github.com/smartcontractkit/chainlink/integration-tests/config" "github.com/smartcontractkit/chainlink/integration-tests/contracts" + it_utils "github.com/smartcontractkit/chainlink/integration-tests/utils" ) func TestOCR2VRFChaos(t *testing.T) { @@ -186,7 +186,7 @@ func TestOCR2VRFChaos(t *testing.T) { ) for i := uint16(0); i < ocr2vrf_constants.NumberOfRandomWordsToRequest; i++ { - randomness, err := consumerContract.GetRandomnessByRequestId(context.Background(), requestID, big.NewInt(int64(i))) + randomness, err := consumerContract.GetRandomnessByRequestId(it_utils.TestContext(t), requestID, big.NewInt(int64(i))) require.NoError(t, err) l.Info().Interface("Random Number", randomness).Interface("Randomness Number Index", i).Msg("Randomness retrieved from Consumer contract") require.NotEqual(t, 0, randomness.Uint64(), "Randomness retrieved from Consumer contract give an answer other than 0") @@ -213,7 +213,7 @@ func TestOCR2VRFChaos(t *testing.T) { ) for i := uint16(0); i < ocr2vrf_constants.NumberOfRandomWordsToRequest; i++ { - randomness, err := consumerContract.GetRandomnessByRequestId(context.Background(), requestID, big.NewInt(int64(i))) + randomness, err := consumerContract.GetRandomnessByRequestId(it_utils.TestContext(t), requestID, big.NewInt(int64(i))) require.NoError(t, err, "Error getting Randomness result from Consumer Contract") l.Info().Interface("Random Number", randomness).Interface("Randomness Number Index", i).Msg("Randomness retrieved from Consumer contract") require.NotEqual(t, 0, randomness.Uint64(), "Randomness retrieved from Consumer contract give an answer other than 0") diff --git a/integration-tests/chaos/ocr_chaos_test.go b/integration-tests/chaos/ocr_chaos_test.go index 599fad8ddc5..9d102394a54 100644 --- a/integration-tests/chaos/ocr_chaos_test.go +++ b/integration-tests/chaos/ocr_chaos_test.go @@ -1,7 +1,6 @@ package chaos import ( - "context" "fmt" "math/big" "os" @@ -23,6 +22,7 @@ import ( "github.com/smartcontractkit/chainlink-testing-framework/networks" "github.com/smartcontractkit/chainlink-testing-framework/utils" + it_utils "github.com/smartcontract/chainlink/integration-tests/utils" "github.com/smartcontractkit/chainlink/integration-tests/actions" "github.com/smartcontractkit/chainlink/integration-tests/client" "github.com/smartcontractkit/chainlink/integration-tests/config" @@ -195,7 +195,7 @@ func TestOCRChaos(t *testing.T) { err := ocr.RequestNewRound() require.NoError(t, err, "Error requesting new round") } - round, err := ocrInstances[0].GetLatestRound(context.Background()) + round, err := ocrInstances[0].GetLatestRound(it_utils.Context(t)) g.Expect(err).ShouldNot(gomega.HaveOccurred()) l.Info().Int64("RoundID", round.RoundId.Int64()).Msg("Latest OCR Round") if round.RoundId.Int64() == chaosStartRound && !chaosApplied { diff --git a/integration-tests/contracts/contract_vrf_models.go b/integration-tests/contracts/contract_vrf_models.go index e2a3e6630b5..baee2ccd929 100644 --- a/integration-tests/contracts/contract_vrf_models.go +++ b/integration-tests/contracts/contract_vrf_models.go @@ -264,7 +264,7 @@ type RequestStatus struct { type LoadTestRequestStatus struct { Fulfilled bool RandomWords []*big.Int - // Unused??? + // Currently Unused November 8, 2023, Mignt be used in near future, will remove if not. // requestTimestamp *big.Int // fulfilmentTimestamp *big.Int // requestBlockNumber *big.Int diff --git a/integration-tests/docker/test_env/cl_node.go b/integration-tests/docker/test_env/cl_node.go index 8ce238369a3..38595fe4173 100644 --- a/integration-tests/docker/test_env/cl_node.go +++ b/integration-tests/docker/test_env/cl_node.go @@ -1,15 +1,11 @@ package test_env import ( - "context" - "crypto/ed25519" - "encoding/hex" "fmt" "math/big" "net/url" "os" "strings" - "sync" "testing" "time" @@ -22,9 +18,6 @@ import ( tc "github.com/testcontainers/testcontainers-go" tcwait "github.com/testcontainers/testcontainers-go/wait" - ocrtypes "github.com/smartcontractkit/libocr/offchainreporting2/types" - "github.com/smartcontractkit/libocr/offchainreporting2plus/confighelper" - "github.com/smartcontractkit/chainlink-testing-framework/blockchain" "github.com/smartcontractkit/chainlink-testing-framework/docker" "github.com/smartcontractkit/chainlink-testing-framework/docker/test_env" @@ -119,7 +112,7 @@ func (n *ClNode) SetTestLogger(t *testing.T) { // Restart restarts only CL node, DB container is reused func (n *ClNode) Restart(cfg *chainlink.Config) error { - if err := n.Container.Terminate(context.Background()); err != nil { + if err := n.Container.Terminate(utils.TestContext(n.t)); err != nil { return err } n.NodeConfig = cfg @@ -197,7 +190,7 @@ func (n *ClNode) AddMercuryOCRJob(verifierAddr common.Address, fromBlock uint64, } func (n *ClNode) GetContainerName() string { - name, err := n.Container.Name(context.Background()) + name, err := n.Container.Name(utils.TestContext(n.t)) if err != nil { return "" } @@ -285,15 +278,15 @@ func (n *ClNode) StartContainer() error { return fmt.Errorf("%s err: %w", ErrStartCLNodeContainer, err) } if n.lw != nil { - if err := n.lw.ConnectContainer(context.Background(), container, "cl-node", true); err != nil { + if err := n.lw.ConnectContainer(utils.TestContext(n.t), container, "cl-node", true); err != nil { return err } } - clEndpoint, err := test_env.GetEndpoint(context.Background(), container, "http") + clEndpoint, err := test_env.GetEndpoint(utils.TestContext(n.t), container, "http") if err != nil { return err } - ip, err := container.ContainerIP(context.Background()) + ip, err := container.ContainerIP(utils.TestContext(n.t)) if err != nil { return err } @@ -411,98 +404,3 @@ func (n *ClNode) getContainerRequest(secrets string) ( }, }, nil } - -func GetOracleIdentities(chainlinkNodes []*ClNode) ([]int, []confighelper.OracleIdentityExtra, error) { - S := make([]int, len(chainlinkNodes)) - oracleIdentities := make([]confighelper.OracleIdentityExtra, len(chainlinkNodes)) - sharedSecretEncryptionPublicKeys := make([]ocrtypes.ConfigEncryptionPublicKey, len(chainlinkNodes)) - var wg sync.WaitGroup - errCh := make(chan error, len(chainlinkNodes)) // Buffered error channel to avoid blocking - for i, cl := range chainlinkNodes { - wg.Add(1) - go func(i int, cl *ClNode) { - defer wg.Done() - - ocr2Keys, err := cl.API.MustReadOCR2Keys() - if err != nil { - errCh <- err - return - } - var ocr2Config client.OCR2KeyAttributes - for _, key := range ocr2Keys.Data { - if key.Attributes.ChainType == string(chaintype.EVM) { - ocr2Config = key.Attributes - break - } - } - - keys, err := cl.API.MustReadP2PKeys() - if err != nil { - errCh <- err - return - } - p2pKeyID := keys.Data[0].Attributes.PeerID - - offchainPkBytes, err := hex.DecodeString(strings.TrimPrefix(ocr2Config.OffChainPublicKey, "ocr2off_evm_")) - if err != nil { - errCh <- err - return - } - - offchainPkBytesFixed := [ed25519.PublicKeySize]byte{} - copy(offchainPkBytesFixed[:], offchainPkBytes) - if err != nil { - errCh <- err - return - } - - configPkBytes, err := hex.DecodeString(strings.TrimPrefix(ocr2Config.ConfigPublicKey, "ocr2cfg_evm_")) - if err != nil { - errCh <- err - return - } - - configPkBytesFixed := [ed25519.PublicKeySize]byte{} - copy(configPkBytesFixed[:], configPkBytes) - if err != nil { - errCh <- err - return - } - - onchainPkBytes, err := hex.DecodeString(strings.TrimPrefix(ocr2Config.OnChainPublicKey, "ocr2on_evm_")) - if err != nil { - errCh <- err - return - } - - csaKeys, _, err := cl.API.ReadCSAKeys() - if err != nil { - errCh <- err - return - } - - sharedSecretEncryptionPublicKeys[i] = configPkBytesFixed - oracleIdentities[i] = confighelper.OracleIdentityExtra{ - OracleIdentity: confighelper.OracleIdentity{ - OnchainPublicKey: onchainPkBytes, - OffchainPublicKey: offchainPkBytesFixed, - PeerID: p2pKeyID, - TransmitAccount: ocrtypes.Account(csaKeys.Data[0].ID), - }, - ConfigEncryptionPublicKey: configPkBytesFixed, - } - S[i] = 1 - }(i, cl) - } - wg.Wait() - close(errCh) // Close the error channel - // Check for errors sent to the error channel - var firstErr error - for err := range errCh { - if err != nil { - firstErr = err - break - } - } - return S, oracleIdentities, firstErr -} diff --git a/integration-tests/docker/test_env/test_env.go b/integration-tests/docker/test_env/test_env.go index fd5f96e287e..bf65937c083 100644 --- a/integration-tests/docker/test_env/test_env.go +++ b/integration-tests/docker/test_env/test_env.go @@ -1,7 +1,6 @@ package test_env import ( - "context" "encoding/json" "fmt" "io" @@ -27,6 +26,7 @@ import ( "github.com/smartcontractkit/chainlink/integration-tests/client" "github.com/smartcontractkit/chainlink/integration-tests/contracts" + "github.com/smartcontractkit/chainlink/integration-tests/utils" ) var ( @@ -233,7 +233,7 @@ func (te *CLClusterTestEnv) collectTestLogs() error { return err } defer logFile.Close() - logReader, err := node.Container.Logs(context.Background()) + logReader, err := node.Container.Logs(utils.TestContext(te.t)) if err != nil { return err } diff --git a/integration-tests/load/vrfv2/onchain_monitoring.go b/integration-tests/load/vrfv2/onchain_monitoring.go index 72a3e7bcd77..879c7089e16 100644 --- a/integration-tests/load/vrfv2/onchain_monitoring.go +++ b/integration-tests/load/vrfv2/onchain_monitoring.go @@ -1,7 +1,6 @@ package loadvrfv2 import ( - "context" "testing" "time" @@ -9,6 +8,7 @@ import ( "github.com/smartcontractkit/wasp" "github.com/smartcontractkit/chainlink/integration-tests/actions/vrfv2_actions" + "github.com/smartcontractkit/chainlink/integration-tests/utils" ) /* Monitors on-chain stats of LoadConsumer and pushes them to Loki every second */ @@ -36,7 +36,7 @@ func MonitorLoadStats(t *testing.T, vrfv2Contracts *vrfv2_actions.VRFV2Contracts } for { time.Sleep(1 * time.Second) - metrics, err := vrfv2Contracts.LoadTestConsumer.GetLoadTestMetrics(context.Background()) + metrics, err := vrfv2Contracts.LoadTestConsumer.GetLoadTestMetrics(utils.TestContext(t)) if err != nil { log.Error().Err(err).Msg(ErrMetrics) } diff --git a/integration-tests/load/vrfv2plus/vrfv2plus_test.go b/integration-tests/load/vrfv2plus/vrfv2plus_test.go index 625510af6f9..e7734fee0d5 100644 --- a/integration-tests/load/vrfv2plus/vrfv2plus_test.go +++ b/integration-tests/load/vrfv2plus/vrfv2plus_test.go @@ -1,7 +1,6 @@ package loadvrfv2plus import ( - "context" "math/big" "os" "sync" @@ -16,6 +15,7 @@ import ( "github.com/smartcontractkit/chainlink-testing-framework/logging" "github.com/smartcontractkit/chainlink/integration-tests/testreporters" + "github.com/smartcontractkit/chainlink/integration-tests/utils" "github.com/smartcontractkit/chainlink/integration-tests/actions" "github.com/smartcontractkit/chainlink/integration-tests/actions/vrfv2plus" @@ -99,7 +99,7 @@ func TestVRFV2PlusPerformance(t *testing.T) { Str("Returning funds from SubID", subID.String()). Str("Returning funds to", eoaWalletAddress). Msg("Canceling subscription and returning funds to subscription owner") - pendingRequestsExist, err := vrfv2PlusContracts.Coordinator.PendingRequestsExist(context.Background(), subID) + pendingRequestsExist, err := vrfv2PlusContracts.Coordinator.PendingRequestsExist(utils.TestContext(t), subID) if err != nil { l.Error().Err(err).Msg("Error checking if pending requests exist") } @@ -230,7 +230,7 @@ func TestVRFV2PlusPerformance(t *testing.T) { l.Debug().Int("Number of Subs", len(subIDs)).Msg("Subs involved in the test") for _, subID := range subIDs { - subscription, err := vrfv2PlusContracts.Coordinator.GetSubscription(context.Background(), subID) + subscription, err := vrfv2PlusContracts.Coordinator.GetSubscription(utils.TestContext(t), subID) require.NoError(t, err, "error getting subscription information for subscription %s", subID.String()) vrfv2plus.LogSubDetails(l, subscription, subID, vrfv2PlusContracts.Coordinator) } diff --git a/integration-tests/performance/directrequest_test.go b/integration-tests/performance/directrequest_test.go index d229f9fb3ee..1a3f1d2a010 100644 --- a/integration-tests/performance/directrequest_test.go +++ b/integration-tests/performance/directrequest_test.go @@ -1,7 +1,6 @@ package performance import ( - "context" "fmt" "math/big" "strings" @@ -25,6 +24,7 @@ import ( "github.com/smartcontractkit/chainlink/integration-tests/client" "github.com/smartcontractkit/chainlink/integration-tests/contracts" "github.com/smartcontractkit/chainlink/integration-tests/testsetups" + "github.com/smartcontractkit/chainlink/integration-tests/utils" "github.com/google/uuid" ) @@ -108,7 +108,7 @@ func TestDirectRequestPerformance(t *testing.T) { gom := gomega.NewGomegaWithT(t) gom.Eventually(func(g gomega.Gomega) { - d, err := consumer.Data(context.Background()) + d, err := consumer.Data(utils.TestContext(t)) g.Expect(err).ShouldNot(gomega.HaveOccurred(), "Getting data from consumer contract shouldn't fail") g.Expect(d).ShouldNot(gomega.BeNil(), "Expected the initial on chain data to be nil") l.Debug().Int64("Data", d.Int64()).Msg("Found on chain") diff --git a/integration-tests/performance/flux_test.go b/integration-tests/performance/flux_test.go index be536450a76..18b13ab9076 100644 --- a/integration-tests/performance/flux_test.go +++ b/integration-tests/performance/flux_test.go @@ -1,7 +1,6 @@ package performance import ( - "context" "fmt" "math/big" "strings" @@ -26,6 +25,7 @@ import ( "github.com/smartcontractkit/chainlink/integration-tests/client" "github.com/smartcontractkit/chainlink/integration-tests/contracts" "github.com/smartcontractkit/chainlink/integration-tests/testsetups" + "github.com/smartcontractkit/chainlink/integration-tests/utils" ) func TestFluxPerformance(t *testing.T) { @@ -83,7 +83,7 @@ func TestFluxPerformance(t *testing.T) { require.NoError(t, err, "Setting oracle options in the Flux Aggregator contract shouldn't fail") err = chainClient.WaitForEvents() require.NoError(t, err, "Waiting for event subscriptions in nodes shouldn't fail") - oracles, err := fluxInstance.GetOracles(context.Background()) + oracles, err := fluxInstance.GetOracles(utils.TestContext(t)) require.NoError(t, err, "Getting oracle details from the Flux aggregator contract shouldn't fail") l.Info().Str("Oracles", strings.Join(oracles, ",")).Msg("Oracles set") @@ -120,7 +120,7 @@ func TestFluxPerformance(t *testing.T) { chainClient.AddHeaderEventSubscription(fluxInstance.Address(), fluxRound) err = chainClient.WaitForEvents() require.NoError(t, err, "Waiting for event subscriptions in nodes shouldn't fail") - data, err := fluxInstance.GetContractData(context.Background()) + data, err := fluxInstance.GetContractData(utils.TestContext(t)) require.NoError(t, err, "Getting contract data from flux aggregator contract shouldn't fail") l.Info().Interface("Data", data).Msg("Round data") require.Equal(t, int64(1e5), data.LatestRoundData.Answer.Int64(), @@ -140,7 +140,7 @@ func TestFluxPerformance(t *testing.T) { require.NoError(t, err, "Setting value path in mock server shouldn't fail") err = chainClient.WaitForEvents() require.NoError(t, err, "Waiting for event subscriptions in nodes shouldn't fail") - data, err = fluxInstance.GetContractData(context.Background()) + data, err = fluxInstance.GetContractData(utils.TestContext(t)) require.NoError(t, err, "Getting contract data from flux aggregator contract shouldn't fail") require.Equal(t, int64(1e10), data.LatestRoundData.Answer.Int64(), "Expected latest round answer to be %d, but found %d", int64(1e10), data.LatestRoundData.Answer.Int64()) @@ -153,7 +153,7 @@ func TestFluxPerformance(t *testing.T) { l.Info().Interface("data", data).Msg("Round data") for _, oracleAddr := range nodeAddresses { - payment, _ := fluxInstance.WithdrawablePayment(context.Background(), oracleAddr) + payment, _ := fluxInstance.WithdrawablePayment(utils.TestContext(t), oracleAddr) require.Equal(t, int64(2), payment.Int64(), "Expected flux aggregator contract's withdrawable payment to be %d, but found %d", int64(2), payment.Int64()) } diff --git a/integration-tests/performance/keeper_test.go b/integration-tests/performance/keeper_test.go index 0d693181080..8e273a96f69 100644 --- a/integration-tests/performance/keeper_test.go +++ b/integration-tests/performance/keeper_test.go @@ -2,7 +2,6 @@ package performance //revive:disable:dot-imports import ( - "context" "fmt" "math/big" "strings" @@ -26,6 +25,7 @@ import ( "github.com/smartcontractkit/chainlink/integration-tests/contracts" "github.com/smartcontractkit/chainlink/integration-tests/contracts/ethereum" "github.com/smartcontractkit/chainlink/integration-tests/testsetups" + "github.com/smartcontractkit/chainlink/integration-tests/utils" ) var keeperDefaultRegistryConfig = contracts.KeeperRegistrySettings{ @@ -74,7 +74,7 @@ func TestKeeperPerformance(t *testing.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 10 for i := 0; i < len(upkeepIDs); i++ { - counter, err := consumers[i].Counter(context.Background()) + counter, err := consumers[i].Counter(utils.TestContext(t)) g.Expect(err).ShouldNot(gomega.HaveOccurred(), "Failed to retrieve consumer counter for upkeep at index %d", i) g.Expect(counter.Int64()).Should(gomega.BeNumerically(">", int64(10)), "Expected consumer counter to be greater than 10, but got %d", counter.Int64()) @@ -95,7 +95,7 @@ func TestKeeperPerformance(t *testing.T) { for i := 0; i < len(upkeepIDs); i++ { // Obtain the amount of times the upkeep has been executed so far - countersAfterCancellation[i], err = consumers[i].Counter(context.Background()) + countersAfterCancellation[i], err = consumers[i].Counter(utils.TestContext(t)) require.NoError(t, err, "Failed to retrieve consumer counter for upkeep at index %d", i) l.Info().Int("Index", i).Int64("Upkeeps Performed", countersAfterCancellation[i].Int64()).Msg("Cancelled Upkeep") } @@ -103,7 +103,7 @@ func TestKeeperPerformance(t *testing.T) { gom.Consistently(func(g gomega.Gomega) { for i := 0; i < len(upkeepIDs); i++ { // Expect the counter to remain constant because the upkeep was cancelled, so it shouldn't increase anymore - latestCounter, err := consumers[i].Counter(context.Background()) + latestCounter, err := consumers[i].Counter(utils.TestContext(t)) require.NoError(t, err, "Failed to retrieve consumer counter for upkeep at index %d", i) g.Expect(latestCounter.Int64()).Should(gomega.Equal(countersAfterCancellation[i].Int64()), "Expected consumer counter to remain constant at %d, but got %d", diff --git a/integration-tests/performance/ocr_test.go b/integration-tests/performance/ocr_test.go index e81cc91cf7f..20c52c3d4aa 100644 --- a/integration-tests/performance/ocr_test.go +++ b/integration-tests/performance/ocr_test.go @@ -1,7 +1,6 @@ package performance import ( - "context" "fmt" "math/big" "strings" @@ -25,6 +24,7 @@ import ( "github.com/smartcontractkit/chainlink/integration-tests/client" "github.com/smartcontractkit/chainlink/integration-tests/contracts" "github.com/smartcontractkit/chainlink/integration-tests/testsetups" + "github.com/smartcontractkit/chainlink/integration-tests/utils" ) func TestOCRBasic(t *testing.T) { @@ -64,7 +64,7 @@ func TestOCRBasic(t *testing.T) { err = actions.StartNewRound(1, ocrInstances, chainClient, l) require.NoError(t, err) - answer, err := ocrInstances[0].GetLatestAnswer(context.Background()) + answer, err := ocrInstances[0].GetLatestAnswer(utils.TestContext(t)) require.NoError(t, err, "Getting latest answer from OCR contract shouldn't fail") require.Equal(t, int64(5), answer.Int64(), "Expected latest answer from OCR contract to be 5 but got %d", answer.Int64()) @@ -73,7 +73,7 @@ func TestOCRBasic(t *testing.T) { err = actions.StartNewRound(2, ocrInstances, chainClient, l) require.NoError(t, err) - answer, err = ocrInstances[0].GetLatestAnswer(context.Background()) + answer, err = ocrInstances[0].GetLatestAnswer(utils.TestContext(t)) require.NoError(t, err, "Error getting latest OCR answer") require.Equal(t, int64(10), answer.Int64(), "Expected latest answer from OCR contract to be 10 but got %d", answer.Int64()) } diff --git a/integration-tests/performance/vrf_test.go b/integration-tests/performance/vrf_test.go index eeaceffaaf5..7a38a454955 100644 --- a/integration-tests/performance/vrf_test.go +++ b/integration-tests/performance/vrf_test.go @@ -1,7 +1,6 @@ package performance import ( - "context" "fmt" "math/big" "strings" @@ -23,6 +22,7 @@ import ( "github.com/smartcontractkit/chainlink/integration-tests/client" "github.com/smartcontractkit/chainlink/integration-tests/contracts" "github.com/smartcontractkit/chainlink/integration-tests/testsetups" + "github.com/smartcontractkit/chainlink/integration-tests/utils" ) func TestVRFBasic(t *testing.T) { @@ -97,7 +97,7 @@ func TestVRFBasic(t *testing.T) { encodedProvingKeys := make([][2]*big.Int, 0) encodedProvingKeys = append(encodedProvingKeys, provingKey) - requestHash, err := coordinator.HashOfKey(context.Background(), encodedProvingKeys[0]) + requestHash, err := coordinator.HashOfKey(utils.TestContext(t), encodedProvingKeys[0]) require.NoError(t, err, "Getting Hash of encoded proving keys shouldn't fail") err = consumer.RequestRandomness(requestHash, big.NewInt(1)) require.NoError(t, err, "Requesting randomness shouldn't fail") @@ -108,7 +108,7 @@ func TestVRFBasic(t *testing.T) { jobRuns, err := chainlinkNodes[0].MustReadRunsByJob(job.Data.ID) g.Expect(err).ShouldNot(gomega.HaveOccurred(), "Job execution shouldn't fail") - out, err := consumer.RandomnessOutput(context.Background()) + out, err := consumer.RandomnessOutput(utils.TestContext(t)) g.Expect(err).ShouldNot(gomega.HaveOccurred(), "Getting the randomness output of the consumer shouldn't fail") // Checks that the job has actually run g.Expect(len(jobRuns.Data)).Should(gomega.BeNumerically(">=", 1), diff --git a/integration-tests/reorg/automation_reorg_test.go b/integration-tests/reorg/automation_reorg_test.go index 888afc21e65..36a2d703e38 100644 --- a/integration-tests/reorg/automation_reorg_test.go +++ b/integration-tests/reorg/automation_reorg_test.go @@ -2,7 +2,6 @@ package reorg //revive:disable:dot-imports import ( - "context" "fmt" "math/big" "testing" @@ -25,6 +24,7 @@ import ( "github.com/smartcontractkit/chainlink/integration-tests/client" "github.com/smartcontractkit/chainlink/integration-tests/contracts" "github.com/smartcontractkit/chainlink/integration-tests/contracts/ethereum" + it_utils "github.com/smartcontractkit/chainlink/integration-tests/utils" ) var ( @@ -211,7 +211,7 @@ func TestAutomationReorg(t *testing.T) { gom.Eventually(func(g gomega.Gomega) { // 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()) + counter, err := consumers[i].Counter(it_utils.TestContext(t)) require.NoError(t, err, "Failed to retrieve consumer counter for upkeep at index %d", i) expect := 5 l.Info().Int64("Upkeeps Performed", counter.Int64()).Int("Upkeep ID", i).Msg("Number of upkeeps performed") @@ -242,7 +242,7 @@ func TestAutomationReorg(t *testing.T) { gom.Eventually(func(g gomega.Gomega) { // Check if the upkeeps are performing multiple times by analyzing their counters and checking they reach 10 for i := 0; i < len(upkeepIDs); i++ { - counter, err := consumers[i].Counter(context.Background()) + counter, err := consumers[i].Counter(it_utils.TestContext(t)) require.NoError(t, err, "Failed to retrieve consumer counter for upkeep at index %d", i) expect := 10 l.Info().Int64("Upkeeps Performed", counter.Int64()).Int("Upkeep ID", i).Msg("Number of upkeeps performed") @@ -259,7 +259,7 @@ func TestAutomationReorg(t *testing.T) { gom.Eventually(func(g gomega.Gomega) { // Check if the upkeeps are performing multiple times by analyzing their counters and checking they reach 20 for i := 0; i < len(upkeepIDs); i++ { - counter, err := consumers[i].Counter(context.Background()) + counter, err := consumers[i].Counter(it_utils.TestContext(t)) require.NoError(t, err, "Failed to retrieve consumer counter for upkeep at index %d", i) expect := 20 l.Info().Int64("Upkeeps Performed", counter.Int64()).Int("Upkeep ID", i).Msg("Number of upkeeps performed") diff --git a/integration-tests/reorg/reorg_test.go b/integration-tests/reorg/reorg_test.go index ba754864b3d..4ada9b95be5 100644 --- a/integration-tests/reorg/reorg_test.go +++ b/integration-tests/reorg/reorg_test.go @@ -1,7 +1,6 @@ package reorg import ( - "context" "fmt" "math/big" "os" @@ -32,6 +31,7 @@ import ( "github.com/smartcontractkit/chainlink/integration-tests/actions" "github.com/smartcontractkit/chainlink/integration-tests/client" "github.com/smartcontractkit/chainlink/integration-tests/contracts" + it_utils "github.com/smartcontractkit/chainlink/integration-tests/utils" ) const ( @@ -222,7 +222,7 @@ func TestDirectRequestReorg(t *testing.T) { gom := gomega.NewGomegaWithT(t) gom.Eventually(func(g gomega.Gomega) { - d, err := consumer.Data(context.Background()) + d, err := consumer.Data(it_utils.TestContext(t)) g.Expect(err).ShouldNot(gomega.HaveOccurred(), "Getting data from consumer contract shouldn't fail") g.Expect(d).ShouldNot(gomega.BeNil(), "Expected the initial on chain data to be nil") log.Debug().Int64("Data", d.Int64()).Msg("Found on chain") diff --git a/integration-tests/smoke/automation_test.go b/integration-tests/smoke/automation_test.go index 349a104697f..190f52caf77 100644 --- a/integration-tests/smoke/automation_test.go +++ b/integration-tests/smoke/automation_test.go @@ -32,7 +32,7 @@ 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" - it_utils "github.com/smartcontractkit/chainlink/integration-tests/utils" + "github.com/smartcontractkit/chainlink/integration-tests/utils" ) var utilsABI = cltypes.MustGetABI(automation_utils_2_1.AutomationUtilsABI) @@ -172,7 +172,7 @@ func SetupAutomationBasic(t *testing.T, nodeUpgrade bool) { gom.Eventually(func(g gomega.Gomega) { // Check if the upkeeps are performing multiple times by analyzing their counters for i := 0; i < len(upkeepIDs); i++ { - counter, err := consumers[i].Counter(context.Background()) + counter, err := consumers[i].Counter(utils.TestContext(t)) require.NoError(t, err, "Failed to retrieve consumer counter for upkeep at index %d", i) expect := 5 l.Info().Int64("Upkeeps Performed", counter.Int64()).Int("Upkeep Index", i).Msg("Number of upkeeps performed") @@ -194,7 +194,7 @@ func SetupAutomationBasic(t *testing.T, nodeUpgrade bool) { gom.Eventually(func(g gomega.Gomega) { // Check if the upkeeps are performing multiple times by analyzing their counters and checking they are increasing by 5 in each step within 5 minutes for i := 0; i < len(upkeepIDs); i++ { - counter, err := consumers[i].Counter(context.Background()) + counter, err := consumers[i].Counter(utils.TestContext(t)) require.NoError(t, err, "Failed to retrieve consumer counter for upkeep at index %d", i) l.Info().Int64("Upkeeps Performed", counter.Int64()).Int("Upkeep ID", i).Msg("Number of upkeeps performed") g.Expect(counter.Int64()).Should(gomega.BeNumerically(">=", int64(expect)), @@ -217,7 +217,7 @@ func SetupAutomationBasic(t *testing.T, nodeUpgrade bool) { for i := 0; i < len(upkeepIDs); i++ { // Obtain the amount of times the upkeep has been executed so far - countersAfterCancellation[i], err = consumers[i].Counter(context.Background()) + countersAfterCancellation[i], err = consumers[i].Counter(utils.TestContext(t)) require.NoError(t, err, "Failed to retrieve consumer counter for upkeep at index %d", i) l.Info().Int64("Upkeep Count", countersAfterCancellation[i].Int64()).Int("Upkeep Index", i).Msg("Cancelled upkeep") } @@ -226,7 +226,7 @@ func SetupAutomationBasic(t *testing.T, nodeUpgrade bool) { gom.Consistently(func(g gomega.Gomega) { for i := 0; i < len(upkeepIDs); i++ { // Expect the counter to remain constant (At most increase by 1 to account for stale performs) because the upkeep was cancelled - latestCounter, err := consumers[i].Counter(context.Background()) + latestCounter, err := consumers[i].Counter(utils.TestContext(t)) g.Expect(err).ShouldNot(gomega.HaveOccurred(), "Failed to retrieve consumer counter for upkeep at index %d", i) g.Expect(latestCounter.Int64()).Should(gomega.BeNumerically("<=", countersAfterCancellation[i].Int64()+1), "Expected consumer counter to remain less than or equal to %d, but got %d", @@ -272,7 +272,7 @@ func TestSetUpkeepTriggerConfig(t *testing.T) { gom.Eventually(func(g gomega.Gomega) { // Check if the upkeeps are performing multiple times by analyzing their counters for i := 0; i < len(upkeepIDs); i++ { - counter, err := consumers[i].Counter(context.Background()) + counter, err := consumers[i].Counter(utils.TestContext(t)) require.NoError(t, err, "Failed to retrieve consumer counter for upkeep at index %d", i) expect := 5 l.Info().Int64("Upkeeps Performed", counter.Int64()).Int("Upkeep Index", i).Msg("Number of upkeeps performed") @@ -329,7 +329,7 @@ func TestSetUpkeepTriggerConfig(t *testing.T) { time.Sleep(10 * time.Second) for i := 0; i < len(upkeepIDs); i++ { // Obtain the amount of times the upkeep has been executed so far - countersAfterSetNoMatch[i], err = consumers[i].Counter(context.Background()) + countersAfterSetNoMatch[i], err = consumers[i].Counter(utils.TestContext(t))) require.NoError(t, err, "Failed to retrieve consumer counter for upkeep at index %d", i) l.Info().Int64("Upkeep Count", countersAfterSetNoMatch[i].Int64()).Int("Upkeep Index", i).Msg("Upkeep") } @@ -339,7 +339,7 @@ func TestSetUpkeepTriggerConfig(t *testing.T) { for i := 0; i < len(upkeepIDs); i++ { // Expect the counter to remain constant (At most increase by 2 to account for stale performs) because the upkeep trigger config is not met bufferCount := int64(2) - latestCounter, err := consumers[i].Counter(context.Background()) + latestCounter, err := consumers[i].Counter(utils.TestContext(t)) g.Expect(err).ShouldNot(gomega.HaveOccurred(), "Failed to retrieve consumer counter for upkeep at index %d", i) g.Expect(latestCounter.Int64()).Should(gomega.BeNumerically("<=", countersAfterSetNoMatch[i].Int64()+bufferCount), "Expected consumer counter to remain less than or equal to %d, but got %d", @@ -375,7 +375,7 @@ func TestSetUpkeepTriggerConfig(t *testing.T) { for i := 0; i < len(upkeepIDs); i++ { // Obtain the amount of times the upkeep has been executed so far - countersAfterSetMatch[i], err = consumers[i].Counter(context.Background()) + countersAfterSetMatch[i], err = consumers[i].Counter(utils.TestContext(t)) require.NoError(t, err, "Failed to retrieve consumer counter for upkeep at index %d", i) l.Info().Int64("Upkeep Count", countersAfterSetMatch[i].Int64()).Int("Upkeep Index", i).Msg("Upkeep") } @@ -394,7 +394,7 @@ func TestSetUpkeepTriggerConfig(t *testing.T) { gom.Eventually(func(g gomega.Gomega) { // Check if the upkeeps are performing multiple times by analyzing their counters for i := 0; i < len(upkeepIDs); i++ { - counter, err := consumers[i].Counter(context.Background()) + counter, err := consumers[i].Counter(utils.TestContext(t)) require.NoError(t, err, "Failed to retrieve consumer counter for upkeep at index %d", i) expect := int64(5) l.Info().Int64("Upkeeps Performed", counter.Int64()).Int("Upkeep Index", i).Msg("Number of upkeeps performed") @@ -425,7 +425,7 @@ func TestAutomationAddFunds(t *testing.T) { gom := gomega.NewGomegaWithT(t) // Since the upkeep is currently underfunded, check that it doesn't get executed gom.Consistently(func(g gomega.Gomega) { - counter, err := consumers[0].Counter(context.Background()) + counter, err := consumers[0].Counter(utils.TestContext(t)) g.Expect(err).ShouldNot(gomega.HaveOccurred(), "Calling consumer's counter shouldn't fail") g.Expect(counter.Int64()).Should(gomega.Equal(int64(0)), "Expected consumer counter to remain zero, but got %d", counter.Int64()) @@ -445,7 +445,7 @@ func TestAutomationAddFunds(t *testing.T) { // Now the new upkeep should be performing because we added enough funds gom.Eventually(func(g gomega.Gomega) { - counter, err := consumers[0].Counter(context.Background()) + counter, err := consumers[0].Counter(utils.TestContext(t)) g.Expect(err).ShouldNot(gomega.HaveOccurred(), "Calling consumer's counter shouldn't fail") g.Expect(counter.Int64()).Should(gomega.BeNumerically(">", int64(0)), "Expected newly registered upkeep's counter to be greater than 0, but got %d", counter.Int64()) @@ -477,7 +477,7 @@ func TestAutomationPauseUnPause(t *testing.T) { gom.Eventually(func(g gomega.Gomega) { // 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()) + counter, err := consumers[i].Counter(utils.TestContext(t)) g.Expect(err).ShouldNot(gomega.HaveOccurred(), "Failed to retrieve consumer counter for upkeep at index %d", i) g.Expect(counter.Int64()).Should(gomega.BeNumerically(">", int64(5)), "Expected consumer counter to be greater than 5, but got %d", counter.Int64()) @@ -497,7 +497,7 @@ func TestAutomationPauseUnPause(t *testing.T) { var countersAfterPause = make([]*big.Int, len(upkeepIDs)) for i := 0; i < len(upkeepIDs); i++ { // Obtain the amount of times the upkeep has been executed so far - countersAfterPause[i], err = consumers[i].Counter(context.Background()) + countersAfterPause[i], err = consumers[i].Counter(utils.TestContext(t)) require.NoError(t, err, "Failed to retrieve consumer counter for upkeep at index %d", i) l.Info().Int("Upkeep Index", i).Int64("Upkeeps Performed", countersAfterPause[i].Int64()).Msg("Paused Upkeep") } @@ -506,7 +506,7 @@ func TestAutomationPauseUnPause(t *testing.T) { for i := 0; i < len(upkeepIDs); i++ { // In most cases counters should remain constant, but there might be a straggling perform tx which // gets committed later and increases counter by 1 - latestCounter, err := consumers[i].Counter(context.Background()) + latestCounter, err := consumers[i].Counter(utils.TestContext(t)) g.Expect(err).ShouldNot(gomega.HaveOccurred(), "Failed to retrieve consumer counter for upkeep at index %d", i) g.Expect(latestCounter.Int64()).Should(gomega.BeNumerically("<=", countersAfterPause[i].Int64()+1), "Expected consumer counter not have increased more than %d, but got %d", @@ -526,7 +526,7 @@ func TestAutomationPauseUnPause(t *testing.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 + numbers of performing before pause for i := 0; i < len(upkeepIDs); i++ { - counter, err := consumers[i].Counter(context.Background()) + counter, err := consumers[i].Counter(utils.TestContext(t)) g.Expect(err).ShouldNot(gomega.HaveOccurred(), "Failed to retrieve consumer counter for upkeep at index %d", i) g.Expect(counter.Int64()).Should(gomega.BeNumerically(">", countersAfterPause[i].Int64()+1), "Expected consumer counter to be greater than %d, but got %d", countersAfterPause[i].Int64()+1, counter.Int64()) @@ -562,7 +562,7 @@ func TestAutomationRegisterUpkeep(t *testing.T) { // store the value of their initial counters in order to compare later on that the value increased. gom.Eventually(func(g gomega.Gomega) { for i := 0; i < len(upkeepIDs); i++ { - counter, err := consumers[i].Counter(context.Background()) + counter, err := consumers[i].Counter(utils.TestContext(t)) initialCounters[i] = counter g.Expect(err).ShouldNot(gomega.HaveOccurred(), "Failed to retrieve consumer counter for upkeep at index %d", i) g.Expect(counter.Int64()).Should(gomega.BeNumerically(">", int64(0)), @@ -582,7 +582,7 @@ func TestAutomationRegisterUpkeep(t *testing.T) { // Test that the newly registered upkeep is also performing. gom.Eventually(func(g gomega.Gomega) { - counter, err := newUpkeep.Counter(context.Background()) + counter, err := newUpkeep.Counter(utils.TestContext(t)) g.Expect(err).ShouldNot(gomega.HaveOccurred(), "Calling newly deployed upkeep's counter shouldn't fail") g.Expect(counter.Int64()).Should(gomega.BeNumerically(">", int64(0)), "Expected newly registered upkeep's counter to be greater than 0, but got %d", counter.Int64()) @@ -591,7 +591,7 @@ func TestAutomationRegisterUpkeep(t *testing.T) { gom.Eventually(func(g gomega.Gomega) { for i := 0; i < len(upkeepIDs); i++ { - currentCounter, err := consumers[i].Counter(context.Background()) + currentCounter, err := consumers[i].Counter(utils.TestContext(t)) g.Expect(err).ShouldNot(gomega.HaveOccurred(), "Calling consumer's counter shouldn't fail") l.Info(). @@ -631,7 +631,7 @@ func TestAutomationPauseRegistry(t *testing.T) { // Observe that the upkeeps which are initially registered are performing gom.Eventually(func(g gomega.Gomega) { for i := 0; i < len(upkeepIDs); i++ { - counter, err := consumers[i].Counter(context.Background()) + counter, err := consumers[i].Counter(utils.TestContext(t)) g.Expect(err).ShouldNot(gomega.HaveOccurred(), "Failed to retrieve consumer counter for upkeep at index %d", i) g.Expect(counter.Int64()).Should(gomega.BeNumerically(">", int64(0)), "Expected consumer counter to be greater than 0, but got %d") @@ -647,7 +647,7 @@ func TestAutomationPauseRegistry(t *testing.T) { // Store how many times each upkeep performed once the registry was successfully paused var countersAfterPause = make([]*big.Int, len(upkeepIDs)) for i := 0; i < len(upkeepIDs); i++ { - countersAfterPause[i], err = consumers[i].Counter(context.Background()) + countersAfterPause[i], err = consumers[i].Counter(utils.TestContext(t)) require.NoError(t, err, "Failed to retrieve consumer counter for upkeep at index %d", i) } @@ -655,7 +655,7 @@ func TestAutomationPauseRegistry(t *testing.T) { // because they are no longer getting serviced gom.Consistently(func(g gomega.Gomega) { for i := 0; i < len(upkeepIDs); i++ { - latestCounter, err := consumers[i].Counter(context.Background()) + latestCounter, err := consumers[i].Counter(utils.TestContext(t)) g.Expect(err).ShouldNot(gomega.HaveOccurred(), "Failed to retrieve consumer counter for upkeep at index %d", i) g.Expect(latestCounter.Int64()).Should(gomega.Equal(countersAfterPause[i].Int64()), "Expected consumer counter to remain constant at %d, but got %d", @@ -692,7 +692,7 @@ func TestAutomationKeeperNodesDown(t *testing.T) { // Watch upkeeps being performed and store their counters in order to compare them later in the test gom.Eventually(func(g gomega.Gomega) { for i := 0; i < len(upkeepIDs); i++ { - counter, err := consumers[i].Counter(context.Background()) + counter, err := consumers[i].Counter(utils.TestContext(t)) initialCounters[i] = counter g.Expect(err).ShouldNot(gomega.HaveOccurred(), "Failed to retrieve consumer counter for upkeep at index %d", i) g.Expect(counter.Int64()).Should(gomega.BeNumerically(">", int64(0)), @@ -711,7 +711,7 @@ func TestAutomationKeeperNodesDown(t *testing.T) { // Assert that upkeeps are still performed and their counters have increased gom.Eventually(func(g gomega.Gomega) { for i := 0; i < len(upkeepIDs); i++ { - currentCounter, err := consumers[i].Counter(context.Background()) + currentCounter, err := consumers[i].Counter(utils.TestContext(t)) g.Expect(err).ShouldNot(gomega.HaveOccurred(), "Failed to retrieve consumer counter for upkeep at index %d", i) g.Expect(currentCounter.Int64()).Should(gomega.BeNumerically(">", initialCounters[i].Int64()), "Expected counter to have increased from initial value of %s, but got %s", @@ -732,7 +732,7 @@ func TestAutomationKeeperNodesDown(t *testing.T) { // See how many times each upkeep was executed var countersAfterNoMoreNodes = make([]*big.Int, len(upkeepIDs)) for i := 0; i < len(upkeepIDs); i++ { - countersAfterNoMoreNodes[i], err = consumers[i].Counter(context.Background()) + countersAfterNoMoreNodes[i], err = consumers[i].Counter(utils.TestContext(t)) require.NoError(t, err, "Failed to retrieve consumer counter for upkeep at index %d", i) l.Info().Int("Upkeep Index", i).Int64("Performed", countersAfterNoMoreNodes[i].Int64()).Msg("Upkeeps Performed") } @@ -741,7 +741,7 @@ func TestAutomationKeeperNodesDown(t *testing.T) { // all the nodes were taken down gom.Consistently(func(g gomega.Gomega) { for i := 0; i < len(upkeepIDs); i++ { - latestCounter, err := consumers[i].Counter(context.Background()) + latestCounter, err := consumers[i].Counter(utils.TestContext(t)) g.Expect(err).ShouldNot(gomega.HaveOccurred(), "Failed to retrieve consumer counter for upkeep at index %d", i) g.Expect(latestCounter.Int64()).Should(gomega.BeNumerically("<=", countersAfterNoMoreNodes[i].Int64()+1), "Expected consumer counter to not have increased more than %d, but got %d", @@ -790,7 +790,7 @@ func TestAutomationPerformSimulation(t *testing.T) { // Initially performGas is set high, so performUpkeep reverts and no upkeep should be performed gom.Consistently(func(g gomega.Gomega) { // Consumer count should remain at 0 - cnt, err := consumerPerformance.GetUpkeepCount(context.Background()) + cnt, err := consumerPerformance.GetUpkeepCount(utils.TestContext(t)) g.Expect(err).ShouldNot(gomega.HaveOccurred(), "Calling consumer's Counter shouldn't fail") g.Expect(cnt.Int64()).Should(gomega.Equal(int64(0)), "Expected consumer counter to remain constant at %d, but got %d", 0, cnt.Int64(), @@ -798,14 +798,14 @@ func TestAutomationPerformSimulation(t *testing.T) { }, "2m", "1s").Should(gomega.Succeed()) // ~1m for setup, 1m assertion // Set performGas on consumer to be low, so that performUpkeep starts becoming successful - err := consumerPerformance.SetPerformGasToBurn(context.Background(), big.NewInt(100000)) + err := consumerPerformance.SetPerformGasToBurn(utils.TestContext(t), big.NewInt(100000)) require.NoError(t, err, "Perform gas should be set successfully on consumer") err = chainClient.WaitForEvents() require.NoError(t, err, "Error waiting for set perform gas tx") // Upkeep should now start performing gom.Eventually(func(g gomega.Gomega) { - cnt, err := consumerPerformance.GetUpkeepCount(context.Background()) + cnt, err := consumerPerformance.GetUpkeepCount(utils.TestContext(t)) g.Expect(err).ShouldNot(gomega.HaveOccurred(), "Calling consumer's Counter shouldn't fail") g.Expect(cnt.Int64()).Should(gomega.BeNumerically(">", int64(0)), "Expected consumer counter to be greater than 0, but got %d", cnt.Int64(), @@ -855,7 +855,7 @@ func TestAutomationCheckPerformGasLimit(t *testing.T) { // Initially performGas is set higher than defaultUpkeepGasLimit, so no upkeep should be performed gom.Consistently(func(g gomega.Gomega) { - cnt, err := consumerPerformance.GetUpkeepCount(context.Background()) + cnt, err := consumerPerformance.GetUpkeepCount(utils.TestContext(t)) g.Expect(err).ShouldNot(gomega.HaveOccurred(), "Calling consumer's counter shouldn't fail") g.Expect(cnt.Int64()).Should( gomega.Equal(int64(0)), @@ -871,7 +871,7 @@ func TestAutomationCheckPerformGasLimit(t *testing.T) { // Upkeep should now start performing gom.Eventually(func(g gomega.Gomega) { - cnt, err := consumerPerformance.GetUpkeepCount(context.Background()) + cnt, err := consumerPerformance.GetUpkeepCount(utils.TestContext(t)) g.Expect(err).ShouldNot(gomega.HaveOccurred(), "Calling consumer's counter shouldn't fail") g.Expect(cnt.Int64()).Should(gomega.BeNumerically(">", int64(0)), "Expected consumer counter to be greater than 0, but got %d", cnt.Int64(), @@ -879,19 +879,19 @@ func TestAutomationCheckPerformGasLimit(t *testing.T) { }, "2m", "1s").Should(gomega.Succeed()) // ~1m to perform once, 1m buffer // Now increase the checkGasBurn on consumer, upkeep should stop performing - err = consumerPerformance.SetCheckGasToBurn(context.Background(), big.NewInt(3000000)) + err = consumerPerformance.SetCheckGasToBurn(utils.TestContext(t), big.NewInt(3000000)) require.NoError(t, err, "Check gas burn should be set successfully on consumer") err = chainClient.WaitForEvents() require.NoError(t, err, "Error waiting for SetCheckGasToBurn tx") // Get existing performed count - existingCnt, err := consumerPerformance.GetUpkeepCount(context.Background()) + existingCnt, err := consumerPerformance.GetUpkeepCount(utils.TestContext(t)) require.NoError(t, err, "Calling consumer's counter shouldn't fail") l.Info().Int64("Upkeep counter", existingCnt.Int64()).Msg("Upkeep counter when check gas increased") // In most cases count should remain constant, but it might increase by upto 1 due to pending perform gom.Consistently(func(g gomega.Gomega) { - cnt, err := consumerPerformance.GetUpkeepCount(context.Background()) + cnt, err := consumerPerformance.GetUpkeepCount(utils.TestContext(t)) g.Expect(err).ShouldNot(gomega.HaveOccurred(), "Calling consumer's counter shouldn't fail") g.Expect(cnt.Int64()).Should( gomega.BeNumerically("<=", existingCnt.Int64()+1), @@ -899,7 +899,7 @@ func TestAutomationCheckPerformGasLimit(t *testing.T) { ) }, "1m", "1s").Should(gomega.Succeed()) - existingCnt, err = consumerPerformance.GetUpkeepCount(context.Background()) + existingCnt, err = consumerPerformance.GetUpkeepCount(utils.TestContext(t)) require.NoError(t, err, "Calling consumer's counter shouldn't fail") existingCntInt := existingCnt.Int64() l.Info().Int64("Upkeep counter", existingCntInt).Msg("Upkeep counter when consistently block finished") @@ -919,7 +919,7 @@ func TestAutomationCheckPerformGasLimit(t *testing.T) { // Upkeep should start performing again, and it should get regularly performed gom.Eventually(func(g gomega.Gomega) { - cnt, err := consumerPerformance.GetUpkeepCount(context.Background()) + cnt, err := consumerPerformance.GetUpkeepCount(utils.TestContext(t)) g.Expect(err).ShouldNot(gomega.HaveOccurred(), "Calling consumer's Counter shouldn't fail") g.Expect(cnt.Int64()).Should(gomega.BeNumerically(">", existingCntInt), "Expected consumer counter to be greater than %d, but got %d", existingCntInt, cnt.Int64(), @@ -963,7 +963,7 @@ func TestUpdateCheckData(t *testing.T) { gom.Consistently(func(g gomega.Gomega) { // expect the counter to remain 0 because perform data does not match for i := 0; i < len(upkeepIDs); i++ { - counter, err := performDataChecker[i].Counter(context.Background()) + counter, err := performDataChecker[i].Counter(utils.TestContext(t)) g.Expect(err).ShouldNot(gomega.HaveOccurred(), "Failed to retrieve perform data checker"+ " for upkeep at index "+strconv.Itoa(i)) g.Expect(counter.Int64()).Should(gomega.Equal(int64(0)), @@ -982,7 +982,7 @@ func TestUpdateCheckData(t *testing.T) { // retrieve new check data for all upkeeps for i := 0; i < len(upkeepIDs); i++ { - upkeep, err := registry.GetUpkeepInfo(context.Background(), upkeepIDs[i]) + upkeep, err := registry.GetUpkeepInfo(utils.TestContext(t), upkeepIDs[i]) require.NoError(t, err, "Failed to get upkeep info at index %d", i) require.Equal(t, []byte(automationExpectedData), upkeep.CheckData, "Upkeep data not as expected") } @@ -990,7 +990,7 @@ func TestUpdateCheckData(t *testing.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 for i := 0; i < len(upkeepIDs); i++ { - counter, err := performDataChecker[i].Counter(context.Background()) + counter, err := performDataChecker[i].Counter(utils.TestContext(t)) g.Expect(err).ShouldNot(gomega.HaveOccurred(), "Failed to retrieve perform data checker counter"+ " for upkeep at index "+strconv.Itoa(i)) g.Expect(counter.Int64()).Should(gomega.BeNumerically(">", int64(0)), diff --git a/integration-tests/smoke/flux_test.go b/integration-tests/smoke/flux_test.go index 8c2b3638bff..2997ff1c74a 100644 --- a/integration-tests/smoke/flux_test.go +++ b/integration-tests/smoke/flux_test.go @@ -1,7 +1,6 @@ package smoke import ( - "context" "fmt" "math/big" "net/http" @@ -19,6 +18,7 @@ import ( "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/smartcontractkit/chainlink/integration-tests/utils" ) func TestFluxBasic(t *testing.T) { @@ -74,7 +74,7 @@ func TestFluxBasic(t *testing.T) { err = env.EVMClient.WaitForEvents() require.NoError(t, err, "Waiting for event subscriptions in nodes shouldn't fail") - oracles, err := fluxInstance.GetOracles(context.Background()) + oracles, err := fluxInstance.GetOracles(utils.TestContext(t)) require.NoError(t, err, "Getting oracle details from the Flux aggregator contract shouldn't fail") l.Info().Str("Oracles", strings.Join(oracles, ",")).Msg("Oracles set") @@ -108,7 +108,7 @@ func TestFluxBasic(t *testing.T) { env.EVMClient.AddHeaderEventSubscription(fluxInstance.Address(), fluxRound) err = env.EVMClient.WaitForEvents() require.NoError(t, err, "Waiting for event subscriptions in nodes shouldn't fail") - data, err := fluxInstance.GetContractData(context.Background()) + data, err := fluxInstance.GetContractData(utils.TestContext(t)) require.NoError(t, err, "Getting contract data from flux aggregator contract shouldn't fail") require.Equal(t, int64(1e5), data.LatestRoundData.Answer.Int64(), "Expected latest round answer to be %d, but found %d", int64(1e5), data.LatestRoundData.Answer.Int64()) @@ -127,7 +127,7 @@ func TestFluxBasic(t *testing.T) { require.NoError(t, err, "Setting value path in mock server shouldn't fail") err = env.EVMClient.WaitForEvents() require.NoError(t, err, "Waiting for event subscriptions in nodes shouldn't fail") - data, err = fluxInstance.GetContractData(context.Background()) + data, err = fluxInstance.GetContractData(utils.TestContext(t)) require.NoError(t, err, "Getting contract data from flux aggregator contract shouldn't fail") require.Equal(t, int64(1e10), data.LatestRoundData.Answer.Int64(), "Expected latest round answer to be %d, but found %d", int64(1e10), data.LatestRoundData.Answer.Int64()) @@ -140,7 +140,7 @@ func TestFluxBasic(t *testing.T) { l.Info().Interface("data", data).Msg("Round data") for _, oracleAddr := range nodeAddresses { - payment, _ := fluxInstance.WithdrawablePayment(context.Background(), oracleAddr) + payment, _ := fluxInstance.WithdrawablePayment(utils.TestContext(t), oracleAddr) require.Equal(t, int64(2), payment.Int64(), "Expected flux aggregator contract's withdrawable payment to be %d, but found %d", int64(2), payment.Int64()) } diff --git a/integration-tests/smoke/forwarder_ocr_test.go b/integration-tests/smoke/forwarder_ocr_test.go index 727b83a601a..7203e031780 100644 --- a/integration-tests/smoke/forwarder_ocr_test.go +++ b/integration-tests/smoke/forwarder_ocr_test.go @@ -1,7 +1,6 @@ package smoke import ( - "context" "math/big" "testing" @@ -12,6 +11,7 @@ import ( "github.com/smartcontractkit/chainlink/integration-tests/actions" "github.com/smartcontractkit/chainlink/integration-tests/docker/test_env" + "github.com/smartcontractkit/chainlink/integration-tests/utils" ) func TestForwarderOCRBasic(t *testing.T) { @@ -72,7 +72,7 @@ func TestForwarderOCRBasic(t *testing.T) { err = env.EVMClient.WaitForEvents() require.NoError(t, err, "Error waiting for events") - answer, err := ocrInstances[0].GetLatestAnswer(context.Background()) + answer, err := ocrInstances[0].GetLatestAnswer(utils.TestContext(t)) require.NoError(t, err, "Getting latest answer from OCR contract shouldn't fail") require.Equal(t, int64(5), answer.Int64(), "Expected latest answer from OCR contract to be 5 but got %d", answer.Int64()) @@ -83,7 +83,7 @@ func TestForwarderOCRBasic(t *testing.T) { err = env.EVMClient.WaitForEvents() require.NoError(t, err, "Error waiting for events") - answer, err = ocrInstances[0].GetLatestAnswer(context.Background()) + answer, err = ocrInstances[0].GetLatestAnswer(utils.TestContext(t)) require.NoError(t, err, "Error getting latest OCR answer") require.Equal(t, int64(10), answer.Int64(), "Expected latest answer from OCR contract to be 10 but got %d", answer.Int64()) } diff --git a/integration-tests/smoke/forwarders_ocr2_test.go b/integration-tests/smoke/forwarders_ocr2_test.go index baa5a781f6b..be87eb56292 100644 --- a/integration-tests/smoke/forwarders_ocr2_test.go +++ b/integration-tests/smoke/forwarders_ocr2_test.go @@ -1,7 +1,6 @@ package smoke import ( - "context" "fmt" "math/big" "net/http" @@ -17,6 +16,7 @@ import ( "github.com/smartcontractkit/chainlink/integration-tests/contracts" "github.com/smartcontractkit/chainlink/integration-tests/docker/test_env" "github.com/smartcontractkit/chainlink/integration-tests/types/config/node" + "github.com/smartcontractkit/chainlink/integration-tests/utils" ) func TestForwarderOCR2Basic(t *testing.T) { @@ -92,7 +92,7 @@ func TestForwarderOCR2Basic(t *testing.T) { err = actions.StartNewOCR2Round(1, ocrInstances, env.EVMClient, time.Minute*10, l) require.NoError(t, err) - answer, err := ocrInstances[0].GetLatestAnswer(context.Background()) + answer, err := ocrInstances[0].GetLatestAnswer(utils.TestContext(t)) require.NoError(t, err, "Getting latest answer from OCRv2 contract shouldn't fail") require.Equal(t, int64(5), answer.Int64(), "Expected latest answer from OCRw contract to be 5 but got %d", answer.Int64()) @@ -103,7 +103,7 @@ func TestForwarderOCR2Basic(t *testing.T) { err = actions.StartNewOCR2Round(int64(i), ocrInstances, env.EVMClient, time.Minute*10, l) require.NoError(t, err) - answer, err = ocrInstances[0].GetLatestAnswer(context.Background()) + answer, err = ocrInstances[0].GetLatestAnswer(utils.TestContext(t)) require.NoError(t, err, "Error getting latest OCRv2 answer") require.Equal(t, int64(ocrRoundVal), answer.Int64(), fmt.Sprintf("Expected latest answer from OCRv2 contract to be %d but got %d", ocrRoundVal, answer.Int64())) } diff --git a/integration-tests/smoke/keeper_test.go b/integration-tests/smoke/keeper_test.go index d42944fd558..b28ab1ff101 100644 --- a/integration-tests/smoke/keeper_test.go +++ b/integration-tests/smoke/keeper_test.go @@ -1,7 +1,6 @@ package smoke import ( - "context" "fmt" "math/big" "strconv" @@ -23,6 +22,7 @@ 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/integration-tests/utils" ) const ( @@ -109,7 +109,7 @@ func TestKeeperBasicSmoke(t *testing.T) { gom.Eventually(func(g gomega.Gomega) error { // 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()) + counter, err := consumers[i].Counter(utils.TestContext(t)) g.Expect(err).ShouldNot(gomega.HaveOccurred(), "Failed to retrieve consumer counter for upkeep at index %d", i) g.Expect(counter.Int64()).Should(gomega.BeNumerically(">", int64(10)), "Expected consumer counter to be greater than 10, but got %d", counter.Int64()) @@ -131,7 +131,7 @@ func TestKeeperBasicSmoke(t *testing.T) { for i := 0; i < len(upkeepIDs); i++ { // Obtain the amount of times the upkeep has been executed so far - countersAfterCancellation[i], err = consumers[i].Counter(context.Background()) + countersAfterCancellation[i], err = consumers[i].Counter(utils.TestContext(t)) require.NoError(t, err, "Failed to retrieve consumer counter for upkeep at index %d", i) l.Info().Int("Index", i).Int64("Upkeeps Performed", countersAfterCancellation[i].Int64()).Msg("Cancelled Upkeep") } @@ -139,7 +139,7 @@ func TestKeeperBasicSmoke(t *testing.T) { gom.Consistently(func(g gomega.Gomega) { for i := 0; i < len(upkeepIDs); i++ { // Expect the counter to remain constant because the upkeep was cancelled, so it shouldn't increase anymore - latestCounter, err := consumers[i].Counter(context.Background()) + latestCounter, err := consumers[i].Counter(utils.TestContext(t)) g.Expect(err).ShouldNot(gomega.HaveOccurred(), "Failed to retrieve consumer counter for upkeep at index %d", i) g.Expect(latestCounter.Int64()).Should(gomega.Equal(countersAfterCancellation[i].Int64()), "Expected consumer counter to remain constant at %d, but got %d", @@ -187,11 +187,11 @@ func TestKeeperBlockCountPerTurn(t *testing.T) { // Wait for upkeep to be performed twice by different keepers (buddies) gom.Eventually(func(g gomega.Gomega) error { - counter, err := consumers[0].Counter(context.Background()) + counter, err := consumers[0].Counter(utils.TestContext(t)) g.Expect(err).ShouldNot(gomega.HaveOccurred(), "Calling consumer's counter shouldn't fail") l.Info().Int64("Upkeep counter", counter.Int64()).Msg("Number of upkeeps performed") - upkeepInfo, err := registry.GetUpkeepInfo(context.Background(), upkeepID) + upkeepInfo, err := registry.GetUpkeepInfo(utils.TestContext(t), upkeepID) g.Expect(err).ShouldNot(gomega.HaveOccurred(), "Registry's getUpkeep shouldn't fail") latestKeeper := upkeepInfo.LastKeeper @@ -205,7 +205,7 @@ func TestKeeperBlockCountPerTurn(t *testing.T) { }, "1m", "1s").Should(gomega.Succeed()) gom.Eventually(func(g gomega.Gomega) error { - upkeepInfo, err := registry.GetUpkeepInfo(context.Background(), upkeepID) + upkeepInfo, err := registry.GetUpkeepInfo(utils.TestContext(t), upkeepID) g.Expect(err).ShouldNot(gomega.HaveOccurred(), "Registry's getUpkeep shouldn't fail") latestKeeper := upkeepInfo.LastKeeper @@ -219,7 +219,7 @@ func TestKeeperBlockCountPerTurn(t *testing.T) { // Expect no new keepers to perform for a while gom.Consistently(func(g gomega.Gomega) { - upkeepInfo, err := registry.GetUpkeepInfo(context.Background(), upkeepID) + upkeepInfo, err := registry.GetUpkeepInfo(utils.TestContext(t), upkeepID) g.Expect(err).ShouldNot(gomega.HaveOccurred(), "Registry's getUpkeep shouldn't fail") latestKeeper := upkeepInfo.LastKeeper @@ -235,11 +235,11 @@ func TestKeeperBlockCountPerTurn(t *testing.T) { // Expect a new keeper to perform gom.Eventually(func(g gomega.Gomega) error { - counter, err := consumers[0].Counter(context.Background()) + counter, err := consumers[0].Counter(utils.TestContext(t)) g.Expect(err).ShouldNot(gomega.HaveOccurred(), "Calling consumer's counter shouldn't fail") l.Info().Int64("Upkeep counter", counter.Int64()).Msg("Num upkeeps performed") - upkeepInfo, err := registry.GetUpkeepInfo(context.Background(), upkeepID) + upkeepInfo, err := registry.GetUpkeepInfo(utils.TestContext(t), upkeepID) g.Expect(err).ShouldNot(gomega.HaveOccurred(), "Registry's getUpkeep shouldn't fail") latestKeeper := upkeepInfo.LastKeeper @@ -296,7 +296,7 @@ func TestKeeperSimulation(t *testing.T) { // Initially performGas is set high, so performUpkeep reverts and no upkeep should be performed gom.Consistently(func(g gomega.Gomega) { // Consumer count should remain at 0 - cnt, err := consumerPerformance.GetUpkeepCount(context.Background()) + cnt, err := consumerPerformance.GetUpkeepCount(utils.TestContext(t)) g.Expect(err).ShouldNot(gomega.HaveOccurred(), "Calling consumer's Counter shouldn't fail") g.Expect(cnt.Int64()).Should( gomega.Equal(int64(0)), @@ -304,20 +304,20 @@ func TestKeeperSimulation(t *testing.T) { ) // Not even reverted upkeeps should be performed. Last keeper for the upkeep should be 0 address - upkeepInfo, err := registry.GetUpkeepInfo(context.Background(), upkeepID) + upkeepInfo, err := registry.GetUpkeepInfo(utils.TestContext(t), upkeepID) g.Expect(err).ShouldNot(gomega.HaveOccurred(), "Registry's getUpkeep shouldn't fail") g.Expect(upkeepInfo.LastKeeper).Should(gomega.Equal(actions.ZeroAddress.String()), "Last keeper should be zero address") }, "1m", "1s").Should(gomega.Succeed()) // Set performGas on consumer to be low, so that performUpkeep starts becoming successful - err = consumerPerformance.SetPerformGasToBurn(context.Background(), big.NewInt(100000)) + err = consumerPerformance.SetPerformGasToBurn(utils.TestContext(t), big.NewInt(100000)) require.NoError(t, err, "Error setting PerformGasToBurn") err = chainClient.WaitForEvents() require.NoError(t, err, "Error waiting to set PerformGasToBurn") // Upkeep should now start performing gom.Eventually(func(g gomega.Gomega) error { - cnt, err := consumerPerformance.GetUpkeepCount(context.Background()) + cnt, err := consumerPerformance.GetUpkeepCount(utils.TestContext(t)) g.Expect(err).ShouldNot(gomega.HaveOccurred(), "Calling consumer's Counter shouldn't fail") g.Expect(cnt.Int64()).Should(gomega.BeNumerically(">", int64(0)), "Expected consumer counter to be greater than 0, but got %d", cnt.Int64(), @@ -368,7 +368,7 @@ func TestKeeperCheckPerformGasLimit(t *testing.T) { // Initially performGas is set higher than defaultUpkeepGasLimit, so no upkeep should be performed gom.Consistently(func(g gomega.Gomega) { - cnt, err := consumerPerformance.GetUpkeepCount(context.Background()) + cnt, err := consumerPerformance.GetUpkeepCount(utils.TestContext(t)) g.Expect(err).ShouldNot(gomega.HaveOccurred(), "Calling consumer's counter shouldn't fail") g.Expect(cnt.Int64()).Should( gomega.Equal(int64(0)), @@ -384,7 +384,7 @@ func TestKeeperCheckPerformGasLimit(t *testing.T) { // Upkeep should now start performing gom.Eventually(func(g gomega.Gomega) error { - cnt, err := consumerPerformance.GetUpkeepCount(context.Background()) + cnt, err := consumerPerformance.GetUpkeepCount(utils.TestContext(t)) g.Expect(err).ShouldNot(gomega.HaveOccurred(), "Calling consumer's counter shouldn't fail") g.Expect(cnt.Int64()).Should(gomega.BeNumerically(">", int64(0)), "Expected consumer counter to be greater than 0, but got %d", cnt.Int64(), @@ -393,13 +393,13 @@ func TestKeeperCheckPerformGasLimit(t *testing.T) { }, "1m", "1s").Should(gomega.Succeed()) // Now increase the checkGasBurn on consumer, upkeep should stop performing - err = consumerPerformance.SetCheckGasToBurn(context.Background(), big.NewInt(3000000)) + err = consumerPerformance.SetCheckGasToBurn(utils.TestContext(t), big.NewInt(3000000)) require.NoError(t, err, "Error setting CheckGasToBurn") err = chainClient.WaitForEvents() require.NoError(t, err, "Error waiting for SetCheckGasToBurn tx") // Get existing performed count - existingCnt, err := consumerPerformance.GetUpkeepCount(context.Background()) + existingCnt, err := consumerPerformance.GetUpkeepCount(utils.TestContext(t)) require.NoError(t, err, "Error calling consumer's counter") l.Info().Int64("Upkeep counter", existingCnt.Int64()).Msg("Check Gas Increased") @@ -407,7 +407,7 @@ func TestKeeperCheckPerformGasLimit(t *testing.T) { // gets committed later. Since every keeper node cannot have more than 1 straggling tx, it // is sufficient to check that the upkeep count does not increase by more than 6. gom.Consistently(func(g gomega.Gomega) { - cnt, err := consumerPerformance.GetUpkeepCount(context.Background()) + cnt, err := consumerPerformance.GetUpkeepCount(utils.TestContext(t)) g.Expect(err).ShouldNot(gomega.HaveOccurred(), "Calling consumer's counter shouldn't fail") g.Expect(cnt.Int64()).Should( gomega.BeNumerically("<=", existingCnt.Int64()+numUpkeepsAllowedForStragglingTxs), @@ -415,7 +415,7 @@ func TestKeeperCheckPerformGasLimit(t *testing.T) { ) }, "3m", "1s").Should(gomega.Succeed()) - existingCnt, err = consumerPerformance.GetUpkeepCount(context.Background()) + existingCnt, err = consumerPerformance.GetUpkeepCount(utils.TestContext(t)) require.NoError(t, err, "Error calling consumer's counter") existingCntInt := existingCnt.Int64() l.Info().Int64("Upkeep counter", existingCntInt).Msg("Upkeep counter when consistently block finished") @@ -430,7 +430,7 @@ func TestKeeperCheckPerformGasLimit(t *testing.T) { // Upkeep should start performing again, and it should get regularly performed gom.Eventually(func(g gomega.Gomega) { - cnt, err := consumerPerformance.GetUpkeepCount(context.Background()) + cnt, err := consumerPerformance.GetUpkeepCount(utils.TestContext(t)) g.Expect(err).ShouldNot(gomega.HaveOccurred(), "Calling consumer's Counter shouldn't fail") g.Expect(cnt.Int64()).Should(gomega.BeNumerically(">", existingCntInt), "Expected consumer counter to be greater than %d, but got %d", existingCntInt, cnt.Int64(), @@ -478,7 +478,7 @@ func TestKeeperRegisterUpkeep(t *testing.T) { // store the value of their initial counters in order to compare later on that the value increased. gom.Eventually(func(g gomega.Gomega) error { for i := 0; i < len(upkeepIDs); i++ { - counter, err := consumers[i].Counter(context.Background()) + counter, err := consumers[i].Counter(utils.TestContext(t)) initialCounters[i] = counter g.Expect(err).ShouldNot(gomega.HaveOccurred(), "Failed to retrieve consumer counter"+ " for upkeep at index "+strconv.Itoa(i)) @@ -500,7 +500,7 @@ func TestKeeperRegisterUpkeep(t *testing.T) { // Test that the newly registered upkeep is also performing. gom.Eventually(func(g gomega.Gomega) error { - counter, err := newUpkeep.Counter(context.Background()) + counter, err := newUpkeep.Counter(utils.TestContext(t)) g.Expect(err).ShouldNot(gomega.HaveOccurred(), "Calling newly deployed upkeep's counter shouldn't fail") g.Expect(counter.Int64()).Should(gomega.BeNumerically(">", int64(0)), "Expected newly registered upkeep's counter to be greater than 0, but got %d", counter.Int64()) @@ -510,7 +510,7 @@ func TestKeeperRegisterUpkeep(t *testing.T) { gom.Eventually(func(g gomega.Gomega) error { for i := 0; i < len(upkeepIDs); i++ { - currentCounter, err := consumers[i].Counter(context.Background()) + currentCounter, err := consumers[i].Counter(utils.TestContext(t)) g.Expect(err).ShouldNot(gomega.HaveOccurred(), "Calling consumer's counter shouldn't fail") l.Info(). @@ -563,7 +563,7 @@ func TestKeeperAddFunds(t *testing.T) { // Since the upkeep is currently underfunded, check that it doesn't get executed gom.Consistently(func(g gomega.Gomega) { - counter, err := consumers[0].Counter(context.Background()) + counter, err := consumers[0].Counter(utils.TestContext(t)) g.Expect(err).ShouldNot(gomega.HaveOccurred(), "Calling consumer's counter shouldn't fail") g.Expect(counter.Int64()).Should(gomega.Equal(int64(0)), "Expected consumer counter to remain zero, but got %d", counter.Int64()) @@ -583,7 +583,7 @@ func TestKeeperAddFunds(t *testing.T) { // Now the new upkeep should be performing because we added enough funds gom.Eventually(func(g gomega.Gomega) { - counter, err := consumers[0].Counter(context.Background()) + counter, err := consumers[0].Counter(utils.TestContext(t)) g.Expect(err).ShouldNot(gomega.HaveOccurred(), "Calling consumer's counter shouldn't fail") g.Expect(counter.Int64()).Should(gomega.BeNumerically(">", int64(0)), "Expected newly registered upkeep's counter to be greater than 0, but got %d", counter.Int64()) @@ -628,7 +628,7 @@ func TestKeeperRemove(t *testing.T) { // Make sure the upkeeps are running before we remove a keeper gom.Eventually(func(g gomega.Gomega) error { for upkeepID := 0; upkeepID < len(upkeepIDs); upkeepID++ { - counter, err := consumers[upkeepID].Counter(context.Background()) + counter, err := consumers[upkeepID].Counter(utils.TestContext(t)) initialCounters[upkeepID] = counter g.Expect(err).ShouldNot(gomega.HaveOccurred(), "Failed to retrieve consumer counter"+ " for upkeep with ID "+strconv.Itoa(upkeepID)) @@ -637,7 +637,7 @@ func TestKeeperRemove(t *testing.T) { return nil }, "1m", "1s").Should(gomega.Succeed()) - keepers, err := registry.GetKeeperList(context.Background()) + keepers, err := registry.GetKeeperList(utils.TestContext(t)) require.NoError(t, err, "Error getting list of Keepers") // Remove the first keeper from the list @@ -660,7 +660,7 @@ func TestKeeperRemove(t *testing.T) { // The upkeeps should still perform and their counters should have increased compared to the first check gom.Eventually(func(g gomega.Gomega) error { for i := 0; i < len(upkeepIDs); i++ { - counter, err := consumers[i].Counter(context.Background()) + counter, err := consumers[i].Counter(utils.TestContext(t)) g.Expect(err).ShouldNot(gomega.HaveOccurred(), "Failed to retrieve consumer counter for upkeep at index %d", i) g.Expect(counter.Cmp(initialCounters[i]) == 1, "Expected consumer counter to be greater "+ "than initial counter which was %s, but got %s", initialCounters[i], counter) @@ -705,7 +705,7 @@ func TestKeeperPauseRegistry(t *testing.T) { // Observe that the upkeeps which are initially registered are performing gom.Eventually(func(g gomega.Gomega) error { for i := 0; i < len(upkeepIDs); i++ { - counter, err := consumers[i].Counter(context.Background()) + counter, err := consumers[i].Counter(utils.TestContext(t)) g.Expect(err).ShouldNot(gomega.HaveOccurred(), "Failed to retrieve consumer counter for upkeep at index %d", i) g.Expect(counter.Int64()).Should(gomega.BeNumerically(">", int64(0)), "Expected consumer counter to be greater than 0, but got %d") @@ -722,7 +722,7 @@ func TestKeeperPauseRegistry(t *testing.T) { // Store how many times each upkeep performed once the registry was successfully paused var countersAfterPause = make([]*big.Int, len(upkeepIDs)) for i := 0; i < len(upkeepIDs); i++ { - countersAfterPause[i], err = consumers[i].Counter(context.Background()) + countersAfterPause[i], err = consumers[i].Counter(utils.TestContext(t)) require.NoError(t, err, "Error retrieving consumer at index %d", i) } @@ -730,7 +730,7 @@ func TestKeeperPauseRegistry(t *testing.T) { // because they are no longer getting serviced gom.Consistently(func(g gomega.Gomega) { for i := 0; i < len(upkeepIDs); i++ { - latestCounter, err := consumers[i].Counter(context.Background()) + latestCounter, err := consumers[i].Counter(utils.TestContext(t)) require.NoError(t, err, "Error retrieving consumer contract at index %d", i) g.Expect(latestCounter.Int64()).Should(gomega.Equal(countersAfterPause[i].Int64()), "Expected consumer counter to remain constant at %d, but got %d", @@ -791,7 +791,7 @@ func TestKeeperMigrateRegistry(t *testing.T) { // Check that the first upkeep from the first registry is performing (before being migrated) gom.Eventually(func(g gomega.Gomega) error { - counterBeforeMigration, err := consumers[0].Counter(context.Background()) + counterBeforeMigration, err := consumers[0].Counter(utils.TestContext(t)) g.Expect(err).ShouldNot(gomega.HaveOccurred(), "Calling consumer's counter shouldn't fail") g.Expect(counterBeforeMigration.Int64()).Should(gomega.BeNumerically(">", int64(0)), "Expected consumer counter to be greater than 0, but got %s", counterBeforeMigration) @@ -810,12 +810,12 @@ func TestKeeperMigrateRegistry(t *testing.T) { err = chainClient.WaitForEvents() require.NoError(t, err, "Error waiting to pause first registry") - counterAfterMigration, err := consumers[0].Counter(context.Background()) + counterAfterMigration, err := consumers[0].Counter(utils.TestContext(t)) require.NoError(t, err, "Error calling consumer's counter") // Check that once we migrated the upkeep, the counter has increased gom.Eventually(func(g gomega.Gomega) error { - currentCounter, err := consumers[0].Counter(context.Background()) + currentCounter, err := consumers[0].Counter(utils.TestContext(t)) g.Expect(err).ShouldNot(gomega.HaveOccurred(), "Calling consumer's counter shouldn't fail") g.Expect(currentCounter.Int64()).Should(gomega.BeNumerically(">", counterAfterMigration.Int64()), "Expected counter to have increased, but stayed constant at %s", counterAfterMigration) @@ -860,7 +860,7 @@ func TestKeeperNodeDown(t *testing.T) { // Watch upkeeps being performed and store their counters in order to compare them later in the test gom.Eventually(func(g gomega.Gomega) error { for i := 0; i < len(upkeepIDs); i++ { - counter, err := consumers[i].Counter(context.Background()) + counter, err := consumers[i].Counter(utils.TestContext(t)) initialCounters[i] = counter g.Expect(err).ShouldNot(gomega.HaveOccurred(), "Failed to retrieve consumer counter for upkeep at index %d", i) g.Expect(counter.Int64()).Should(gomega.BeNumerically(">", int64(0)), @@ -882,7 +882,7 @@ func TestKeeperNodeDown(t *testing.T) { // Assert that upkeeps are still performed and their counters have increased gom.Eventually(func(g gomega.Gomega) error { for i := 0; i < len(upkeepIDs); i++ { - currentCounter, err := consumers[i].Counter(context.Background()) + currentCounter, err := consumers[i].Counter(utils.TestContext(t)) g.Expect(err).ShouldNot(gomega.HaveOccurred(), "Failed to retrieve consumer counter for upkeep at index %d", i) g.Expect(currentCounter.Int64()).Should(gomega.BeNumerically(">", initialCounters[i].Int64()), "Expected counter to have increased from initial value of %s, but got %s", @@ -908,7 +908,7 @@ func TestKeeperNodeDown(t *testing.T) { // See how many times each upkeep was executed var countersAfterNoMoreNodes = make([]*big.Int, len(upkeepIDs)) for i := 0; i < len(upkeepIDs); i++ { - countersAfterNoMoreNodes[i], err = consumers[i].Counter(context.Background()) + countersAfterNoMoreNodes[i], err = consumers[i].Counter(utils.TestContext(t)) require.NoError(t, err, "Error retrieving consumer counter %d", i) l.Info(). Int("Index", i). @@ -921,7 +921,7 @@ func TestKeeperNodeDown(t *testing.T) { // so a +6 on the upper limit side should be sufficient. gom.Consistently(func(g gomega.Gomega) { for i := 0; i < len(upkeepIDs); i++ { - latestCounter, err := consumers[i].Counter(context.Background()) + latestCounter, err := consumers[i].Counter(utils.TestContext(t)) g.Expect(err).ShouldNot(gomega.HaveOccurred(), "Failed to retrieve consumer counter for upkeep at index %d", i) g.Expect(latestCounter.Int64()).Should(gomega.BeNumerically("<=", countersAfterNoMoreNodes[i].Int64()+numUpkeepsAllowedForStragglingTxs, @@ -964,7 +964,7 @@ func TestKeeperPauseUnPauseUpkeep(t *testing.T) { 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 5 for i := 0; i < len(upkeepIDs); i++ { - counter, err := consumers[i].Counter(context.Background()) + counter, err := consumers[i].Counter(utils.TestContext(t)) g.Expect(err).ShouldNot(gomega.HaveOccurred(), "Failed to retrieve consumer counter for upkeep at index %d", i) g.Expect(counter.Int64()).Should(gomega.BeNumerically(">", int64(5)), "Expected consumer counter to be greater than 5, but got %d", counter.Int64()) @@ -985,7 +985,7 @@ func TestKeeperPauseUnPauseUpkeep(t *testing.T) { var countersAfterPause = make([]*big.Int, len(upkeepIDs)) for i := 0; i < len(upkeepIDs); i++ { // Obtain the amount of times the upkeep has been executed so far - countersAfterPause[i], err = consumers[i].Counter(context.Background()) + countersAfterPause[i], err = consumers[i].Counter(utils.TestContext(t)) require.NoError(t, err, "Error retrieving upkeep count at index %d", i) l.Info(). Int("Index", i). @@ -998,7 +998,7 @@ func TestKeeperPauseUnPauseUpkeep(t *testing.T) { // In most cases counters should remain constant, but there might be a straggling perform tx which // gets committed later. Since every keeper node cannot have more than 1 straggling tx, it // is sufficient to check that the upkeep count does not increase by more than 6. - latestCounter, err := consumers[i].Counter(context.Background()) + latestCounter, err := consumers[i].Counter(utils.TestContext(t)) require.NoError(t, err, "Error retrieving counter at index %d", i) g.Expect(latestCounter.Int64()).Should(gomega.BeNumerically("<=", countersAfterPause[i].Int64()+numUpkeepsAllowedForStragglingTxs), "Expected consumer counter not have increased more than %d, but got %d", @@ -1018,7 +1018,7 @@ func TestKeeperPauseUnPauseUpkeep(t *testing.T) { 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 5 + numbers of performing before pause for i := 0; i < len(upkeepIDs); i++ { - counter, err := consumers[i].Counter(context.Background()) + counter, err := consumers[i].Counter(utils.TestContext(t)) g.Expect(err).ShouldNot(gomega.HaveOccurred(), "Failed to retrieve consumer counter"+ " for upkeep at index %d", i) g.Expect(counter.Int64()).Should(gomega.BeNumerically(">", int64(5)+countersAfterPause[i].Int64()), @@ -1055,7 +1055,7 @@ func TestKeeperUpdateCheckData(t *testing.T) { gom.Consistently(func(g gomega.Gomega) { // expect the counter to remain 0 because perform data does not match for i := 0; i < len(upkeepIDs); i++ { - counter, err := performDataChecker[i].Counter(context.Background()) + counter, err := performDataChecker[i].Counter(utils.TestContext(t)) g.Expect(err).ShouldNot(gomega.HaveOccurred(), "Failed to retrieve perform data checker for upkeep at index %d", i) g.Expect(counter.Int64()).Should(gomega.Equal(int64(0)), "Expected perform data checker counter to be 0, but got %d", counter.Int64()) @@ -1073,7 +1073,7 @@ func TestKeeperUpdateCheckData(t *testing.T) { // retrieve new check data for all upkeeps for i := 0; i < len(upkeepIDs); i++ { - upkeep, err := registry.GetUpkeepInfo(context.Background(), upkeepIDs[i]) + upkeep, err := registry.GetUpkeepInfo(utils.TestContext(t), upkeepIDs[i]) require.NoError(t, err, "Error getting upkeep info from index %d", i) require.Equal(t, []byte(keeperExpectedData), upkeep.CheckData, "Check data not as expected") } @@ -1081,7 +1081,7 @@ func TestKeeperUpdateCheckData(t *testing.T) { 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 5 for i := 0; i < len(upkeepIDs); i++ { - counter, err := performDataChecker[i].Counter(context.Background()) + counter, err := performDataChecker[i].Counter(utils.TestContext(t)) g.Expect(err).ShouldNot(gomega.HaveOccurred(), "Failed to retrieve perform data checker counter for upkeep at index %d", i) g.Expect(counter.Int64()).Should(gomega.BeNumerically(">", int64(5)), "Expected perform data checker counter to be greater than 5, but got %d", counter.Int64()) diff --git a/integration-tests/smoke/ocr2_test.go b/integration-tests/smoke/ocr2_test.go index a6dcdcd139d..5950e9febb6 100644 --- a/integration-tests/smoke/ocr2_test.go +++ b/integration-tests/smoke/ocr2_test.go @@ -1,7 +1,6 @@ package smoke import ( - "context" "fmt" "math/big" "net/http" @@ -16,6 +15,7 @@ import ( "github.com/smartcontractkit/chainlink/integration-tests/contracts" "github.com/smartcontractkit/chainlink/integration-tests/docker/test_env" "github.com/smartcontractkit/chainlink/integration-tests/types/config/node" + "github.com/smartcontractkit/chainlink/integration-tests/utils" ) // Tests a basic OCRv2 median feed @@ -73,7 +73,7 @@ func TestOCRv2Basic(t *testing.T) { err = actions.StartNewOCR2Round(1, aggregatorContracts, env.EVMClient, time.Minute*5, l) require.NoError(t, err, "Error starting new OCR2 round") - roundData, err := aggregatorContracts[0].GetRound(context.Background(), big.NewInt(1)) + roundData, err := aggregatorContracts[0].GetRound(utils.TestContext(t), big.NewInt(1)) require.NoError(t, err, "Getting latest answer from OCR contract shouldn't fail") require.Equal(t, int64(5), roundData.Answer.Int64(), "Expected latest answer from OCR contract to be 5 but got %d", @@ -85,7 +85,7 @@ func TestOCRv2Basic(t *testing.T) { err = actions.StartNewOCR2Round(2, aggregatorContracts, env.EVMClient, time.Minute*5, l) require.NoError(t, err) - roundData, err = aggregatorContracts[0].GetRound(context.Background(), big.NewInt(2)) + roundData, err = aggregatorContracts[0].GetRound(utils.TestContext(t), big.NewInt(2)) require.NoError(t, err, "Error getting latest OCR answer") require.Equal(t, int64(10), roundData.Answer.Int64(), "Expected latest answer from OCR contract to be 10 but got %d", diff --git a/integration-tests/smoke/ocr2vrf_test.go b/integration-tests/smoke/ocr2vrf_test.go index 912c121d075..dc939872509 100644 --- a/integration-tests/smoke/ocr2vrf_test.go +++ b/integration-tests/smoke/ocr2vrf_test.go @@ -1,7 +1,6 @@ package smoke import ( - "context" "fmt" "math/big" "strings" @@ -24,6 +23,7 @@ import ( "github.com/smartcontractkit/chainlink/integration-tests/client" "github.com/smartcontractkit/chainlink/integration-tests/config" "github.com/smartcontractkit/chainlink/integration-tests/contracts" + it_utils "github.com/smartcontractkit/chainlink/integration-tests/utils" ) func TestOCR2VRFRedeemModel(t *testing.T) { @@ -81,7 +81,7 @@ func TestOCR2VRFRedeemModel(t *testing.T) { ) for i := uint16(0); i < ocr2vrf_constants.NumberOfRandomWordsToRequest; i++ { - randomness, err := consumerContract.GetRandomnessByRequestId(context.Background(), requestID, big.NewInt(int64(i))) + randomness, err := consumerContract.GetRandomnessByRequestId(it_utils.TestContext(t), requestID, big.NewInt(int64(i))) require.NoError(t, err) l.Info().Interface("Random Number", randomness).Interface("Randomness Number Index", i).Msg("Randomness retrieved from Consumer contract") require.NotEqual(t, 0, randomness.Uint64(), "Randomness retrieved from Consumer contract give an answer other than 0") @@ -142,7 +142,7 @@ func TestOCR2VRFFulfillmentModel(t *testing.T) { ) for i := uint16(0); i < ocr2vrf_constants.NumberOfRandomWordsToRequest; i++ { - randomness, err := consumerContract.GetRandomnessByRequestId(context.Background(), requestID, big.NewInt(int64(i))) + randomness, err := consumerContract.GetRandomnessByRequestId(it_utils.TestContext(t), requestID, big.NewInt(int64(i))) require.NoError(t, err, "Error getting Randomness result from Consumer Contract") l.Info().Interface("Random Number", randomness).Interface("Randomness Number Index", i).Msg("Randomness Fulfillment retrieved from Consumer contract") require.NotEqual(t, 0, randomness.Uint64(), "Randomness Fulfillment retrieved from Consumer contract give an answer other than 0") diff --git a/integration-tests/smoke/ocr_test.go b/integration-tests/smoke/ocr_test.go index 8952f00d768..45205565e21 100644 --- a/integration-tests/smoke/ocr_test.go +++ b/integration-tests/smoke/ocr_test.go @@ -1,7 +1,6 @@ package smoke import ( - "context" "math/big" "testing" @@ -11,6 +10,7 @@ import ( "github.com/smartcontractkit/chainlink/integration-tests/actions" "github.com/smartcontractkit/chainlink/integration-tests/docker/test_env" + "github.com/smartcontractkit/chainlink/integration-tests/utils" ) func TestOCRBasic(t *testing.T) { @@ -46,7 +46,7 @@ func TestOCRBasic(t *testing.T) { err = actions.StartNewRound(1, ocrInstances, env.EVMClient, l) require.NoError(t, err) - answer, err := ocrInstances[0].GetLatestAnswer(context.Background()) + answer, err := ocrInstances[0].GetLatestAnswer(utils.TestContext(t)) require.NoError(t, err, "Getting latest answer from OCR contract shouldn't fail") require.Equal(t, int64(5), answer.Int64(), "Expected latest answer from OCR contract to be 5 but got %d", answer.Int64()) @@ -55,7 +55,7 @@ func TestOCRBasic(t *testing.T) { err = actions.StartNewRound(2, ocrInstances, env.EVMClient, l) require.NoError(t, err) - answer, err = ocrInstances[0].GetLatestAnswer(context.Background()) + answer, err = ocrInstances[0].GetLatestAnswer(utils.TestContext(t)) require.NoError(t, err, "Error getting latest OCR answer") require.Equal(t, int64(10), answer.Int64(), "Expected latest answer from OCR contract to be 10 but got %d", answer.Int64()) } diff --git a/integration-tests/smoke/runlog_test.go b/integration-tests/smoke/runlog_test.go index f29cb4bc893..20389da378f 100644 --- a/integration-tests/smoke/runlog_test.go +++ b/integration-tests/smoke/runlog_test.go @@ -1,7 +1,6 @@ package smoke import ( - "context" "fmt" "math/big" "net/http" @@ -16,6 +15,7 @@ import ( "github.com/smartcontractkit/chainlink/integration-tests/client" "github.com/smartcontractkit/chainlink/integration-tests/docker/test_env" + "github.com/smartcontractkit/chainlink/integration-tests/utils" ) func TestRunLogBasic(t *testing.T) { @@ -87,7 +87,7 @@ func TestRunLogBasic(t *testing.T) { gom := gomega.NewGomegaWithT(t) gom.Eventually(func(g gomega.Gomega) { - d, err := consumer.Data(context.Background()) + d, err := consumer.Data(utils.TestContext(t)) g.Expect(err).ShouldNot(gomega.HaveOccurred(), "Getting data from consumer contract shouldn't fail") g.Expect(d).ShouldNot(gomega.BeNil(), "Expected the initial on chain data to be nil") l.Debug().Int64("Data", d.Int64()).Msg("Found on chain") diff --git a/integration-tests/smoke/vrf_test.go b/integration-tests/smoke/vrf_test.go index 444d1ce20ee..61d2c5cdd70 100644 --- a/integration-tests/smoke/vrf_test.go +++ b/integration-tests/smoke/vrf_test.go @@ -1,7 +1,6 @@ package smoke import ( - "context" "fmt" "math/big" "testing" @@ -17,6 +16,7 @@ import ( "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/smartcontractkit/chainlink/integration-tests/utils" ) func TestVRFBasic(t *testing.T) { @@ -81,7 +81,7 @@ func TestVRFBasic(t *testing.T) { encodedProvingKeys := make([][2]*big.Int, 0) encodedProvingKeys = append(encodedProvingKeys, provingKey) - requestHash, err := contracts.Coordinator.HashOfKey(context.Background(), encodedProvingKeys[0]) + requestHash, err := contracts.Coordinator.HashOfKey(utils.TestContext(t), encodedProvingKeys[0]) require.NoError(t, err, "Getting Hash of encoded proving keys shouldn't fail") err = contracts.Consumer.RequestRandomness(requestHash, big.NewInt(1)) require.NoError(t, err, "Requesting randomness shouldn't fail") @@ -92,7 +92,7 @@ func TestVRFBasic(t *testing.T) { jobRuns, err := env.ClCluster.Nodes[0].API.MustReadRunsByJob(job.Data.ID) g.Expect(err).ShouldNot(gomega.HaveOccurred(), "Job execution shouldn't fail") - out, err := contracts.Consumer.RandomnessOutput(context.Background()) + out, err := contracts.Consumer.RandomnessOutput(utils.TestContext(t)) g.Expect(err).ShouldNot(gomega.HaveOccurred(), "Getting the randomness output of the consumer shouldn't fail") // Checks that the job has actually run g.Expect(len(jobRuns.Data)).Should(gomega.BeNumerically(">=", 1), diff --git a/integration-tests/smoke/vrfv2_test.go b/integration-tests/smoke/vrfv2_test.go index c960bb6c691..714ed752a36 100644 --- a/integration-tests/smoke/vrfv2_test.go +++ b/integration-tests/smoke/vrfv2_test.go @@ -1,7 +1,6 @@ package smoke import ( - "context" "math/big" "testing" "time" @@ -16,6 +15,7 @@ import ( vrfConst "github.com/smartcontractkit/chainlink/integration-tests/actions/vrfv2_actions/vrfv2_constants" "github.com/smartcontractkit/chainlink/integration-tests/docker/test_env" "github.com/smartcontractkit/chainlink/integration-tests/types/config/node" + "github.com/smartcontractkit/chainlink/integration-tests/utils" ) func TestVRFv2Basic(t *testing.T) { @@ -97,11 +97,11 @@ func TestVRFv2Basic(t *testing.T) { jobRuns, err := env.ClCluster.Nodes[0].API.MustReadRunsByJob(vrfV2jobs[0].Job.Data.ID) g.Expect(err).ShouldNot(gomega.HaveOccurred()) g.Expect(len(jobRuns.Data)).Should(gomega.BeNumerically("==", 1)) - lastRequestID, err = vrfv2Contracts.LoadTestConsumer.GetLastRequestId(context.Background()) + lastRequestID, err = vrfv2Contracts.LoadTestConsumer.GetLastRequestId(utils.TestContext(t)) l.Debug().Interface("Last Request ID", lastRequestID).Msg("Last Request ID Received") g.Expect(err).ShouldNot(gomega.HaveOccurred()) - status, err := vrfv2Contracts.LoadTestConsumer.GetRequestStatus(context.Background(), lastRequestID) + status, err := vrfv2Contracts.LoadTestConsumer.GetRequestStatus(utils.TestContext(t), lastRequestID) g.Expect(err).ShouldNot(gomega.HaveOccurred()) g.Expect(status.Fulfilled).Should(gomega.BeTrue()) l.Debug().Interface("Fulfilment Status", status.Fulfilled).Msg("Random Words Request Fulfilment Status") diff --git a/integration-tests/smoke/vrfv2plus_test.go b/integration-tests/smoke/vrfv2plus_test.go index 3510a1505a7..cfeca0a66a3 100644 --- a/integration-tests/smoke/vrfv2plus_test.go +++ b/integration-tests/smoke/vrfv2plus_test.go @@ -1,7 +1,6 @@ package smoke import ( - "context" "fmt" "math/big" "testing" @@ -55,7 +54,7 @@ func TestVRFv2Plus(t *testing.T) { subID := subIDs[0] - subscription, err := vrfv2PlusContracts.Coordinator.GetSubscription(context.Background(), subID) + subscription, err := vrfv2PlusContracts.Coordinator.GetSubscription(utils.TestContext(t), subID) require.NoError(t, err, "error getting subscription information") vrfv2plus.LogSubDetails(l, subscription, subID, vrfv2PlusContracts.Coordinator) @@ -83,7 +82,7 @@ func TestVRFv2Plus(t *testing.T) { require.NoError(t, err, "error requesting randomness and waiting for fulfilment") expectedSubBalanceJuels := new(big.Int).Sub(subBalanceBeforeRequest, randomWordsFulfilledEvent.Payment) - subscription, err = vrfv2PlusContracts.Coordinator.GetSubscription(context.Background(), subID) + subscription, err = vrfv2PlusContracts.Coordinator.GetSubscription(utils.TestContext(t), subID) require.NoError(t, err, "error getting subscription information") subBalanceAfterRequest := subscription.Balance require.Equal(t, expectedSubBalanceJuels, subBalanceAfterRequest) @@ -92,7 +91,7 @@ func TestVRFv2Plus(t *testing.T) { require.NoError(t, err, "error reading job runs") require.Equal(t, len(jobRunsBeforeTest.Data)+1, len(jobRuns.Data)) - status, err := vrfv2PlusContracts.LoadTestConsumers[0].GetRequestStatus(context.Background(), randomWordsFulfilledEvent.RequestId) + status, err := vrfv2PlusContracts.LoadTestConsumers[0].GetRequestStatus(utils.TestContext(t), randomWordsFulfilledEvent.RequestId) require.NoError(t, err, "error getting rand request status") require.True(t, status.Fulfilled) l.Debug().Bool("Fulfilment Status", status.Fulfilled).Msg("Random Words Request Fulfilment Status") @@ -125,7 +124,7 @@ func TestVRFv2Plus(t *testing.T) { ) require.NoError(t, err, "error requesting randomness and waiting for fulfilment") expectedSubBalanceWei := new(big.Int).Sub(subNativeTokenBalanceBeforeRequest, randomWordsFulfilledEvent.Payment) - subscription, err = vrfv2PlusContracts.Coordinator.GetSubscription(context.Background(), subID) + subscription, err = vrfv2PlusContracts.Coordinator.GetSubscription(utils.TestContext(t), subID) require.NoError(t, err) subBalanceAfterRequest := subscription.NativeBalance require.Equal(t, expectedSubBalanceWei, subBalanceAfterRequest) @@ -134,7 +133,7 @@ func TestVRFv2Plus(t *testing.T) { require.NoError(t, err, "error reading job runs") require.Equal(t, len(jobRunsBeforeTest.Data)+1, len(jobRuns.Data)) - status, err := vrfv2PlusContracts.LoadTestConsumers[0].GetRequestStatus(context.Background(), randomWordsFulfilledEvent.RequestId) + status, err := vrfv2PlusContracts.LoadTestConsumers[0].GetRequestStatus(utils.TestContext(t), randomWordsFulfilledEvent.RequestId) require.NoError(t, err, "error getting rand request status") require.True(t, status.Fulfilled) l.Debug().Bool("Fulfilment Status", status.Fulfilled).Msg("Random Words Request Fulfilment Status") @@ -162,10 +161,10 @@ func TestVRFv2Plus(t *testing.T) { testConfig := vrfv2PlusConfig var isNativeBilling = false - wrapperConsumerJuelsBalanceBeforeRequest, err := linkToken.BalanceOf(context.Background(), wrapperContracts.LoadTestConsumers[0].Address()) + wrapperConsumerJuelsBalanceBeforeRequest, err := linkToken.BalanceOf(utils.TestContext(t), wrapperContracts.LoadTestConsumers[0].Address()) require.NoError(t, err, "error getting wrapper consumer balance") - wrapperSubscription, err := vrfv2PlusContracts.Coordinator.GetSubscription(context.Background(), wrapperSubID) + wrapperSubscription, err := vrfv2PlusContracts.Coordinator.GetSubscription(utils.TestContext(t), wrapperSubID) require.NoError(t, err, "error getting subscription information") subBalanceBeforeRequest := wrapperSubscription.Balance @@ -182,18 +181,18 @@ func TestVRFv2Plus(t *testing.T) { require.NoError(t, err, "error requesting randomness and waiting for fulfilment") expectedSubBalanceJuels := new(big.Int).Sub(subBalanceBeforeRequest, randomWordsFulfilledEvent.Payment) - wrapperSubscription, err = vrfv2PlusContracts.Coordinator.GetSubscription(context.Background(), wrapperSubID) + wrapperSubscription, err = vrfv2PlusContracts.Coordinator.GetSubscription(utils.TestContext(t), wrapperSubID) require.NoError(t, err, "error getting subscription information") subBalanceAfterRequest := wrapperSubscription.Balance require.Equal(t, expectedSubBalanceJuels, subBalanceAfterRequest) - consumerStatus, err := wrapperContracts.LoadTestConsumers[0].GetRequestStatus(context.Background(), randomWordsFulfilledEvent.RequestId) + consumerStatus, err := wrapperContracts.LoadTestConsumers[0].GetRequestStatus(utils.TestContext(t), randomWordsFulfilledEvent.RequestId) require.NoError(t, err, "error getting rand request status") require.True(t, consumerStatus.Fulfilled) expectedWrapperConsumerJuelsBalance := new(big.Int).Sub(wrapperConsumerJuelsBalanceBeforeRequest, consumerStatus.Paid) - wrapperConsumerJuelsBalanceAfterRequest, err := linkToken.BalanceOf(context.Background(), wrapperContracts.LoadTestConsumers[0].Address()) + wrapperConsumerJuelsBalanceAfterRequest, err := linkToken.BalanceOf(utils.TestContext(t), wrapperContracts.LoadTestConsumers[0].Address()) require.NoError(t, err, "error getting wrapper consumer balance") require.Equal(t, expectedWrapperConsumerJuelsBalance, wrapperConsumerJuelsBalanceAfterRequest) @@ -211,10 +210,10 @@ func TestVRFv2Plus(t *testing.T) { testConfig := vrfv2PlusConfig var isNativeBilling = true - wrapperConsumerBalanceBeforeRequestWei, err := env.EVMClient.BalanceAt(context.Background(), common.HexToAddress(wrapperContracts.LoadTestConsumers[0].Address())) + wrapperConsumerBalanceBeforeRequestWei, err := env.EVMClient.BalanceAt(utils.TestContext(t), common.HexToAddress(wrapperContracts.LoadTestConsumers[0].Address())) require.NoError(t, err, "error getting wrapper consumer balance") - wrapperSubscription, err := vrfv2PlusContracts.Coordinator.GetSubscription(context.Background(), wrapperSubID) + wrapperSubscription, err := vrfv2PlusContracts.Coordinator.GetSubscription(utils.TestContext(t), wrapperSubID) require.NoError(t, err, "error getting subscription information") subBalanceBeforeRequest := wrapperSubscription.NativeBalance @@ -231,18 +230,18 @@ func TestVRFv2Plus(t *testing.T) { require.NoError(t, err, "error requesting randomness and waiting for fulfilment") expectedSubBalanceWei := new(big.Int).Sub(subBalanceBeforeRequest, randomWordsFulfilledEvent.Payment) - wrapperSubscription, err = vrfv2PlusContracts.Coordinator.GetSubscription(context.Background(), wrapperSubID) + wrapperSubscription, err = vrfv2PlusContracts.Coordinator.GetSubscription(utils.TestContext(t), wrapperSubID) require.NoError(t, err, "error getting subscription information") subBalanceAfterRequest := wrapperSubscription.NativeBalance require.Equal(t, expectedSubBalanceWei, subBalanceAfterRequest) - consumerStatus, err := wrapperContracts.LoadTestConsumers[0].GetRequestStatus(context.Background(), randomWordsFulfilledEvent.RequestId) + consumerStatus, err := wrapperContracts.LoadTestConsumers[0].GetRequestStatus(utils.TestContext(t), randomWordsFulfilledEvent.RequestId) require.NoError(t, err, "error getting rand request status") require.True(t, consumerStatus.Fulfilled) expectedWrapperConsumerWeiBalance := new(big.Int).Sub(wrapperConsumerBalanceBeforeRequestWei, consumerStatus.Paid) - wrapperConsumerBalanceAfterRequestWei, err := env.EVMClient.BalanceAt(context.Background(), common.HexToAddress(wrapperContracts.LoadTestConsumers[0].Address())) + wrapperConsumerBalanceAfterRequestWei, err := env.EVMClient.BalanceAt(utils.TestContext(t), common.HexToAddress(wrapperContracts.LoadTestConsumers[0].Address())) require.NoError(t, err, "error getting wrapper consumer balance") require.Equal(t, expectedWrapperConsumerWeiBalance, wrapperConsumerBalanceAfterRequestWei) @@ -273,13 +272,13 @@ func TestVRFv2Plus(t *testing.T) { testWalletAddress, err := actions.GenerateWallet() require.NoError(t, err) - testWalletBalanceNativeBeforeSubCancelling, err := env.EVMClient.BalanceAt(context.Background(), testWalletAddress) + testWalletBalanceNativeBeforeSubCancelling, err := env.EVMClient.BalanceAt(utils.TestContext(t), testWalletAddress) require.NoError(t, err) - testWalletBalanceLinkBeforeSubCancelling, err := linkToken.BalanceOf(context.Background(), testWalletAddress.String()) + testWalletBalanceLinkBeforeSubCancelling, err := linkToken.BalanceOf(utils.TestContext(t), testWalletAddress.String()) require.NoError(t, err) - subscriptionForCancelling, err := vrfv2PlusContracts.Coordinator.GetSubscription(context.Background(), subIDForCancelling) + subscriptionForCancelling, err := vrfv2PlusContracts.Coordinator.GetSubscription(utils.TestContext(t), subIDForCancelling) require.NoError(t, err, "error getting subscription information") subBalanceLink := subscriptionForCancelling.Balance @@ -318,14 +317,14 @@ func TestVRFv2Plus(t *testing.T) { require.Equal(t, subBalanceNative, subscriptionCanceledEvent.AmountNative, "SubscriptionCanceled event native amount is not equal to sub amount while canceling subscription") require.Equal(t, subBalanceLink, subscriptionCanceledEvent.AmountLink, "SubscriptionCanceled event LINK amount is not equal to sub amount while canceling subscription") - testWalletBalanceNativeAfterSubCancelling, err := env.EVMClient.BalanceAt(context.Background(), testWalletAddress) + testWalletBalanceNativeAfterSubCancelling, err := env.EVMClient.BalanceAt(utils.TestContext(t), testWalletAddress) require.NoError(t, err) - testWalletBalanceLinkAfterSubCancelling, err := linkToken.BalanceOf(context.Background(), testWalletAddress.String()) + testWalletBalanceLinkAfterSubCancelling, err := linkToken.BalanceOf(utils.TestContext(t), testWalletAddress.String()) require.NoError(t, err) //Verify that sub was deleted from Coordinator - _, err = vrfv2PlusContracts.Coordinator.GetSubscription(context.Background(), subIDForCancelling) + _, err = vrfv2PlusContracts.Coordinator.GetSubscription(utils.TestContext(t), subIDForCancelling) require.Error(t, err, "error not occurred when trying to get deleted subscription from old Coordinator after sub migration") subFundsReturnedNativeActual := new(big.Int).Sub(testWalletBalanceNativeAfterSubCancelling, testWalletBalanceNativeBeforeSubCancelling) @@ -367,17 +366,17 @@ func TestVRFv2Plus(t *testing.T) { subIDForCancelling := subIDsForCancelling[0] - subscriptionForCancelling, err := vrfv2PlusContracts.Coordinator.GetSubscription(context.Background(), subIDForCancelling) + subscriptionForCancelling, err := vrfv2PlusContracts.Coordinator.GetSubscription(utils.TestContext(t), subIDForCancelling) require.NoError(t, err, "error getting subscription information") vrfv2plus.LogSubDetails(l, subscriptionForCancelling, subIDForCancelling, vrfv2PlusContracts.Coordinator) - activeSubscriptionIdsBeforeSubCancellation, err := vrfv2PlusContracts.Coordinator.GetActiveSubscriptionIds(context.Background(), big.NewInt(0), big.NewInt(0)) + activeSubscriptionIdsBeforeSubCancellation, err := vrfv2PlusContracts.Coordinator.GetActiveSubscriptionIds(utils.TestContext(t), big.NewInt(0), big.NewInt(0)) require.NoError(t, err) require.True(t, utils.BigIntSliceContains(activeSubscriptionIdsBeforeSubCancellation, subIDForCancelling)) - pendingRequestsExist, err := vrfv2PlusContracts.Coordinator.PendingRequestsExist(context.Background(), subIDForCancelling) + pendingRequestsExist, err := vrfv2PlusContracts.Coordinator.PendingRequestsExist(utils.TestContext(t), subIDForCancelling) require.NoError(t, err) require.False(t, pendingRequestsExist, "Pending requests should not exist") @@ -409,17 +408,17 @@ func TestVRFv2Plus(t *testing.T) { require.Error(t, err, "error should occur for waiting for fulfilment due to low sub balance") - pendingRequestsExist, err = vrfv2PlusContracts.Coordinator.PendingRequestsExist(context.Background(), subIDForCancelling) + pendingRequestsExist, err = vrfv2PlusContracts.Coordinator.PendingRequestsExist(utils.TestContext(t), subIDForCancelling) require.NoError(t, err) require.True(t, pendingRequestsExist, "Pending requests should exist after unfulfilled rand requests due to low sub balance") - walletBalanceNativeBeforeSubCancelling, err := env.EVMClient.BalanceAt(context.Background(), common.HexToAddress(defaultWalletAddress)) + walletBalanceNativeBeforeSubCancelling, err := env.EVMClient.BalanceAt(utils.TestContext(t), common.HexToAddress(defaultWalletAddress)) require.NoError(t, err) - walletBalanceLinkBeforeSubCancelling, err := linkToken.BalanceOf(context.Background(), defaultWalletAddress) + walletBalanceLinkBeforeSubCancelling, err := linkToken.BalanceOf(utils.TestContext(t), defaultWalletAddress) require.NoError(t, err) - subscriptionForCancelling, err = vrfv2PlusContracts.Coordinator.GetSubscription(context.Background(), subIDForCancelling) + subscriptionForCancelling, err = vrfv2PlusContracts.Coordinator.GetSubscription(utils.TestContext(t), subIDForCancelling) require.NoError(t, err, "error getting subscription information") subBalanceLink := subscriptionForCancelling.Balance @@ -458,14 +457,14 @@ func TestVRFv2Plus(t *testing.T) { require.Equal(t, subBalanceNative, subscriptionCanceledEvent.AmountNative, "SubscriptionCanceled event native amount is not equal to sub amount while canceling subscription") require.Equal(t, subBalanceLink, subscriptionCanceledEvent.AmountLink, "SubscriptionCanceled event LINK amount is not equal to sub amount while canceling subscription") - walletBalanceNativeAfterSubCancelling, err := env.EVMClient.BalanceAt(context.Background(), common.HexToAddress(defaultWalletAddress)) + walletBalanceNativeAfterSubCancelling, err := env.EVMClient.BalanceAt(utils.TestContext(t), common.HexToAddress(defaultWalletAddress)) require.NoError(t, err) - walletBalanceLinkAfterSubCancelling, err := linkToken.BalanceOf(context.Background(), defaultWalletAddress) + walletBalanceLinkAfterSubCancelling, err := linkToken.BalanceOf(utils.TestContext(t), defaultWalletAddress) require.NoError(t, err) //Verify that sub was deleted from Coordinator - _, err = vrfv2PlusContracts.Coordinator.GetSubscription(context.Background(), subIDForCancelling) + _, err = vrfv2PlusContracts.Coordinator.GetSubscription(utils.TestContext(t), subIDForCancelling) fmt.Println("err", err) require.Error(t, err, "error not occurred when trying to get deleted subscription from old Coordinator after sub migration") @@ -494,7 +493,7 @@ func TestVRFv2Plus(t *testing.T) { //require.Equal(t, subFundsReturnedNativeExpected, subFundsReturnedNativeActual, "Returned funds are not equal to sub balance that was cancelled") require.Equal(t, 0, subBalanceLink.Cmp(subFundsReturnedLinkActual), "Returned LINK funds are not equal to sub balance that was cancelled") - activeSubscriptionIdsAfterSubCancellation, err := vrfv2PlusContracts.Coordinator.GetActiveSubscriptionIds(context.Background(), big.NewInt(0), big.NewInt(0)) + activeSubscriptionIdsAfterSubCancellation, err := vrfv2PlusContracts.Coordinator.GetActiveSubscriptionIds(utils.TestContext(t), big.NewInt(0), big.NewInt(0)) require.NoError(t, err, "error getting active subscription ids") require.False( @@ -543,10 +542,10 @@ func TestVRFv2Plus(t *testing.T) { require.NoError(t, err) amountToWithdrawLink := fulfilledEventLink.Payment - defaultWalletBalanceNativeBeforeOracleWithdraw, err := env.EVMClient.BalanceAt(context.Background(), common.HexToAddress(defaultWalletAddress)) + defaultWalletBalanceNativeBeforeOracleWithdraw, err := env.EVMClient.BalanceAt(utils.TestContext(t), common.HexToAddress(defaultWalletAddress)) require.NoError(t, err) - defaultWalletBalanceLinkBeforeOracleWithdraw, err := linkToken.BalanceOf(context.Background(), defaultWalletAddress) + defaultWalletBalanceLinkBeforeOracleWithdraw, err := linkToken.BalanceOf(utils.TestContext(t), defaultWalletAddress) require.NoError(t, err) l.Info(). @@ -575,10 +574,10 @@ func TestVRFv2Plus(t *testing.T) { err = env.EVMClient.WaitForEvents() require.NoError(t, err, vrfv2plus.ErrWaitTXsComplete) - defaultWalletBalanceNativeAfterOracleWithdraw, err := env.EVMClient.BalanceAt(context.Background(), common.HexToAddress(defaultWalletAddress)) + defaultWalletBalanceNativeAfterOracleWithdraw, err := env.EVMClient.BalanceAt(utils.TestContext(t), common.HexToAddress(defaultWalletAddress)) require.NoError(t, err) - defaultWalletBalanceLinkAfterOracleWithdraw, err := linkToken.BalanceOf(context.Background(), defaultWalletAddress) + defaultWalletBalanceLinkAfterOracleWithdraw, err := linkToken.BalanceOf(utils.TestContext(t), defaultWalletAddress) require.NoError(t, err) //not possible to verify exact amount of Native/LINK returned as defaultWallet is used in other tests in parallel which might affect the balance @@ -618,17 +617,17 @@ func TestVRFv2PlusMigration(t *testing.T) { subID := subIDs[0] - subscription, err := vrfv2PlusContracts.Coordinator.GetSubscription(context.Background(), subID) + subscription, err := vrfv2PlusContracts.Coordinator.GetSubscription(utils.TestContext(t), subID) require.NoError(t, err, "error getting subscription information") vrfv2plus.LogSubDetails(l, subscription, subID, vrfv2PlusContracts.Coordinator) - activeSubIdsOldCoordinatorBeforeMigration, err := vrfv2PlusContracts.Coordinator.GetActiveSubscriptionIds(context.Background(), big.NewInt(0), big.NewInt(0)) + activeSubIdsOldCoordinatorBeforeMigration, err := vrfv2PlusContracts.Coordinator.GetActiveSubscriptionIds(utils.TestContext(t), big.NewInt(0), big.NewInt(0)) require.NoError(t, err, "error occurred getting active sub ids") require.Len(t, activeSubIdsOldCoordinatorBeforeMigration, 1, "Active Sub Ids length is not equal to 1") require.Equal(t, subID, activeSubIdsOldCoordinatorBeforeMigration[0]) - oldSubscriptionBeforeMigration, err := vrfv2PlusContracts.Coordinator.GetSubscription(context.Background(), subID) + oldSubscriptionBeforeMigration, err := vrfv2PlusContracts.Coordinator.GetSubscription(utils.TestContext(t), subID) require.NoError(t, err, "error getting subscription information") //Migration Process @@ -699,14 +698,14 @@ func TestVRFv2PlusMigration(t *testing.T) { migratedCoordinatorLinkTotalBalanceAfterMigration, migratedCoordinatorEthTotalBalanceAfterMigration, err := vrfv2plus.GetUpgradedCoordinatorTotalBalance(newCoordinator) require.NoError(t, err) - migratedSubscription, err := newCoordinator.GetSubscription(context.Background(), subID) + migratedSubscription, err := newCoordinator.GetSubscription(utils.TestContext(t), subID) require.NoError(t, err, "error getting subscription information") vrfv2plus.LogSubDetailsAfterMigration(l, newCoordinator, subID, migratedSubscription) //Verify that Coordinators were updated in Consumers for _, consumer := range vrfv2PlusContracts.LoadTestConsumers { - coordinatorAddressInConsumerAfterMigration, err := consumer.GetCoordinator(context.Background()) + coordinatorAddressInConsumerAfterMigration, err := consumer.GetCoordinator(utils.TestContext(t)) require.NoError(t, err, "error getting Coordinator from Consumer contract") require.Equal(t, newCoordinator.Address(), coordinatorAddressInConsumerAfterMigration.String()) l.Debug(). @@ -722,13 +721,13 @@ func TestVRFv2PlusMigration(t *testing.T) { require.Equal(t, oldSubscriptionBeforeMigration.Consumers, migratedSubscription.Consumers) //Verify that old sub was deleted from old Coordinator - _, err = vrfv2PlusContracts.Coordinator.GetSubscription(context.Background(), subID) + _, err = vrfv2PlusContracts.Coordinator.GetSubscription(utils.TestContext(t), subID) require.Error(t, err, "error not occurred when trying to get deleted subscription from old Coordinator after sub migration") - _, err = vrfv2PlusContracts.Coordinator.GetActiveSubscriptionIds(context.Background(), big.NewInt(0), big.NewInt(0)) + _, err = vrfv2PlusContracts.Coordinator.GetActiveSubscriptionIds(utils.TestContext(t), big.NewInt(0), big.NewInt(0)) require.Error(t, err, "error not occurred getting active sub ids. Should occur since it should revert when sub id array is empty") - activeSubIdsMigratedCoordinator, err := newCoordinator.GetActiveSubscriptionIds(context.Background(), big.NewInt(0), big.NewInt(0)) + activeSubIdsMigratedCoordinator, err := newCoordinator.GetActiveSubscriptionIds(utils.TestContext(t), big.NewInt(0), big.NewInt(0)) require.NoError(t, err, "error occurred getting active sub ids") require.Len(t, activeSubIdsMigratedCoordinator, 1, "Active Sub Ids length is not equal to 1 for Migrated Coordinator after migration") require.Equal(t, subID, activeSubIdsMigratedCoordinator[0]) diff --git a/integration-tests/testsetups/keeper_benchmark.go b/integration-tests/testsetups/keeper_benchmark.go index 7f6d37c5541..bb6c582c137 100644 --- a/integration-tests/testsetups/keeper_benchmark.go +++ b/integration-tests/testsetups/keeper_benchmark.go @@ -37,6 +37,7 @@ import ( "github.com/smartcontractkit/chainlink/integration-tests/contracts" "github.com/smartcontractkit/chainlink/integration-tests/contracts/ethereum" "github.com/smartcontractkit/chainlink/integration-tests/testreporters" + "github.com/smartcontractkit/chainlink/integration-tests/utils" ) // KeeperBenchmarkTest builds a test to check that chainlink nodes are able to upkeep a specified amount of Upkeep @@ -229,7 +230,7 @@ func (k *KeeperBenchmarkTest) Run() { "NumberOfRegistries": len(k.keeperRegistries), } inputs := k.Inputs - startingBlock, err := k.chainClient.LatestBlockNumber(context.Background()) + startingBlock, err := k.chainClient.LatestBlockNumber(utils.TestContext(k.t)) require.NoError(k.t, err, "Error getting latest block number") k.startingBlock = big.NewInt(0).SetUint64(startingBlock) startTime := time.Now() @@ -305,7 +306,7 @@ func (k *KeeperBenchmarkTest) Run() { err = fmt.Errorf("initial error") // to ensure our for loop runs at least once ) for err != nil { // This RPC call can possibly time out or otherwise die. Failure is not an option, keep retrying to get our stats. - ctx, cancel := context.WithTimeout(context.Background(), timeout) + ctx, cancel := context.WithTimeout(utils.TestContext(k.t), timeout) logs, err = k.chainClient.FilterLogs(ctx, filterQuery) cancel() if err != nil { @@ -407,7 +408,7 @@ func (k *KeeperBenchmarkTest) observeUpkeepEvents() { FromBlock: k.startingBlock, } - ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) + ctx, cancel := context.WithTimeout(utils.TestContext(k.t), 5*time.Second) sub, err := k.chainClient.SubscribeFilterLogs(ctx, filterQuery, eventLogs) cancel() require.NoError(k.t, err, "Subscribing to upkeep performed events log shouldn't fail") @@ -430,7 +431,7 @@ func (k *KeeperBenchmarkTest) observeUpkeepEvents() { Str("Backoff", backoff.String()). Msg("Error while subscribing to Keeper Event Logs. Resubscribing...") - ctx, cancel := context.WithTimeout(context.Background(), backoff) + ctx, cancel := context.WithTimeout(utils.TestContext(k.t), backoff) sub, err = k.chainClient.SubscribeFilterLogs(ctx, filterQuery, eventLogs) cancel() if err != nil { diff --git a/integration-tests/testsetups/ocr.go b/integration-tests/testsetups/ocr.go index 5428d13ca27..8b6e5f8eda1 100644 --- a/integration-tests/testsetups/ocr.go +++ b/integration-tests/testsetups/ocr.go @@ -42,6 +42,7 @@ import ( "github.com/smartcontractkit/chainlink/integration-tests/config" "github.com/smartcontractkit/chainlink/integration-tests/contracts" "github.com/smartcontractkit/chainlink/integration-tests/testreporters" + "github.com/smartcontractkit/chainlink/integration-tests/utils" ) const ( @@ -258,7 +259,7 @@ func (o *OCRSoakTest) Setup() { // Run starts the OCR soak test func (o *OCRSoakTest) Run() { - ctx, cancel := context.WithTimeout(context.Background(), time.Second*5) + ctx, cancel := context.WithTimeout(utils.TestContext(o.t), time.Second*5) latestBlockNum, err := o.chainClient.LatestBlockNumber(ctx) cancel() require.NoError(o.t, err, "Error getting current block number") @@ -559,7 +560,7 @@ func (o *OCRSoakTest) setFilterQuery() { // WARNING: Should only be used for observation and logging. This is not a reliable way to collect events. func (o *OCRSoakTest) observeOCREvents() error { eventLogs := make(chan types.Log) - ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) + ctx, cancel := context.WithTimeout(utils.TestContext(o.t), 5*time.Second) eventSub, err := o.chainClient.SubscribeFilterLogs(ctx, o.filterQuery, eventLogs) cancel() if err != nil { @@ -593,7 +594,7 @@ func (o *OCRSoakTest) observeOCREvents() error { Str("Backoff", backoff.String()). Interface("Query", o.filterQuery). Msg("Error while subscribed to OCR Logs. Resubscribing") - ctx, cancel = context.WithTimeout(context.Background(), backoff) + ctx, cancel = context.WithTimeout(utils.TestContext(o.t), backoff) eventSub, err = o.chainClient.SubscribeFilterLogs(ctx, o.filterQuery, eventLogs) cancel() if err != nil { @@ -646,12 +647,12 @@ func (o *OCRSoakTest) collectEvents() error { timeout := time.Second * 15 o.log.Info().Interface("Filter Query", o.filterQuery).Str("Timeout", timeout.String()).Msg("Retrieving on-chain events") - ctx, cancel := context.WithTimeout(context.Background(), timeout) + ctx, cancel := context.WithTimeout(utils.TestContext(o.t), timeout) contractEvents, err := o.chainClient.FilterLogs(ctx, o.filterQuery) cancel() for err != nil { o.log.Info().Interface("Filter Query", o.filterQuery).Str("Timeout", timeout.String()).Msg("Retrieving on-chain events") - ctx, cancel := context.WithTimeout(context.Background(), timeout) + ctx, cancel := context.WithTimeout(utils.TestContext(o.t), timeout) contractEvents, err = o.chainClient.FilterLogs(ctx, o.filterQuery) cancel() if err != nil { diff --git a/integration-tests/testsetups/vrfv2.go b/integration-tests/testsetups/vrfv2.go index ccbce18a7c7..97db07b71b8 100644 --- a/integration-tests/testsetups/vrfv2.go +++ b/integration-tests/testsetups/vrfv2.go @@ -22,6 +22,7 @@ import ( "github.com/smartcontractkit/chainlink/integration-tests/client" "github.com/smartcontractkit/chainlink/integration-tests/contracts" "github.com/smartcontractkit/chainlink/integration-tests/testreporters" + "github.com/smartcontractkit/chainlink/integration-tests/utils" ) // VRFV2SoakTest defines a typical VRFV2 soak test @@ -87,7 +88,7 @@ func (v *VRFV2SoakTest) Run(t *testing.T) { Msg("Starting VRFV2 Soak Test") // set the requests to only run for a certain amount of time - testContext, testCancel := context.WithTimeout(context.Background(), v.Inputs.TestDuration) + testContext, testCancel := context.WithTimeout(utils.TestContext(t), v.Inputs.TestDuration) defer testCancel() v.NumberOfRandRequests = 0 @@ -126,7 +127,7 @@ func (v *VRFV2SoakTest) Run(t *testing.T) { //todo - need to find better way for this time.Sleep(1 * time.Minute) - loadTestMetrics, err := v.Inputs.ConsumerContract.GetLoadTestMetrics(context.Background()) + loadTestMetrics, err := v.Inputs.ConsumerContract.GetLoadTestMetrics(utils.TestContext(t)) if err != nil { l.Error().Err(err).Msg("Error Occurred when getting Load Test Metrics from Consumer contract") } diff --git a/integration-tests/universal/log_poller/helpers.go b/integration-tests/universal/log_poller/helpers.go index 748def98d18..61d66bf6097 100644 --- a/integration-tests/universal/log_poller/helpers.go +++ b/integration-tests/universal/log_poller/helpers.go @@ -79,8 +79,8 @@ var registerSingleTopicFilter = func(registry contracts.KeeperRegistry, upkeepID return nil } +// Currently Unused November 8, 2023, Might be useful in the near future so keeping it here for now // this is not really possible, log trigger doesn't support multiple topics, even if log poller does -// Unused??? // var registerMultipleTopicsFilter = func(registry contracts.KeeperRegistry, upkeepID *big.Int, emitterAddress common.Address, topics []abi.Event) error { // if len(topics) > 4 { // return errors.New("Cannot register more than 4 topics") @@ -277,29 +277,6 @@ var emitEvents = func(ctx context.Context, l zerolog.Logger, logEmitter *contrac } } -// Unused??? -// var waitForEndBlockInLogPoller = func(endBlock int64, chainID *big.Int, l zerolog.Logger, coreLogger core_logger.SugaredLogger, nodes *test_env.ClCluster) (bool, error) { -// for i := 1; i < len(nodes.Nodes); i++ { -// clNode := nodes.Nodes[i] -// orm, db, err := NewOrm(coreLogger, chainID, clNode.PostgresDb) -// if err != nil { -// return false, err -// } - -// defer db.Close() -// block, err := orm.SelectBlockByNumber(endBlock) -// if err != nil { -// return false, err -// } - -// if block == nil { -// return false, nil -// } -// } - -// return true, nil -// } - var chainHasFinalisedEndBlock = func(l zerolog.Logger, evmClient blockchain.EVMClient, endBlock int64) (bool, error) { effectiveEndBlock := endBlock + 1 lastFinalisedBlockHeader, err := evmClient.GetLatestFinalizedBlockHeader(context.Background()) diff --git a/integration-tests/universal/log_poller/scenarios.go b/integration-tests/universal/log_poller/scenarios.go index f89193ee228..955abbf2a74 100644 --- a/integration-tests/universal/log_poller/scenarios.go +++ b/integration-tests/universal/log_poller/scenarios.go @@ -1,7 +1,6 @@ package logpoller import ( - "context" "fmt" "math/big" "testing" @@ -14,6 +13,7 @@ import ( "github.com/smartcontractkit/chainlink/integration-tests/actions" "github.com/smartcontractkit/chainlink/integration-tests/contracts" "github.com/smartcontractkit/chainlink/integration-tests/contracts/ethereum" + "github.com/smartcontractkit/chainlink/integration-tests/utils" core_logger "github.com/smartcontractkit/chainlink/v2/core/logger" ) @@ -101,7 +101,7 @@ func ExecuteBasicLogPollerTest(t *testing.T, cfg *Config) { l.Info().Int("Count", len(expectedFilters)).Msg("Expected filters count") // Save block number before starting to emit events, so that we can later use it when querying logs - sb, err := testEnv.EVMClient.LatestBlockNumber(context.Background()) + sb, err := testEnv.EVMClient.LatestBlockNumber(utils.TestContext(t)) require.NoError(t, err, "Error getting latest block number") startBlock := int64(sb) @@ -123,7 +123,7 @@ func ExecuteBasicLogPollerTest(t *testing.T, cfg *Config) { l.Info().Int("Total logs emitted", totalLogsEmitted).Int64("Expected total logs emitted", expectedLogsEmitted).Str("Duration", fmt.Sprintf("%d sec", duration)).Str("LPS", fmt.Sprintf("%d/sec", totalLogsEmitted/duration)).Msg("FINISHED EVENT EMISSION") // Save block number after finishing to emit events, so that we can later use it when querying logs - eb, err := testEnv.EVMClient.LatestBlockNumber(context.Background()) + eb, err := testEnv.EVMClient.LatestBlockNumber(utils.TestContext(t)) require.NoError(t, err, "Error getting latest block number") endBlock, err := GetEndBlockToWaitFor(int64(eb), testEnv.EVMClient.GetChainID().Int64(), cfg) @@ -231,7 +231,7 @@ func ExecuteLogPollerReplay(t *testing.T, cfg *Config, consistencyTimeout string time.Sleep(5 * time.Second) // Save block number before starting to emit events, so that we can later use it when querying logs - sb, err := testEnv.EVMClient.LatestBlockNumber(context.Background()) + sb, err := testEnv.EVMClient.LatestBlockNumber(utils.TestContext(t)) require.NoError(t, err, "Error getting latest block number") startBlock := int64(sb) @@ -245,7 +245,7 @@ func ExecuteLogPollerReplay(t *testing.T, cfg *Config, consistencyTimeout string l.Info().Int("Total logs emitted", totalLogsEmitted).Int64("Expected total logs emitted", expectedLogsEmitted).Str("Duration", fmt.Sprintf("%d sec", duration)).Str("LPS", fmt.Sprintf("%d/sec", totalLogsEmitted/duration)).Msg("FINISHED EVENT EMISSION") // Save block number after finishing to emit events, so that we can later use it when querying logs - eb, err := testEnv.EVMClient.LatestBlockNumber(context.Background()) + eb, err := testEnv.EVMClient.LatestBlockNumber(utils.TestContext(t)) require.NoError(t, err, "Error getting latest block number") endBlock, err := GetEndBlockToWaitFor(int64(eb), testEnv.EVMClient.GetChainID().Int64(), cfg) @@ -422,7 +422,7 @@ func ExecuteCILogPollerTest(t *testing.T, cfg *Config) { l.Info().Int("Count", len(expectedFilters)).Msg("Expected filters count") // Save block number before starting to emit events, so that we can later use it when querying logs - sb, err := testEnv.EVMClient.LatestBlockNumber(context.Background()) + sb, err := testEnv.EVMClient.LatestBlockNumber(utils.TestContext(t)) require.NoError(t, err, "Error getting latest block number") startBlock := int64(sb) @@ -444,7 +444,7 @@ func ExecuteCILogPollerTest(t *testing.T, cfg *Config) { l.Info().Int("Total logs emitted", totalLogsEmitted).Int64("Expected total logs emitted", expectedLogsEmitted).Str("Duration", fmt.Sprintf("%d sec", duration)).Str("LPS", fmt.Sprintf("%d/sec", totalLogsEmitted/duration)).Msg("FINISHED EVENT EMISSION") // Save block number after finishing to emit events, so that we can later use it when querying logs - eb, err := testEnv.EVMClient.LatestBlockNumber(context.Background()) + eb, err := testEnv.EVMClient.LatestBlockNumber(utils.TestContext(t)) require.NoError(t, err, "Error getting latest block number") endBlock, err := GetEndBlockToWaitFor(int64(eb), testEnv.EVMClient.GetChainID().Int64(), cfg) diff --git a/integration-tests/utils/common.go b/integration-tests/utils/common.go index 9aacaeed416..5ef3209c920 100644 --- a/integration-tests/utils/common.go +++ b/integration-tests/utils/common.go @@ -1,8 +1,10 @@ package utils import ( + "context" "math/big" "net" + "testing" "github.com/smartcontractkit/chainlink/v2/core/store/models" ) @@ -33,3 +35,20 @@ func BigIntSliceContains(slice []*big.Int, b *big.Int) bool { } return false } + +// TestContext returns a context with the test's deadline, if available. +func TestContext(tb testing.TB) context.Context { + ctx := context.Background() + var cancel func() + switch t := tb.(type) { + case *testing.T: + if d, ok := t.Deadline(); ok { + ctx, cancel = context.WithDeadline(ctx, d) + } + } + if cancel == nil { + ctx, cancel = context.WithCancel(ctx) + } + tb.Cleanup(cancel) + return ctx +} From 697af4b5acab3cf8a6ae05a0aba31de3ac12b323 Mon Sep 17 00:00:00 2001 From: Tate Date: Wed, 8 Nov 2023 10:47:57 -0700 Subject: [PATCH 05/12] fix build and lint errors --- integration-tests/chaos/ocr_chaos_test.go | 4 ++-- integration-tests/smoke/automation_test.go | 11 +++++------ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/integration-tests/chaos/ocr_chaos_test.go b/integration-tests/chaos/ocr_chaos_test.go index 9d102394a54..5be7bf90a45 100644 --- a/integration-tests/chaos/ocr_chaos_test.go +++ b/integration-tests/chaos/ocr_chaos_test.go @@ -22,11 +22,11 @@ import ( "github.com/smartcontractkit/chainlink-testing-framework/networks" "github.com/smartcontractkit/chainlink-testing-framework/utils" - it_utils "github.com/smartcontract/chainlink/integration-tests/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/contracts" + it_utils "github.com/smartcontractkit/chainlink/integration-tests/utils" ) var ( @@ -195,7 +195,7 @@ func TestOCRChaos(t *testing.T) { err := ocr.RequestNewRound() require.NoError(t, err, "Error requesting new round") } - round, err := ocrInstances[0].GetLatestRound(it_utils.Context(t)) + round, err := ocrInstances[0].GetLatestRound(it_utils.TestContext(t)) g.Expect(err).ShouldNot(gomega.HaveOccurred()) l.Info().Int64("RoundID", round.RoundId.Int64()).Msg("Latest OCR Round") if round.RoundId.Int64() == chaosStartRound && !chaosApplied { diff --git a/integration-tests/smoke/automation_test.go b/integration-tests/smoke/automation_test.go index 190f52caf77..b33bc0fe518 100644 --- a/integration-tests/smoke/automation_test.go +++ b/integration-tests/smoke/automation_test.go @@ -1,7 +1,6 @@ package smoke import ( - "context" "encoding/json" "fmt" "math/big" @@ -329,7 +328,7 @@ func TestSetUpkeepTriggerConfig(t *testing.T) { time.Sleep(10 * time.Second) for i := 0; i < len(upkeepIDs); i++ { // Obtain the amount of times the upkeep has been executed so far - countersAfterSetNoMatch[i], err = consumers[i].Counter(utils.TestContext(t))) + countersAfterSetNoMatch[i], err = consumers[i].Counter(utils.TestContext(t)) require.NoError(t, err, "Failed to retrieve consumer counter for upkeep at index %d", i) l.Info().Int64("Upkeep Count", countersAfterSetNoMatch[i].Int64()).Int("Upkeep Index", i).Msg("Upkeep") } @@ -1033,11 +1032,11 @@ func setupAutomationTestDocker( // build the node config clNodeConfig := node.NewConfig(node.NewBaseConfig()) syncInterval := models.MustMakeDuration(5 * time.Minute) - clNodeConfig.Feature.LogPoller = it_utils.Ptr[bool](true) - clNodeConfig.OCR2.Enabled = it_utils.Ptr[bool](true) - clNodeConfig.Keeper.TurnLookBack = it_utils.Ptr[int64](int64(0)) + clNodeConfig.Feature.LogPoller = utils.Ptr[bool](true) + clNodeConfig.OCR2.Enabled = utils.Ptr[bool](true) + clNodeConfig.Keeper.TurnLookBack = utils.Ptr[int64](int64(0)) clNodeConfig.Keeper.Registry.SyncInterval = &syncInterval - clNodeConfig.Keeper.Registry.PerformGasOverhead = it_utils.Ptr[uint32](uint32(150000)) + clNodeConfig.Keeper.Registry.PerformGasOverhead = utils.Ptr[uint32](uint32(150000)) clNodeConfig.P2P.V2.AnnounceAddresses = &[]string{"0.0.0.0:6690"} clNodeConfig.P2P.V2.ListenAddresses = &[]string{"0.0.0.0:6690"} From 2a48aa9af57a115eb4bf9960a423c5208b685c60 Mon Sep 17 00:00:00 2001 From: Tate Date: Wed, 8 Nov 2023 10:56:37 -0700 Subject: [PATCH 06/12] bump lint and go versions --- .github/actions/golangci-lint/action.yml | 2 +- .github/workflows/integration-tests.yml | 2 +- .github/workflows/on-demand-vrfv2plus-performance-test.yml | 2 +- .tool-versions | 4 ++-- GNUmakefile | 2 +- integration-tests/.tool-versions | 4 ++-- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/actions/golangci-lint/action.yml b/.github/actions/golangci-lint/action.yml index 97755fa46ea..055960ff282 100644 --- a/.github/actions/golangci-lint/action.yml +++ b/.github/actions/golangci-lint/action.yml @@ -53,7 +53,7 @@ runs: - name: golangci-lint uses: golangci/golangci-lint-action@3a919529898de77ec3da873e3063ca4b10e7f5cc # v3.7.0 with: - version: v1.55.0 + version: v1.55.2 # We already cache these directories in setup-go skip-pkg-cache: true skip-build-cache: true diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index b882e3432f4..9294dceae6d 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -85,7 +85,7 @@ jobs: - name: Lint Go uses: golangci/golangci-lint-action@3a919529898de77ec3da873e3063ca4b10e7f5cc # v3.7.0 with: - version: v1.55.0 + version: v1.55.2 # We already cache these directories in setup-go skip-pkg-cache: true skip-build-cache: true diff --git a/.github/workflows/on-demand-vrfv2plus-performance-test.yml b/.github/workflows/on-demand-vrfv2plus-performance-test.yml index c51f7f5a2fb..b4f9f46de02 100644 --- a/.github/workflows/on-demand-vrfv2plus-performance-test.yml +++ b/.github/workflows/on-demand-vrfv2plus-performance-test.yml @@ -54,7 +54,7 @@ on: useExistingEnv: description: Set `true` to use existing environment or `false` to deploy CL node and all contracts required: false - default: false + default: "false" configBase64: description: TOML config in base64 (Needed when overriding config or providing contract addresses for existing env) required: false diff --git a/.tool-versions b/.tool-versions index 87910cf6d6f..c60396ccb86 100644 --- a/.tool-versions +++ b/.tool-versions @@ -1,7 +1,7 @@ -golang 1.21.1 +golang 1.21.4 mockery 2.35.4 nodejs 16.16.0 postgres 13.3 helm 3.10.3 zig 0.10.1 -golangci-lint 1.55.0 +golangci-lint 1.55.2 diff --git a/GNUmakefile b/GNUmakefile index 32f74e285e9..e82efd8a96c 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -134,7 +134,7 @@ config-docs: ## Generate core node configuration documentation .PHONY: golangci-lint golangci-lint: ## Run golangci-lint for all issues. [ -d "./golangci-lint" ] || mkdir ./golangci-lint && \ - docker run --rm -v $(shell pwd):/app -w /app golangci/golangci-lint:v1.55.0 golangci-lint run --max-issues-per-linter 0 --max-same-issues 0 > ./golangci-lint/$(shell date +%Y-%m-%d_%H:%M:%S).txt + docker run --rm -v $(shell pwd):/app -w /app golangci/golangci-lint:v1.55.2 golangci-lint run --max-issues-per-linter 0 --max-same-issues 0 > ./golangci-lint/$(shell date +%Y-%m-%d_%H:%M:%S).txt GORELEASER_CONFIG ?= .goreleaser.yaml diff --git a/integration-tests/.tool-versions b/integration-tests/.tool-versions index ed888c14d28..47b73e9de11 100644 --- a/integration-tests/.tool-versions +++ b/integration-tests/.tool-versions @@ -1,5 +1,5 @@ -golang 1.21.3 +golang 1.21.4 k3d 5.4.6 kubectl 1.25.5 nodejs 18.13.0 -golangci-lint 1.55.0 +golangci-lint 1.55.2 From b7f423930fb62c2f59801b6375e98d0b7cc633f9 Mon Sep 17 00:00:00 2001 From: Tate Date: Wed, 8 Nov 2023 12:00:17 -0700 Subject: [PATCH 07/12] lint weirdness in migration test --- integration-tests/migration/upgrade_version_test.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/integration-tests/migration/upgrade_version_test.go b/integration-tests/migration/upgrade_version_test.go index ddb8b892535..c851f36ec62 100644 --- a/integration-tests/migration/upgrade_version_test.go +++ b/integration-tests/migration/upgrade_version_test.go @@ -1,14 +1,12 @@ package migration import ( + "os" "testing" "github.com/stretchr/testify/require" "github.com/smartcontractkit/chainlink-testing-framework/utils" - - "os" - "github.com/smartcontractkit/chainlink/integration-tests/docker/test_env" ) From 59a72ae46786579ee66cfafff98afa2c7aed2db9 Mon Sep 17 00:00:00 2001 From: Tate Date: Wed, 8 Nov 2023 12:06:25 -0700 Subject: [PATCH 08/12] Wire the test context in the VRFV2SoakTest Run function to a parent context tied to the test. --- integration-tests/testsetups/vrfv2.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/integration-tests/testsetups/vrfv2.go b/integration-tests/testsetups/vrfv2.go index 97db07b71b8..8c5fde72168 100644 --- a/integration-tests/testsetups/vrfv2.go +++ b/integration-tests/testsetups/vrfv2.go @@ -88,7 +88,8 @@ func (v *VRFV2SoakTest) Run(t *testing.T) { Msg("Starting VRFV2 Soak Test") // set the requests to only run for a certain amount of time - testContext, testCancel := context.WithTimeout(utils.TestContext(t), v.Inputs.TestDuration) + ctx := utils.TestContext(t) + testContext, testCancel := context.WithTimeout(ctx, v.Inputs.TestDuration) defer testCancel() v.NumberOfRandRequests = 0 @@ -127,7 +128,7 @@ func (v *VRFV2SoakTest) Run(t *testing.T) { //todo - need to find better way for this time.Sleep(1 * time.Minute) - loadTestMetrics, err := v.Inputs.ConsumerContract.GetLoadTestMetrics(utils.TestContext(t)) + loadTestMetrics, err := v.Inputs.ConsumerContract.GetLoadTestMetrics(ctx) if err != nil { l.Error().Err(err).Msg("Error Occurred when getting Load Test Metrics from Consumer contract") } From 3136d6ed072c8dc31de5e87bf50f4fc85612c051 Mon Sep 17 00:00:00 2001 From: Tate Date: Thu, 9 Nov 2023 09:29:05 -0700 Subject: [PATCH 09/12] Merge conflict fix and improved .golangci lint file with fixes for those --- integration-tests/.golangci.yml | 30 ++++++++----------- integration-tests/actions/actions.go | 1 - integration-tests/actions/actions_local.go | 2 +- .../actions/ocr2vrf_actions/ocr2vrf_steps.go | 3 +- integration-tests/actions/ocr_helpers.go | 1 - .../actions/operator_forwarder_helpers.go | 6 ++-- .../chaos/automation_chaos_test.go | 2 +- integration-tests/chaos/ocr2vrf_chaos_test.go | 2 +- integration-tests/chaos/ocr_chaos_test.go | 4 +-- .../contracts/ethereum_contracts.go | 6 ++-- .../contracts/ethereum_keeper_contracts.go | 6 ++-- integration-tests/docker/test_env/cl_node.go | 6 ++-- integration-tests/load/vrfv2/gun.go | 2 +- integration-tests/load/vrfv2plus/gun.go | 2 +- integration-tests/performance/cron_test.go | 3 +- integration-tests/performance/ocr_test.go | 2 +- .../reorg/automation_reorg_test.go | 3 +- integration-tests/reorg/reorg_test.go | 3 +- integration-tests/runner_helpers.go | 4 +-- integration-tests/smoke/automation_test.go | 24 +++++++-------- integration-tests/smoke/ocr2vrf_test.go | 5 ++-- .../testreporters/keeper_benchmark.go | 2 ++ integration-tests/testreporters/profile.go | 2 +- integration-tests/testsetups/ocr.go | 3 +- .../universal/log_poller/config.go | 26 ++++++++-------- .../universal/log_poller/helpers.go | 6 ++-- .../universal/log_poller/scenarios.go | 9 ++---- integration-tests/utils/cl_node_jobs.go | 2 +- 28 files changed, 73 insertions(+), 94 deletions(-) diff --git a/integration-tests/.golangci.yml b/integration-tests/.golangci.yml index 91881a8cf76..3b2063494a7 100644 --- a/integration-tests/.golangci.yml +++ b/integration-tests/.golangci.yml @@ -16,20 +16,16 @@ linters-settings: goimports: local-prefixes: github.com/smartcontractkit/chainlink golint: - min-confidence: 1.0 + min-confidence: 0.999 gosec: excludes: - G101 - - G104 - # - G204 - # - G304 - # - G404 govet: # report about shadowed variables check-shadowing: true - errorlint: - # Allow formatting of errors without %w - errorf: false + # errorlint: + # # Allow formatting of errors without %w + # errorf: false revive: confidence: 0.8 rules: @@ -42,37 +38,37 @@ linters-settings: - name: error-naming - name: if-return - name: increment-decrement - # - name: var-naming + # - name: var-naming // doesn't work with some generated names - name: var-declaration - name: package-comments - name: range - name: receiver-naming - name: time-naming - # - name: unexported-return + - name: unexported-return - name: indent-error-flow - name: errorf - name: empty-block - name: superfluous-else - # - name: unused-parameter + - name: unused-parameter - name: unreachable-code - name: redefines-builtin-id - name: waitgroup-by-value - name: unconditional-recursion - name: struct-tag - # - name: string-format + - name: string-format - name: string-of-int - # - name: range-val-address + - name: range-val-address - name: range-val-in-closure - name: modifies-value-receiver - name: modifies-parameter - name: identical-branches - name: get-return - # - name: flag-parameter - # - name: early-return + # - name: flag-parameter // probably one we should work on doing better at in the future + # - name: early-return // probably one we should work on doing better at in the future - name: defer - name: constant-logical-expr - # - name: confusing-naming - # - name: confusing-results + - name: confusing-naming + - name: confusing-results - name: bool-literal-in-expr - name: atomic issues: diff --git a/integration-tests/actions/actions.go b/integration-tests/actions/actions.go index bacf5a9dbfa..02a25234774 100644 --- a/integration-tests/actions/actions.go +++ b/integration-tests/actions/actions.go @@ -254,7 +254,6 @@ func GetMockserverInitializerDataForOTPE( func TeardownSuite( t *testing.T, env *environment.Environment, - logsFolderPath string, chainlinkNodes []*client.ChainlinkK8sClient, optionalTestReporter testreporters.TestReporter, // Optionally pass in a test reporter to log further metrics failingLogLevel zapcore.Level, // Examines logs after the test, and fails the test if any Chainlink logs are found at or above provided level diff --git a/integration-tests/actions/actions_local.go b/integration-tests/actions/actions_local.go index f5d2a9035f5..d4913cabd8a 100644 --- a/integration-tests/actions/actions_local.go +++ b/integration-tests/actions/actions_local.go @@ -17,7 +17,7 @@ func UpgradeChainlinkNodeVersionsLocal( return fmt.Errorf("unable to upgrade node version, found empty image and version, must provide either a new image or a new version") } for _, node := range nodes { - if err := node.UpgradeVersion(node.NodeConfig, newImage, newVersion); err != nil { + if err := node.UpgradeVersion(newImage, newVersion); err != nil { return err } } diff --git a/integration-tests/actions/ocr2vrf_actions/ocr2vrf_steps.go b/integration-tests/actions/ocr2vrf_actions/ocr2vrf_steps.go index ab2104d563c..72d668076e9 100644 --- a/integration-tests/actions/ocr2vrf_actions/ocr2vrf_steps.go +++ b/integration-tests/actions/ocr2vrf_actions/ocr2vrf_steps.go @@ -173,7 +173,7 @@ func FundVRFCoordinatorV3Subscription(t *testing.T, linkToken contracts.LinkToke require.NoError(t, err, "Error waiting for TXs to complete") } -func DeployOCR2VRFContracts(t *testing.T, contractDeployer contracts.ContractDeployer, chainClient blockchain.EVMClient, linkToken contracts.LinkToken, mockETHLinkFeed contracts.MockETHLINKFeed, beaconPeriodBlocksCount *big.Int, keyID string) (contracts.DKG, contracts.VRFCoordinatorV3, contracts.VRFBeacon, contracts.VRFBeaconConsumer) { +func DeployOCR2VRFContracts(t *testing.T, contractDeployer contracts.ContractDeployer, chainClient blockchain.EVMClient, linkToken contracts.LinkToken, beaconPeriodBlocksCount *big.Int, keyID string) (contracts.DKG, contracts.VRFCoordinatorV3, contracts.VRFBeacon, contracts.VRFBeaconConsumer) { dkg, err := contractDeployer.DeployDKG() require.NoError(t, err, "Error deploying DKG Contract") @@ -306,7 +306,6 @@ func SetupOCR2VRFUniverse( contractDeployer, chainClient, linkToken, - mockETHLinkFeed, ocr2vrf_constants.BeaconPeriodBlocksCount, ocr2vrf_constants.KeyID, ) diff --git a/integration-tests/actions/ocr_helpers.go b/integration-tests/actions/ocr_helpers.go index cfc8cfe589b..4f713dcdd6d 100644 --- a/integration-tests/actions/ocr_helpers.go +++ b/integration-tests/actions/ocr_helpers.go @@ -27,7 +27,6 @@ func DeployOCRContracts( numberOfContracts int, linkTokenContract contracts.LinkToken, contractDeployer contracts.ContractDeployer, - bootstrapNode *client.ChainlinkK8sClient, workerNodes []*client.ChainlinkK8sClient, client blockchain.EVMClient, ) ([]contracts.OffchainAggregator, error) { diff --git a/integration-tests/actions/operator_forwarder_helpers.go b/integration-tests/actions/operator_forwarder_helpers.go index ab9a89f1326..a1d7135416c 100644 --- a/integration-tests/actions/operator_forwarder_helpers.go +++ b/integration-tests/actions/operator_forwarder_helpers.go @@ -82,13 +82,11 @@ func AcceptAuthorizedReceiversOperator( func ProcessNewEvent( t *testing.T, - eventSub geth.Subscription, operatorCreated chan *operator_factory.OperatorFactoryOperatorCreated, authorizedForwarderCreated chan *operator_factory.OperatorFactoryAuthorizedForwarderCreated, event *types.Log, eventDetails *abi.Event, operatorFactoryInstance contracts.OperatorFactory, - contractABI *abi.ABI, chainClient blockchain.EVMClient, ) { l := logging.GetTestLogger(t) @@ -166,8 +164,8 @@ func SubscribeOperatorFactoryEvents( eventDetails, err := contractABI.EventByID(vLog.Topics[0]) require.NoError(t, err, "Getting event details for OperatorFactory instance shouldn't fail") go ProcessNewEvent( - t, sub, operatorCreated, authorizedForwarderCreated, &vLog, - eventDetails, operatorFactoryInstance, contractABI, chainClient, + t, operatorCreated, authorizedForwarderCreated, &vLog, + eventDetails, operatorFactoryInstance, chainClient, ) if eventDetails.Name == "AuthorizedForwarderCreated" || eventDetails.Name == "OperatorCreated" { remainingExpectedEvents-- diff --git a/integration-tests/chaos/automation_chaos_test.go b/integration-tests/chaos/automation_chaos_test.go index 2691ce11879..6ebf14d806e 100644 --- a/integration-tests/chaos/automation_chaos_test.go +++ b/integration-tests/chaos/automation_chaos_test.go @@ -224,7 +224,7 @@ func TestAutomationChaos(t *testing.T) { if chainClient != nil { chainClient.GasStats().PrintStats() } - err := actions.TeardownSuite(t, testEnvironment, utils.ProjectRoot, chainlinkNodes, nil, zapcore.PanicLevel, chainClient) + err := actions.TeardownSuite(t, testEnvironment, chainlinkNodes, nil, zapcore.PanicLevel, chainClient) require.NoError(t, err, "Error tearing down environment") }) diff --git a/integration-tests/chaos/ocr2vrf_chaos_test.go b/integration-tests/chaos/ocr2vrf_chaos_test.go index 7ee91f69116..8739a5960af 100644 --- a/integration-tests/chaos/ocr2vrf_chaos_test.go +++ b/integration-tests/chaos/ocr2vrf_chaos_test.go @@ -150,7 +150,7 @@ func TestOCR2VRFChaos(t *testing.T) { require.NoError(t, err, "Retrieving on-chain wallet addresses for chainlink nodes shouldn't fail") t.Cleanup(func() { - err := actions.TeardownSuite(t, testEnvironment, utils.ProjectRoot, chainlinkNodes, nil, zapcore.PanicLevel, chainClient) + err := actions.TeardownSuite(t, testEnvironment, chainlinkNodes, nil, zapcore.PanicLevel, chainClient) require.NoError(t, err, "Error tearing down environment") }) diff --git a/integration-tests/chaos/ocr_chaos_test.go b/integration-tests/chaos/ocr_chaos_test.go index 5be7bf90a45..76e25d92000 100644 --- a/integration-tests/chaos/ocr_chaos_test.go +++ b/integration-tests/chaos/ocr_chaos_test.go @@ -164,7 +164,7 @@ func TestOCRChaos(t *testing.T) { if chainClient != nil { chainClient.GasStats().PrintStats() } - err := actions.TeardownSuite(t, testEnvironment, utils.ProjectRoot, chainlinkNodes, nil, zapcore.PanicLevel, chainClient) + err := actions.TeardownSuite(t, testEnvironment, chainlinkNodes, nil, zapcore.PanicLevel, chainClient) require.NoError(t, err, "Error tearing down environment") }) @@ -180,7 +180,7 @@ func TestOCRChaos(t *testing.T) { err = actions.FundChainlinkNodes(chainlinkNodes, chainClient, big.NewFloat(10)) require.NoError(t, err) - ocrInstances, err := actions.DeployOCRContracts(1, lt, cd, bootstrapNode, workerNodes, chainClient) + ocrInstances, err := actions.DeployOCRContracts(1, lt, cd, workerNodes, chainClient) require.NoError(t, err) err = chainClient.WaitForEvents() require.NoError(t, err) diff --git a/integration-tests/contracts/ethereum_contracts.go b/integration-tests/contracts/ethereum_contracts.go index 147442f73b4..9cb858fe007 100644 --- a/integration-tests/contracts/ethereum_contracts.go +++ b/integration-tests/contracts/ethereum_contracts.go @@ -940,7 +940,7 @@ func (f *EthereumFluxAggregator) PaymentAmount(ctx context.Context) (*big.Int, e return payment, nil } -func (f *EthereumFluxAggregator) RequestNewRound(ctx context.Context) error { +func (f *EthereumFluxAggregator) RequestNewRound(_ context.Context) error { opts, err := f.client.TransactionOpts(f.client.GetDefaultWallet()) if err != nil { return err @@ -979,7 +979,7 @@ func (f *EthereumFluxAggregator) WatchSubmissionReceived(ctx context.Context, ev } } -func (f *EthereumFluxAggregator) SetRequesterPermissions(ctx context.Context, addr common.Address, authorized bool, roundsDelay uint32) error { +func (f *EthereumFluxAggregator) SetRequesterPermissions(_ context.Context, addr common.Address, authorized bool, roundsDelay uint32) error { opts, err := f.client.TransactionOpts(f.client.GetDefaultWallet()) if err != nil { return err @@ -1020,7 +1020,7 @@ func (f *EthereumFluxAggregator) LatestRoundID(ctx context.Context) (*big.Int, e } func (f *EthereumFluxAggregator) WithdrawPayment( - ctx context.Context, + _ context.Context, from common.Address, to common.Address, amount *big.Int) error { diff --git a/integration-tests/contracts/ethereum_keeper_contracts.go b/integration-tests/contracts/ethereum_keeper_contracts.go index 2a26024b9cc..2c0250e7454 100644 --- a/integration-tests/contracts/ethereum_keeper_contracts.go +++ b/integration-tests/contracts/ethereum_keeper_contracts.go @@ -1859,7 +1859,7 @@ func (v *EthereumKeeperConsumerPerformance) GetUpkeepCount(ctx context.Context) return eligible, err } -func (v *EthereumKeeperConsumerPerformance) SetCheckGasToBurn(ctx context.Context, gas *big.Int) error { +func (v *EthereumKeeperConsumerPerformance) SetCheckGasToBurn(_ context.Context, gas *big.Int) error { opts, err := v.client.TransactionOpts(v.client.GetDefaultWallet()) if err != nil { return err @@ -1871,7 +1871,7 @@ func (v *EthereumKeeperConsumerPerformance) SetCheckGasToBurn(ctx context.Contex return v.client.ProcessTransaction(tx) } -func (v *EthereumKeeperConsumerPerformance) SetPerformGasToBurn(ctx context.Context, gas *big.Int) error { +func (v *EthereumKeeperConsumerPerformance) SetPerformGasToBurn(_ context.Context, gas *big.Int) error { opts, err := v.client.TransactionOpts(v.client.GetDefaultWallet()) if err != nil { return err @@ -1906,7 +1906,7 @@ func (v *EthereumKeeperPerformDataCheckerConsumer) Counter(ctx context.Context) return cnt, nil } -func (v *EthereumKeeperPerformDataCheckerConsumer) SetExpectedData(ctx context.Context, expectedData []byte) error { +func (v *EthereumKeeperPerformDataCheckerConsumer) SetExpectedData(_ context.Context, expectedData []byte) error { opts, err := v.client.TransactionOpts(v.client.GetDefaultWallet()) if err != nil { return err diff --git a/integration-tests/docker/test_env/cl_node.go b/integration-tests/docker/test_env/cl_node.go index 94bba3692da..3c0a6d3af76 100644 --- a/integration-tests/docker/test_env/cl_node.go +++ b/integration-tests/docker/test_env/cl_node.go @@ -120,7 +120,7 @@ func (n *ClNode) Restart(cfg *chainlink.Config) error { } // UpgradeVersion restarts the cl node with new image and version -func (n *ClNode) UpgradeVersion(cfg *chainlink.Config, newImage, newVersion string) error { +func (n *ClNode) UpgradeVersion(newImage, newVersion string) error { if newVersion == "" { return fmt.Errorf("new version is empty") } @@ -136,9 +136,9 @@ func (n *ClNode) PrimaryETHAddress() (string, error) { return n.API.PrimaryEthAddress() } -func (n *ClNode) AddBootstrapJob(verifierAddr common.Address, fromBlock uint64, chainId int64, +func (n *ClNode) AddBootstrapJob(verifierAddr common.Address, chainId int64, feedId [32]byte) (*client.Job, error) { - spec := utils.BuildBootstrapSpec(verifierAddr, chainId, fromBlock, feedId) + spec := utils.BuildBootstrapSpec(verifierAddr, chainId, feedId) return n.API.MustCreateJob(spec) } diff --git a/integration-tests/load/vrfv2/gun.go b/integration-tests/load/vrfv2/gun.go index 4e1c82bf3aa..8100baaa7f7 100644 --- a/integration-tests/load/vrfv2/gun.go +++ b/integration-tests/load/vrfv2/gun.go @@ -22,7 +22,7 @@ func SingleFeedGun(contracts *vrfv2_actions.VRFV2Contracts, keyHash [32]byte) *S } // Call implements example gun call, assertions on response bodies should be done here -func (m *SingleHashGun) Call(l *wasp.Generator) *wasp.CallResult { +func (m *SingleHashGun) Call(_ *wasp.Generator) *wasp.CallResult { err := m.contracts.LoadTestConsumer.RequestRandomness( m.keyHash, vrfConst.SubID, diff --git a/integration-tests/load/vrfv2plus/gun.go b/integration-tests/load/vrfv2plus/gun.go index 2aecc69365e..8ab278b73e9 100644 --- a/integration-tests/load/vrfv2plus/gun.go +++ b/integration-tests/load/vrfv2plus/gun.go @@ -38,7 +38,7 @@ func NewSingleHashGun( } // Call implements example gun call, assertions on response bodies should be done here -func (m *SingleHashGun) Call(l *wasp.Generator) *wasp.CallResult { +func (m *SingleHashGun) Call(_ *wasp.Generator) *wasp.CallResult { //todo - should work with multiple consumers and consumers having different keyhashes and wallets //randomly increase/decrease randomness request count per TX diff --git a/integration-tests/performance/cron_test.go b/integration-tests/performance/cron_test.go index e700a66e1f8..7e90d29221d 100644 --- a/integration-tests/performance/cron_test.go +++ b/integration-tests/performance/cron_test.go @@ -20,7 +20,6 @@ import ( "github.com/smartcontractkit/chainlink-testing-framework/k8s/pkg/helm/mockserver" mockservercfg "github.com/smartcontractkit/chainlink-testing-framework/k8s/pkg/helm/mockserver-cfg" "github.com/smartcontractkit/chainlink-testing-framework/logging" - "github.com/smartcontractkit/chainlink-testing-framework/utils" "github.com/smartcontractkit/chainlink-testing-framework/networks" @@ -44,7 +43,7 @@ func CleanupPerformanceTest( if chainClient != nil { chainClient.GasStats().PrintStats() } - err := actions.TeardownSuite(t, testEnvironment, utils.ProjectRoot, chainlinkNodes, &testReporter, zapcore.PanicLevel, chainClient) + err := actions.TeardownSuite(t, testEnvironment, chainlinkNodes, &testReporter, zapcore.PanicLevel, chainClient) require.NoError(t, err, "Error tearing down environment") } diff --git a/integration-tests/performance/ocr_test.go b/integration-tests/performance/ocr_test.go index 20c52c3d4aa..47879cebb81 100644 --- a/integration-tests/performance/ocr_test.go +++ b/integration-tests/performance/ocr_test.go @@ -53,7 +53,7 @@ func TestOCRBasic(t *testing.T) { err = actions.FundChainlinkNodes(chainlinkNodes, chainClient, big.NewFloat(.05)) require.NoError(t, err, "Error funding Chainlink nodes") - ocrInstances, err := actions.DeployOCRContracts(1, linkTokenContract, contractDeployer, bootstrapNode, workerNodes, chainClient) + ocrInstances, err := actions.DeployOCRContracts(1, linkTokenContract, contractDeployer, workerNodes, chainClient) require.NoError(t, err) err = chainClient.WaitForEvents() require.NoError(t, err, "Error waiting for events") diff --git a/integration-tests/reorg/automation_reorg_test.go b/integration-tests/reorg/automation_reorg_test.go index 36a2d703e38..58cd147201e 100644 --- a/integration-tests/reorg/automation_reorg_test.go +++ b/integration-tests/reorg/automation_reorg_test.go @@ -18,7 +18,6 @@ import ( "github.com/smartcontractkit/chainlink-testing-framework/k8s/pkg/helm/reorg" "github.com/smartcontractkit/chainlink-testing-framework/logging" "github.com/smartcontractkit/chainlink-testing-framework/networks" - "github.com/smartcontractkit/chainlink-testing-framework/utils" "github.com/smartcontractkit/chainlink/integration-tests/actions" "github.com/smartcontractkit/chainlink/integration-tests/client" @@ -169,7 +168,7 @@ func TestAutomationReorg(t *testing.T) { // Register cleanup for any test t.Cleanup(func() { - err := actions.TeardownSuite(t, testEnvironment, utils.ProjectRoot, chainlinkNodes, nil, zapcore.PanicLevel, chainClient) + err := actions.TeardownSuite(t, testEnvironment, chainlinkNodes, nil, zapcore.PanicLevel, chainClient) require.NoError(t, err, "Error tearing down environment") }) diff --git a/integration-tests/reorg/reorg_test.go b/integration-tests/reorg/reorg_test.go index 4ada9b95be5..d5fefdbc562 100644 --- a/integration-tests/reorg/reorg_test.go +++ b/integration-tests/reorg/reorg_test.go @@ -21,7 +21,6 @@ import ( mockservercfg "github.com/smartcontractkit/chainlink-testing-framework/k8s/pkg/helm/mockserver-cfg" "github.com/smartcontractkit/chainlink-testing-framework/k8s/pkg/helm/reorg" "github.com/smartcontractkit/chainlink-testing-framework/logging" - "github.com/smartcontractkit/chainlink-testing-framework/utils" "github.com/onsi/gomega" "github.com/rs/zerolog/log" @@ -86,7 +85,7 @@ func CleanupReorgTest( if chainClient != nil { chainClient.GasStats().PrintStats() } - err := actions.TeardownSuite(t, testEnvironment, utils.ProjectRoot, chainlinkNodes, nil, zapcore.PanicLevel, chainClient) + err := actions.TeardownSuite(t, testEnvironment, chainlinkNodes, nil, zapcore.PanicLevel, chainClient) require.NoError(t, err, "Error tearing down environment") } diff --git a/integration-tests/runner_helpers.go b/integration-tests/runner_helpers.go index 43268a703ac..def2ebdc1d4 100644 --- a/integration-tests/runner_helpers.go +++ b/integration-tests/runner_helpers.go @@ -122,7 +122,7 @@ func collectBranchesAndTags(results chan []string, errChan chan error) { go func() { stdOut, stdErr, err := gh.Exec("api", fmt.Sprintf("repos/%s/branches", chainlinkRepo), "-q", ".[][\"name\"]", "--paginate") if err != nil { - errChan <- fmt.Errorf("%v: %s", err, stdErr.String()) + errChan <- fmt.Errorf("%w: %s", err, stdErr.String()) } branches := strings.Split(stdOut.String(), "\n") cleanBranches := []string{} @@ -139,7 +139,7 @@ func collectBranchesAndTags(results chan []string, errChan chan error) { go func() { stdOut, stdErr, err := gh.Exec("api", fmt.Sprintf("repos/%s/tags", chainlinkRepo), "-q", ".[][\"name\"]", "--paginate") if err != nil { - errChan <- fmt.Errorf("%v: %s", err, stdErr.String()) + errChan <- fmt.Errorf("%w: %s", err, stdErr.String()) } tags := strings.Split(stdOut.String(), "\n") cleanTags := []string{} diff --git a/integration-tests/smoke/automation_test.go b/integration-tests/smoke/automation_test.go index b33bc0fe518..a4ad12db002 100644 --- a/integration-tests/smoke/automation_test.go +++ b/integration-tests/smoke/automation_test.go @@ -109,7 +109,6 @@ func SetupAutomationBasic(t *testing.T, nodeUpgrade bool) { upgradeImage string upgradeVersion string err error - testName = "basic-upkeep" ) if nodeUpgrade { upgradeImage = os.Getenv("UPGRADE_IMAGE") @@ -117,7 +116,6 @@ func SetupAutomationBasic(t *testing.T, nodeUpgrade bool) { if len(upgradeImage) == 0 || len(upgradeVersion) == 0 { t.Fatal("UPGRADE_IMAGE and UPGRADE_VERSION must be set to upgrade nodes") } - testName = "node-upgrade" } // Use the name to determine if this is a log trigger or mercury @@ -127,7 +125,7 @@ func SetupAutomationBasic(t *testing.T, nodeUpgrade bool) { isMercury := isMercuryV02 || isMercuryV03 chainClient, _, contractDeployer, linkToken, registry, registrar, testEnv := setupAutomationTestDocker( - t, testName, registryVersion, defaultOCRRegistryConfig, nodeUpgrade, isMercuryV02, isMercuryV03, + t, registryVersion, defaultOCRRegistryConfig, isMercuryV02, isMercuryV03, ) consumers, upkeepIDs := actions.DeployConsumers( @@ -241,7 +239,7 @@ func TestSetUpkeepTriggerConfig(t *testing.T) { l := logging.GetTestLogger(t) chainClient, _, contractDeployer, linkToken, registry, registrar, _ := setupAutomationTestDocker( - t, "set-trigger-config", ethereum.RegistryVersion_2_1, defaultOCRRegistryConfig, false, false, false, + t, ethereum.RegistryVersion_2_1, defaultOCRRegistryConfig, false, false, ) consumers, upkeepIDs := actions.DeployConsumers( @@ -416,7 +414,7 @@ func TestAutomationAddFunds(t *testing.T) { t.Run(name, func(t *testing.T) { t.Parallel() chainClient, _, contractDeployer, linkToken, registry, registrar, _ := setupAutomationTestDocker( - t, "add-funds", registryVersion, defaultOCRRegistryConfig, false, false, false, + t, registryVersion, defaultOCRRegistryConfig, false, false, ) consumers, upkeepIDs := actions.DeployConsumers(t, registry, registrar, linkToken, contractDeployer, chainClient, defaultAmountOfUpkeeps, big.NewInt(1), automationDefaultUpkeepGasLimit, false, false) @@ -467,7 +465,7 @@ func TestAutomationPauseUnPause(t *testing.T) { t.Parallel() l := logging.GetTestLogger(t) chainClient, _, contractDeployer, linkToken, registry, registrar, _ := setupAutomationTestDocker( - t, "pause-unpause", registryVersion, defaultOCRRegistryConfig, false, false, false, + t, registryVersion, defaultOCRRegistryConfig, false, false, ) consumers, upkeepIDs := actions.DeployConsumers(t, registry, registrar, linkToken, contractDeployer, chainClient, defaultAmountOfUpkeeps, big.NewInt(automationDefaultLinkFunds), automationDefaultUpkeepGasLimit, false, false) @@ -550,7 +548,7 @@ func TestAutomationRegisterUpkeep(t *testing.T) { t.Parallel() l := logging.GetTestLogger(t) chainClient, _, contractDeployer, linkToken, registry, registrar, _ := setupAutomationTestDocker( - t, "register-upkeep", registryVersion, defaultOCRRegistryConfig, false, false, false, + t, registryVersion, defaultOCRRegistryConfig, false, false, ) consumers, upkeepIDs := actions.DeployConsumers(t, registry, registrar, linkToken, contractDeployer, chainClient, defaultAmountOfUpkeeps, big.NewInt(automationDefaultLinkFunds), automationDefaultUpkeepGasLimit, false, false) @@ -621,7 +619,7 @@ func TestAutomationPauseRegistry(t *testing.T) { t.Run(name, func(t *testing.T) { t.Parallel() chainClient, _, contractDeployer, linkToken, registry, registrar, _ := setupAutomationTestDocker( - t, "pause-registry", registryVersion, defaultOCRRegistryConfig, false, false, false, + t, registryVersion, defaultOCRRegistryConfig, false, false, ) consumers, upkeepIDs := actions.DeployConsumers(t, registry, registrar, linkToken, contractDeployer, chainClient, defaultAmountOfUpkeeps, big.NewInt(automationDefaultLinkFunds), automationDefaultUpkeepGasLimit, false, false) @@ -679,7 +677,7 @@ func TestAutomationKeeperNodesDown(t *testing.T) { t.Parallel() l := logging.GetTestLogger(t) chainClient, chainlinkNodes, contractDeployer, linkToken, registry, registrar, _ := setupAutomationTestDocker( - t, "keeper-nodes-down", registryVersion, defaultOCRRegistryConfig, false, false, false, + t, registryVersion, defaultOCRRegistryConfig, false, false, ) consumers, upkeepIDs := actions.DeployConsumers(t, registry, registrar, linkToken, contractDeployer, chainClient, defaultAmountOfUpkeeps, big.NewInt(automationDefaultLinkFunds), automationDefaultUpkeepGasLimit, false, false) @@ -764,7 +762,7 @@ func TestAutomationPerformSimulation(t *testing.T) { t.Run(name, func(t *testing.T) { t.Parallel() chainClient, _, contractDeployer, linkToken, registry, registrar, _ := setupAutomationTestDocker( - t, "perform-simulation", registryVersion, defaultOCRRegistryConfig, false, false, false, + t, registryVersion, defaultOCRRegistryConfig, false, false, ) consumersPerformance, _ := actions.DeployPerformanceConsumers( @@ -828,7 +826,7 @@ func TestAutomationCheckPerformGasLimit(t *testing.T) { t.Parallel() l := logging.GetTestLogger(t) chainClient, chainlinkNodes, contractDeployer, linkToken, registry, registrar, _ := setupAutomationTestDocker( - t, "gas-limit", registryVersion, defaultOCRRegistryConfig, false, false, false, + t, registryVersion, defaultOCRRegistryConfig, false, false, ) consumersPerformance, upkeepIDs := actions.DeployPerformanceConsumers( @@ -942,7 +940,7 @@ func TestUpdateCheckData(t *testing.T) { t.Parallel() l := logging.GetTestLogger(t) chainClient, _, contractDeployer, linkToken, registry, registrar, _ := setupAutomationTestDocker( - t, "update-check-data", registryVersion, defaultOCRRegistryConfig, false, false, false, + t, registryVersion, defaultOCRRegistryConfig, false, false, ) performDataChecker, upkeepIDs := actions.DeployPerformDataCheckerConsumers( @@ -1007,10 +1005,8 @@ type TestConfig struct { func setupAutomationTestDocker( t *testing.T, - testName string, registryVersion ethereum.KeeperRegistryVersion, registryConfig contracts.KeeperRegistrySettings, - statefulDb bool, isMercuryV02 bool, isMercuryV03 bool, ) ( diff --git a/integration-tests/smoke/ocr2vrf_test.go b/integration-tests/smoke/ocr2vrf_test.go index dc939872509..57bd5412b14 100644 --- a/integration-tests/smoke/ocr2vrf_test.go +++ b/integration-tests/smoke/ocr2vrf_test.go @@ -15,7 +15,6 @@ import ( eth "github.com/smartcontractkit/chainlink-testing-framework/k8s/pkg/helm/ethereum" "github.com/smartcontractkit/chainlink-testing-framework/logging" "github.com/smartcontractkit/chainlink-testing-framework/networks" - "github.com/smartcontractkit/chainlink-testing-framework/utils" "github.com/smartcontractkit/chainlink/integration-tests/actions" "github.com/smartcontractkit/chainlink/integration-tests/actions/ocr2vrf_actions" @@ -45,7 +44,7 @@ func TestOCR2VRFRedeemModel(t *testing.T) { require.NoError(t, err, "Retreiving on-chain wallet addresses for chainlink nodes shouldn't fail") t.Cleanup(func() { - err := actions.TeardownSuite(t, testEnvironment, utils.ProjectRoot, chainlinkNodes, nil, zapcore.ErrorLevel, chainClient) + err := actions.TeardownSuite(t, testEnvironment, chainlinkNodes, nil, zapcore.ErrorLevel, chainClient) require.NoError(t, err, "Error tearing down environment") }) @@ -107,7 +106,7 @@ func TestOCR2VRFFulfillmentModel(t *testing.T) { require.NoError(t, err, "Retreiving on-chain wallet addresses for chainlink nodes shouldn't fail") t.Cleanup(func() { - err := actions.TeardownSuite(t, testEnvironment, utils.ProjectRoot, chainlinkNodes, nil, zapcore.ErrorLevel, chainClient) + err := actions.TeardownSuite(t, testEnvironment, chainlinkNodes, nil, zapcore.ErrorLevel, chainClient) require.NoError(t, err, "Error tearing down environment") }) diff --git a/integration-tests/testreporters/keeper_benchmark.go b/integration-tests/testreporters/keeper_benchmark.go index baf97265c6c..e9f2eaad7c5 100644 --- a/integration-tests/testreporters/keeper_benchmark.go +++ b/integration-tests/testreporters/keeper_benchmark.go @@ -305,6 +305,8 @@ func (k *KeeperBenchmarkTestReporter) SendSlackNotification(t *testing.T, slackC } // intListStats helper calculates some statistics on an int list: avg, median, 90pct, 99pct, max +// +//nolint:revive func intListStats(in []int64) (float64, int64, int64, int64, int64) { length := len(in) if length == 0 { diff --git a/integration-tests/testreporters/profile.go b/integration-tests/testreporters/profile.go index 9ac7713e94d..ab9dec138e4 100644 --- a/integration-tests/testreporters/profile.go +++ b/integration-tests/testreporters/profile.go @@ -54,7 +54,7 @@ func (c *ChainlinkProfileTestReporter) WriteReport(folderLocation string) error } // SendNotification hasn't been implemented for this test -func (c *ChainlinkProfileTestReporter) SendSlackNotification(t *testing.T, slackClient *slack.Client) error { +func (c *ChainlinkProfileTestReporter) SendSlackNotification(_ *testing.T, _ *slack.Client) error { log.Warn().Msg("No Slack notification integration for Chainlink profile tests") return nil } diff --git a/integration-tests/testsetups/ocr.go b/integration-tests/testsetups/ocr.go index 8b6e5f8eda1..3fb9dd9844a 100644 --- a/integration-tests/testsetups/ocr.go +++ b/integration-tests/testsetups/ocr.go @@ -164,7 +164,7 @@ func (o *OCRSoakTest) DeployEnvironment(customChainlinkNetworkTOML string) { } // LoadEnvironment loads an existing test environment using the provided URLs -func (o *OCRSoakTest) LoadEnvironment(chainlinkURLs []string, chainURL, mockServerURL string) { +func (o *OCRSoakTest) LoadEnvironment(chainlinkURLs []string, mockServerURL string) { var ( network = networks.MustGetSelectedNetworksFromEnv()[0] err error @@ -242,7 +242,6 @@ func (o *OCRSoakTest) Setup() { o.Inputs.NumberOfContracts, linkTokenContract, contractDeployer, - o.bootstrapNode, o.workerNodes, o.chainClient, ) diff --git a/integration-tests/universal/log_poller/config.go b/integration-tests/universal/log_poller/config.go index ffb30d6f79b..78a0da46bc6 100644 --- a/integration-tests/universal/log_poller/config.go +++ b/integration-tests/universal/log_poller/config.go @@ -132,33 +132,33 @@ func (c *Config) validate() error { err := c.General.validate() if err != nil { - return fmt.Errorf("General config validation failed: %v", err) + return fmt.Errorf("General config validation failed: %w", err) } switch c.General.Generator { case GeneratorType_WASP: if c.Wasp == nil { - return fmt.Errorf("Wasp config is nil") + return fmt.Errorf("wasp config is nil") } if c.Wasp.Load == nil { - return fmt.Errorf("Wasp load config is nil") + return fmt.Errorf("wasp load config is nil") } err = c.Wasp.validate() if err != nil { - return fmt.Errorf("Wasp config validation failed: %v", err) + return fmt.Errorf("wasp config validation failed: %w", err) } case GeneratorType_Looped: if c.LoopedConfig == nil { - return fmt.Errorf("Looped config is nil") + return fmt.Errorf("looped config is nil") } err = c.LoopedConfig.validate() if err != nil { - return fmt.Errorf("Looped config validation failed: %v", err) + return fmt.Errorf("looped config validation failed: %w", err) } default: - return fmt.Errorf("Unknown generator type: %s", c.General.Generator) + return fmt.Errorf("unknown generator type: %s", c.General.Generator) } return nil @@ -166,15 +166,15 @@ func (c *Config) validate() error { func (g *General) validate() error { if g.Generator == "" { - return fmt.Errorf("Generator is empty") + return fmt.Errorf("generator is empty") } if g.Contracts == 0 { - return fmt.Errorf("Contracts is 0, but must be > 0") + return fmt.Errorf("contracts is 0, but must be > 0") } if g.EventsPerTx == 0 { - return fmt.Errorf("Events_per_tx is 0, but must be > 0") + return fmt.Errorf("events_per_tx is 0, but must be > 0") } return nil @@ -187,7 +187,7 @@ func (w *WaspConfig) validate() error { err := w.Load.validate() if err != nil { - return fmt.Errorf("Load config validation failed: %v", err) + return fmt.Errorf("Load config validation failed: %w", err) } return nil @@ -195,11 +195,11 @@ func (w *WaspConfig) validate() error { func (l *Load) validate() error { if l.RPS == 0 && l.LPS == 0 { - return fmt.Errorf("Either RPS or LPS needs to be set") + return fmt.Errorf("either RPS or LPS needs to be set") } if l.RPS != 0 && l.LPS != 0 { - return fmt.Errorf("Only one of RPS or LPS can be set") + return fmt.Errorf("only one of RPS or LPS can be set") } if l.Duration == nil { diff --git a/integration-tests/universal/log_poller/helpers.go b/integration-tests/universal/log_poller/helpers.go index e27b7caed8f..7102f58ef22 100644 --- a/integration-tests/universal/log_poller/helpers.go +++ b/integration-tests/universal/log_poller/helpers.go @@ -21,6 +21,8 @@ import ( "github.com/scylladb/go-reflectx" "github.com/stretchr/testify/require" + "github.com/smartcontractkit/wasp" + "github.com/smartcontractkit/chainlink-testing-framework/blockchain" ctf_test_env "github.com/smartcontractkit/chainlink-testing-framework/docker/test_env" "github.com/smartcontractkit/chainlink-testing-framework/logging" @@ -28,7 +30,6 @@ import ( evmcfg "github.com/smartcontractkit/chainlink/v2/core/chains/evm/config/toml" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller" - lpEvm "github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller" cltypes "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/automation_utils_2_1" le "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/log_emitter" @@ -38,13 +39,11 @@ import ( "github.com/smartcontractkit/chainlink/integration-tests/actions" "github.com/smartcontractkit/chainlink/integration-tests/client" - "github.com/stretchr/testify/require" "github.com/smartcontractkit/chainlink/integration-tests/contracts" "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/sqlx" it_utils "github.com/smartcontractkit/chainlink/integration-tests/utils" ) @@ -989,7 +988,6 @@ var ( func setupLogPollerTestDocker( t *testing.T, - testName string, registryVersion ethereum.KeeperRegistryVersion, registryConfig contracts.KeeperRegistrySettings, upkeepsNeeded int, diff --git a/integration-tests/universal/log_poller/scenarios.go b/integration-tests/universal/log_poller/scenarios.go index c7c4bae4deb..886547d46e1 100644 --- a/integration-tests/universal/log_poller/scenarios.go +++ b/integration-tests/universal/log_poller/scenarios.go @@ -32,12 +32,11 @@ func ExecuteBasicLogPollerTest(t *testing.T, cfg *Config) { var ( err error - testName = "basic-log-poller" upKeepsNeeded = cfg.General.Contracts * len(cfg.General.EventsToEmit) ) chainClient, _, contractDeployer, linkToken, registry, registrar, testEnv := setupLogPollerTestDocker( - t, testName, ethereum.RegistryVersion_2_1, defaultOCRRegistryConfig, upKeepsNeeded, time.Duration(500*time.Millisecond), cfg.General.UseFinalityTag, + t, ethereum.RegistryVersion_2_1, defaultOCRRegistryConfig, upKeepsNeeded, time.Duration(500*time.Millisecond), cfg.General.UseFinalityTag, ) _, upkeepIDs := actions.DeployConsumers( @@ -195,13 +194,12 @@ func ExecuteLogPollerReplay(t *testing.T, cfg *Config, consistencyTimeout string var ( err error - testName = "replay-log-poller" upKeepsNeeded = cfg.General.Contracts * len(cfg.General.EventsToEmit) ) // we set blockBackfillDepth to 0, to make sure nothing will be backfilled and won't interfere with our test chainClient, _, contractDeployer, linkToken, registry, registrar, testEnv := setupLogPollerTestDocker( - t, testName, ethereum.RegistryVersion_2_1, defaultOCRRegistryConfig, upKeepsNeeded, time.Duration(1000*time.Millisecond), cfg.General.UseFinalityTag) + t, ethereum.RegistryVersion_2_1, defaultOCRRegistryConfig, upKeepsNeeded, time.Duration(1000*time.Millisecond), cfg.General.UseFinalityTag) _, upkeepIDs := actions.DeployConsumers( t, @@ -353,12 +351,11 @@ func ExecuteCILogPollerTest(t *testing.T, cfg *Config) { var ( err error - testName = "ci-log-poller" upKeepsNeeded = cfg.General.Contracts * len(cfg.General.EventsToEmit) ) chainClient, _, contractDeployer, linkToken, registry, registrar, testEnv := setupLogPollerTestDocker( - t, testName, ethereum.RegistryVersion_2_1, defaultOCRRegistryConfig, upKeepsNeeded, time.Duration(1000*time.Millisecond), cfg.General.UseFinalityTag, + t, ethereum.RegistryVersion_2_1, defaultOCRRegistryConfig, upKeepsNeeded, time.Duration(1000*time.Millisecond), cfg.General.UseFinalityTag, ) _, upkeepIDs := actions.DeployConsumers( diff --git a/integration-tests/utils/cl_node_jobs.go b/integration-tests/utils/cl_node_jobs.go index 16f3c886170..65dc6e4e392 100644 --- a/integration-tests/utils/cl_node_jobs.go +++ b/integration-tests/utils/cl_node_jobs.go @@ -17,7 +17,7 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/store/models" ) -func BuildBootstrapSpec(verifierAddr common.Address, chainID int64, fromBlock uint64, feedId [32]byte) *coreClient.OCR2TaskJobSpec { +func BuildBootstrapSpec(verifierAddr common.Address, chainID int64, feedId [32]byte) *coreClient.OCR2TaskJobSpec { hash := common.BytesToHash(feedId[:]) return &coreClient.OCR2TaskJobSpec{ Name: fmt.Sprintf("bootstrap-%s", uuid.NewString()), From 42d3655023a9720ca69b745caa3b5ba7a97c8e9c Mon Sep 17 00:00:00 2001 From: Tate Date: Thu, 9 Nov 2023 09:40:24 -0700 Subject: [PATCH 10/12] One more .golangci cleanup --- integration-tests/.golangci.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/integration-tests/.golangci.yml b/integration-tests/.golangci.yml index 3b2063494a7..d22b26b8260 100644 --- a/integration-tests/.golangci.yml +++ b/integration-tests/.golangci.yml @@ -23,9 +23,6 @@ linters-settings: govet: # report about shadowed variables check-shadowing: true - # errorlint: - # # Allow formatting of errors without %w - # errorf: false revive: confidence: 0.8 rules: From 8baaf979e626afad13dcfba487e8f0976f25574d Mon Sep 17 00:00:00 2001 From: Tate Date: Mon, 13 Nov 2023 08:38:37 -0700 Subject: [PATCH 11/12] Fix newly added lint errors --- integration-tests/universal/log_poller/helpers.go | 1 + 1 file changed, 1 insertion(+) diff --git a/integration-tests/universal/log_poller/helpers.go b/integration-tests/universal/log_poller/helpers.go index 011dfd6bcc9..08ceb4a7be4 100644 --- a/integration-tests/universal/log_poller/helpers.go +++ b/integration-tests/universal/log_poller/helpers.go @@ -1051,6 +1051,7 @@ func setupLogPollerTestDocker( SlotsPerEpoch: 2, }). Build() + require.NoError(t, err, "Error building ethereum network config") env, err = test_env.NewCLTestEnvBuilder(). WithTestLogger(t). From 6bf6b9da8530c24a0a8b4707ac78ef470340aa9d Mon Sep 17 00:00:00 2001 From: Tate Date: Mon, 13 Nov 2023 08:46:55 -0700 Subject: [PATCH 12/12] add build to integration-tests makefile --- integration-tests/Makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/integration-tests/Makefile b/integration-tests/Makefile index a9257686104..fb4bfa74f3e 100644 --- a/integration-tests/Makefile +++ b/integration-tests/Makefile @@ -59,6 +59,9 @@ install_gotestfmt: lint: golangci-lint --color=always run ./... --fix -v +build: + @go build ./... && SELECTED_NETWORKS=SIMULATED go test -run=^# ./... + # Builds the test image # tag: the tag for the test image being built, example: tag=tate # base_tag: the tag for the base-test-image to use, example: base_tag=latest