From 9eff5d9c23bb77b4e06de1cc9404c8845b2d5cf0 Mon Sep 17 00:00:00 2001 From: Bartek Tofel Date: Fri, 3 Nov 2023 16:06:44 +0100 Subject: [PATCH 01/15] move workflow to correct directory --- .../on-demand-log-poller.yml} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename .github/{log_poller_on_demand.yml => workflows/on-demand-log-poller.yml} (95%) diff --git a/.github/log_poller_on_demand.yml b/.github/workflows/on-demand-log-poller.yml similarity index 95% rename from .github/log_poller_on_demand.yml rename to .github/workflows/on-demand-log-poller.yml index 856d1e02349..c5470a5a3dc 100644 --- a/.github/log_poller_on_demand.yml +++ b/.github/workflows/on-demand-log-poller.yml @@ -31,7 +31,7 @@ on: default: "Sepolia" required: true fundingKey: - description: Private key used to fund the contracts + description: Private key used to fund the contracts (must have sufficient ETH and LINK!) required: true rpcURL: description: RPC URL to use From 54291ef7a809517e30df3fd0163049390d457287 Mon Sep 17 00:00:00 2001 From: Bartek Tofel Date: Mon, 6 Nov 2023 11:58:38 +0100 Subject: [PATCH 02/15] streamline on-demand values a bit --- integration-tests/docker/test_env/test_env.go | 17 +++++++++++++++++ .../reorg/log_poller_maybe_reorg_test.go | 4 ++-- .../universal/log_poller/config.go | 11 ++++++----- .../universal/log_poller/scenarios.go | 2 +- 4 files changed, 26 insertions(+), 8 deletions(-) diff --git a/integration-tests/docker/test_env/test_env.go b/integration-tests/docker/test_env/test_env.go index e067e46090d..506b1410459 100644 --- a/integration-tests/docker/test_env/test_env.go +++ b/integration-tests/docker/test_env/test_env.go @@ -187,6 +187,8 @@ func (te *CLClusterTestEnv) Cleanup() error { return errors.New("chainlink nodes are nil, unable cleanup chainlink nodes") } + te.logWhetherAllContainersAreRunning() + // TODO: This is an imperfect and temporary solution, see TT-590 for a more sustainable solution // Collect logs if the test fails, or if we just want them if te.t.Failed() || os.Getenv("TEST_LOG_COLLECT") == "true" { @@ -216,6 +218,21 @@ func (te *CLClusterTestEnv) Cleanup() error { return nil } +func (te *CLClusterTestEnv) logWhetherAllContainersAreRunning() { + for _, node := range te.ClCluster.Nodes { + isCLRunning := node.Container.IsRunning() + isDBRunning := node.PostgresDb.Container.IsRunning() + + if !isCLRunning { + te.l.Warn().Str("Node", node.ContainerName).Msg("Chainlink node was not running, when test ended") + } + + if !isDBRunning { + te.l.Warn().Str("Node", node.ContainerName).Msg("Postgres DB is not running, when test ended") + } + } +} + // collectTestLogs collects the logs from all the Chainlink nodes in the test environment and writes them to local files func (te *CLClusterTestEnv) collectTestLogs() error { te.l.Info().Msg("Collecting test logs") diff --git a/integration-tests/reorg/log_poller_maybe_reorg_test.go b/integration-tests/reorg/log_poller_maybe_reorg_test.go index 4e802bdb09c..0176fdbbdd6 100644 --- a/integration-tests/reorg/log_poller_maybe_reorg_test.go +++ b/integration-tests/reorg/log_poller_maybe_reorg_test.go @@ -20,8 +20,8 @@ func TestLogPollerFromEnv(t *testing.T) { ExecutionCount: 100, }, FuzzConfig: logpoller.FuzzConfig{ - MinEmitWaitTimeMs: 800, - MaxEmitWaitTimeMs: 1200, + MinEmitWaitTimeMs: 400, + MaxEmitWaitTimeMs: 600, }, }, } diff --git a/integration-tests/universal/log_poller/config.go b/integration-tests/universal/log_poller/config.go index 623fa6606ed..7297e811241 100644 --- a/integration-tests/universal/log_poller/config.go +++ b/integration-tests/universal/log_poller/config.go @@ -112,11 +112,12 @@ func (c *Config) OverrideFromEnv() error { if c.General.Generator == GeneratorType_WASP { c.Wasp.Load.Duration = &d } else { - // make the looped generator approximately run for desired duration - // on average we will emit 1 event per second - c.LoopedConfig.FuzzConfig.MinEmitWaitTimeMs = 900 - c.LoopedConfig.FuzzConfig.MaxEmitWaitTimeMs = 1100 - c.LoopedConfig.ContractConfig.ExecutionCount = int(d.Duration().Seconds()) + // this is completely arbitrary and practice shows that even with this values + // test executes much longer than specified, probably due to network latency + c.LoopedConfig.FuzzConfig.MinEmitWaitTimeMs = 400 + c.LoopedConfig.FuzzConfig.MaxEmitWaitTimeMs = 600 + // divide by 4 based on past runs, but we should do it in a better way + c.LoopedConfig.ContractConfig.ExecutionCount = int(d.Duration().Seconds() / 4) } } diff --git a/integration-tests/universal/log_poller/scenarios.go b/integration-tests/universal/log_poller/scenarios.go index d14a3bcb2a7..1110a2f8caf 100644 --- a/integration-tests/universal/log_poller/scenarios.go +++ b/integration-tests/universal/log_poller/scenarios.go @@ -309,7 +309,7 @@ func ExecuteLogPollerReplay(t *testing.T, cfg *Config, consistencyTimeout string require.Equal(t, "Replay started", response.Data.Attributes.Message, "Unexpected response message from log poller's replay") } - l.Warn().Str("Duration", consistencyTimeout).Msg("Waiting for logs to be processed by all nodes and for chain to advance beyond finality") + l.Warn().Str("Duration", consistencyTimeout).Msg("Waiting for replay logs to be processed by all nodes") gom.Eventually(func(g gomega.Gomega) { logCountMatches, err := clNodesHaveExpectedLogCount(startBlock, endBlock, testEnv.EVMClient.GetChainID(), totalLogsEmitted, expectedFilters, l, coreLogger, testEnv.ClCluster) From d2f2aacff37a2a23fb42e8bbc3213e9b0d08211c Mon Sep 17 00:00:00 2001 From: Bartek Tofel Date: Mon, 6 Nov 2023 12:07:41 +0100 Subject: [PATCH 03/15] get RPC urls and private keys from secrets --- .github/workflows/on-demand-log-poller.yml | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/.github/workflows/on-demand-log-poller.yml b/.github/workflows/on-demand-log-poller.yml index c5470a5a3dc..488ac4320f2 100644 --- a/.github/workflows/on-demand-log-poller.yml +++ b/.github/workflows/on-demand-log-poller.yml @@ -30,15 +30,6 @@ on: description: Network to use (only Sepolia or Mumbai) default: "Sepolia" required: true - fundingKey: - description: Private key used to fund the contracts (must have sufficient ETH and LINK!) - required: true - rpcURL: - description: RPC URL to use - required: true - wsURL: - description: WS URL to use - required: true jobs: test: @@ -59,8 +50,8 @@ jobs: CHAINLINK_IMAGE: ${{ inputs.chainlinkImage }} CHAINLINK_VERSION: ${{ inputs.chainlinkVersion }} SELECTED_NETWORKS: ${{ inputs.selectedNetworks }} - EVM_KEYS: ${{ inputs.fundingKey }} - EVM_HTTP_URLS: ${{ inputs.rpcURL }} - EVM_URLS: ${{ inputs.wsURL }} + EVM_KEYS: ${{ secrets.ctfFundingKey }} + EVM_HTTP_URLS: ${{ secrets.ctfRpcURL }} + EVM_URLS: ${{ secrets.ctfWsURL }} run: | go test -v -timeout 5h -run=TestLogPollerFromEnv integration-tests/reorg/log_poller_maybe_reorg_test.go \ No newline at end of file From a5a6798cf7f0dcdbdaa9e24c4d6f2e0ef88f9c0b Mon Sep 17 00:00:00 2001 From: Bartek Tofel Date: Mon, 6 Nov 2023 12:18:58 +0100 Subject: [PATCH 04/15] download and run from inside the test folder --- .github/workflows/on-demand-log-poller.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/on-demand-log-poller.yml b/.github/workflows/on-demand-log-poller.yml index 488ac4320f2..0e6923353e5 100644 --- a/.github/workflows/on-demand-log-poller.yml +++ b/.github/workflows/on-demand-log-poller.yml @@ -54,4 +54,6 @@ jobs: EVM_HTTP_URLS: ${{ secrets.ctfRpcURL }} EVM_URLS: ${{ secrets.ctfWsURL }} run: | - go test -v -timeout 5h -run=TestLogPollerFromEnv integration-tests/reorg/log_poller_maybe_reorg_test.go \ No newline at end of file + cd integration-tests + go mod download + go test -v -timeout 5h -run=TestLogPollerFromEnv ./reorg/log_poller_maybe_reorg_test.go \ No newline at end of file From 510d504a50a38230e0efd7da52bdebe216bfde76 Mon Sep 17 00:00:00 2001 From: Bartek Tofel Date: Mon, 6 Nov 2023 12:26:56 +0100 Subject: [PATCH 05/15] checkout repo before running tests --- .github/workflows/on-demand-log-poller.yml | 31 +++++++++++++--------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/.github/workflows/on-demand-log-poller.yml b/.github/workflows/on-demand-log-poller.yml index 0e6923353e5..3c3792a04d4 100644 --- a/.github/workflows/on-demand-log-poller.yml +++ b/.github/workflows/on-demand-log-poller.yml @@ -33,6 +33,18 @@ on: jobs: test: + env: + CONTRACTS: ${{ inputs.contracts }} + EVENTS_PER_TX: ${{ inputs.eventsPerTx }} + LOAD_DURATION: ${{ inputs.loadDuration }} + USE_FINALITY_TAG: ${{ inputs.useFinalityTag }} + CHAINLINK_IMAGE: ${{ inputs.chainlinkImage }} + CHAINLINK_VERSION: ${{ inputs.chainlinkVersion }} + SELECTED_NETWORKS: ${{ inputs.selectedNetworks }} + EVM_KEYS: ${{ inputs.ctfFundingKey }} + EVM_HTTP_URLS: ${{ inputs.ctfRpcURL }} + EVM_URLS: ${{ inputs.ctfWsURL }} + REF_NAME: ${{ github.head_ref || github.ref_name }} runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -41,19 +53,12 @@ jobs: with: go-version-file: "integration-tests/go.mod" cache: true - - name: Show overrides - env: - CONTRACTS: ${{ inputs.contracts }} - EVENTS_PER_TX: ${{ inputs.eventsPerTx }} - LOAD_DURATION: ${{ inputs.loadDuration }} - USE_FINALITY_TAG: ${{ inputs.useFinalityTag }} - CHAINLINK_IMAGE: ${{ inputs.chainlinkImage }} - CHAINLINK_VERSION: ${{ inputs.chainlinkVersion }} - SELECTED_NETWORKS: ${{ inputs.selectedNetworks }} - EVM_KEYS: ${{ secrets.ctfFundingKey }} - EVM_HTTP_URLS: ${{ secrets.ctfRpcURL }} - EVM_URLS: ${{ secrets.ctfWsURL }} + - name: Checkout the repo + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + with: + ref: ${{ env.REF_NAME }} + - name: Run tests run: | cd integration-tests go mod download - go test -v -timeout 5h -run=TestLogPollerFromEnv ./reorg/log_poller_maybe_reorg_test.go \ No newline at end of file + go test -v -timeout 5h -v -count=1 -run ^TestLogPollerFromEnv$ ./reorg \ No newline at end of file From d0a68eb64645ea9f7fcb8d2f831a7f0e5808a50d Mon Sep 17 00:00:00 2001 From: Bartek Tofel Date: Mon, 6 Nov 2023 12:43:38 +0100 Subject: [PATCH 06/15] get inputs and mask them --- .github/workflows/on-demand-log-poller.yml | 35 ++++++++++++++++++---- 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/.github/workflows/on-demand-log-poller.yml b/.github/workflows/on-demand-log-poller.yml index 3c3792a04d4..b1351334561 100644 --- a/.github/workflows/on-demand-log-poller.yml +++ b/.github/workflows/on-demand-log-poller.yml @@ -27,9 +27,23 @@ on: default: "v2.7.0-beta0" required: true selectedNetworks: - description: Network to use (only Sepolia or Mumbai) - default: "Sepolia" + type: choice + options: + - "SIMULATED" + - "SEPOLIA" + - "MUMBAI" + fundingPrivateKey: + description: Private funding key (Skip for Simulated) required: true + type: string + wsURL: + description: WS URL for the network (Skip for Simulated) + required: true + type: string + httpURL: + description: HTTP URL for the network (Skip for Simulated) + required: true + type: string jobs: test: @@ -41,13 +55,22 @@ jobs: CHAINLINK_IMAGE: ${{ inputs.chainlinkImage }} CHAINLINK_VERSION: ${{ inputs.chainlinkVersion }} SELECTED_NETWORKS: ${{ inputs.selectedNetworks }} - EVM_KEYS: ${{ inputs.ctfFundingKey }} - EVM_HTTP_URLS: ${{ inputs.ctfRpcURL }} - EVM_URLS: ${{ inputs.ctfWsURL }} REF_NAME: ${{ github.head_ref || github.ref_name }} runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - name: Get Inputs + run: | + EVM_URLS=$(jq -r '.inputs.wsURL' $GITHUB_EVENT_PATH) + EVM_HTTP_URLS=$(jq -r '.inputs.httpURL' $GITHUB_EVENT_PATH) + EVM_KEYS=$(jq -r '.inputs.fundingPrivateKey' $GITHUB_EVENT_PATH) + + echo ::add-mask::$EVM_URLS + echo ::add-mask::$EVM_HTTP_URLS + echo ::add-mask::$EVM_KEYS + + echo EVM_URLS=$EVM_URLS >> $GITHUB_ENV + echo EVM_HTTP_URLS=$EVM_HTTP_URLS >> $GITHUB_ENV + echo EVM_KEYS=$EVM_KEYS >> $GITHUB_ENV - name: Setup Go uses: actions/setup-go@v3 with: From 12dcb56fad3dd3662ae9016731753a50f59a2375 Mon Sep 17 00:00:00 2001 From: Bartek Tofel Date: Mon, 6 Nov 2023 12:57:33 +0100 Subject: [PATCH 07/15] fix step ordering in workflow --- .github/workflows/on-demand-log-poller.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/on-demand-log-poller.yml b/.github/workflows/on-demand-log-poller.yml index b1351334561..cf0c6fbdc8b 100644 --- a/.github/workflows/on-demand-log-poller.yml +++ b/.github/workflows/on-demand-log-poller.yml @@ -71,15 +71,15 @@ jobs: echo EVM_URLS=$EVM_URLS >> $GITHUB_ENV echo EVM_HTTP_URLS=$EVM_HTTP_URLS >> $GITHUB_ENV echo EVM_KEYS=$EVM_KEYS >> $GITHUB_ENV + - name: Checkout the repo + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + with: + ref: ${{ env.REF_NAME }} - name: Setup Go uses: actions/setup-go@v3 with: go-version-file: "integration-tests/go.mod" cache: true - - name: Checkout the repo - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - with: - ref: ${{ env.REF_NAME }} - name: Run tests run: | cd integration-tests From a8284894f8653a389a7e2275fa9d98e38aa8aebf Mon Sep 17 00:00:00 2001 From: Bartek Tofel Date: Mon, 6 Nov 2023 13:08:49 +0100 Subject: [PATCH 08/15] fix default image tag --- .github/workflows/on-demand-log-poller.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/on-demand-log-poller.yml b/.github/workflows/on-demand-log-poller.yml index cf0c6fbdc8b..e73282084be 100644 --- a/.github/workflows/on-demand-log-poller.yml +++ b/.github/workflows/on-demand-log-poller.yml @@ -24,7 +24,7 @@ on: required: true chainlinkVersion: description: Chainlink version to use - default: "v2.7.0-beta0" + default: "2.7.0-beta0" required: true selectedNetworks: type: choice From ad3a765130c4dc2c504a53c89decadd964f5eb5b Mon Sep 17 00:00:00 2001 From: Bartek Tofel Date: Mon, 6 Nov 2023 18:06:58 +0100 Subject: [PATCH 09/15] use latest pumba@CTF --- integration-tests/go.mod | 2 +- integration-tests/go.sum | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/integration-tests/go.mod b/integration-tests/go.mod index 127980a2cb9..bf23d0e2edf 100644 --- a/integration-tests/go.mod +++ b/integration-tests/go.mod @@ -22,7 +22,7 @@ require ( github.com/scylladb/go-reflectx v1.0.1 github.com/segmentio/ksuid v1.0.4 github.com/slack-go/slack v0.12.2 - github.com/smartcontractkit/chainlink-testing-framework v1.18.2-0.20231030212542-5fb562e774a5 + github.com/smartcontractkit/chainlink-testing-framework v1.18.4-0.20231106170326-cc1b855e6b08 github.com/smartcontractkit/chainlink/v2 v2.0.0-00010101000000-000000000000 github.com/smartcontractkit/libocr v0.0.0-20231020123319-d255366a6545 github.com/smartcontractkit/ocr2keepers v0.7.27 diff --git a/integration-tests/go.sum b/integration-tests/go.sum index 24da9467176..04e146176f8 100644 --- a/integration-tests/go.sum +++ b/integration-tests/go.sum @@ -2370,6 +2370,8 @@ github.com/smartcontractkit/chainlink-starknet/relayer v0.0.1-beta-test.0.202310 github.com/smartcontractkit/chainlink-starknet/relayer v0.0.1-beta-test.0.20231024133459-1ef3a11319eb/go.mod h1:/30flFG4L/iCYAFeA3DUzR0xuHSxAMONiWTzyzvsNwo= github.com/smartcontractkit/chainlink-testing-framework v1.18.2-0.20231030212542-5fb562e774a5 h1:4hTf8pvtdtwoaeKFSEYjBZPvDbZ05WgiHsb0TPL6HqQ= github.com/smartcontractkit/chainlink-testing-framework v1.18.2-0.20231030212542-5fb562e774a5/go.mod h1:lMdEUTdSmzldCwqf+todFEyebE9Vlb23+5rvIHJBPOk= +github.com/smartcontractkit/chainlink-testing-framework v1.18.4-0.20231106170326-cc1b855e6b08 h1:DIrCqf5alhyyOdrnIp4HSSCV1rxI2yX3gv4Fy9IgdxU= +github.com/smartcontractkit/chainlink-testing-framework v1.18.4-0.20231106170326-cc1b855e6b08/go.mod h1:zScXRqmvbyTFUooyLYrOp4+V/sFPUbFJNRc72YmnuIk= github.com/smartcontractkit/go-plugin v0.0.0-20231003134350-e49dad63b306 h1:ko88+ZznniNJZbZPWAvHQU8SwKAdHngdDZ+pvVgB5ss= github.com/smartcontractkit/go-plugin v0.0.0-20231003134350-e49dad63b306/go.mod h1:w1sAEES3g3PuV/RzUrgow20W2uErMly84hhD3um1WL4= github.com/smartcontractkit/grpc-proxy v0.0.0-20230731113816-f1be6620749f h1:hgJif132UCdjo8u43i7iPN1/MFnu49hv7lFGFftCHKU= From 65e2cb33e3af77de33be068f30c6eaebf69d4c67 Mon Sep 17 00:00:00 2001 From: Bartek Tofel Date: Mon, 6 Nov 2023 18:13:45 +0100 Subject: [PATCH 10/15] run one test --- .github/workflows/on-demand-log-poller.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/on-demand-log-poller.yml b/.github/workflows/on-demand-log-poller.yml index e73282084be..4b39fe5868d 100644 --- a/.github/workflows/on-demand-log-poller.yml +++ b/.github/workflows/on-demand-log-poller.yml @@ -84,4 +84,4 @@ jobs: run: | cd integration-tests go mod download - go test -v -timeout 5h -v -count=1 -run ^TestLogPollerFromEnv$ ./reorg \ No newline at end of file + go test -v -timeout 5h -v -count=1 -run ^TestLogPollerFromEnv$ ./integration-tests/reorg/log_poller_maybe_reorg_test.go \ No newline at end of file From 21d5d435416a9fbb62a48d5afe57fb548483c32b Mon Sep 17 00:00:00 2001 From: Bartek Tofel Date: Mon, 6 Nov 2023 18:16:10 +0100 Subject: [PATCH 11/15] fix directory name --- .github/workflows/on-demand-log-poller.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/on-demand-log-poller.yml b/.github/workflows/on-demand-log-poller.yml index 4b39fe5868d..4608583839b 100644 --- a/.github/workflows/on-demand-log-poller.yml +++ b/.github/workflows/on-demand-log-poller.yml @@ -84,4 +84,4 @@ jobs: run: | cd integration-tests go mod download - go test -v -timeout 5h -v -count=1 -run ^TestLogPollerFromEnv$ ./integration-tests/reorg/log_poller_maybe_reorg_test.go \ No newline at end of file + go test -v -timeout 5h -v -count=1 -run ^TestLogPollerFromEnv$ ./reorg/log_poller_maybe_reorg_test.go \ No newline at end of file From b035bad75bebf7869e113586de98e5cde3f65484 Mon Sep 17 00:00:00 2001 From: Bartek Tofel Date: Tue, 7 Nov 2023 09:33:55 +0100 Subject: [PATCH 12/15] run on powerful runner --- .github/workflows/on-demand-log-poller.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/on-demand-log-poller.yml b/.github/workflows/on-demand-log-poller.yml index 4608583839b..1a669e6f510 100644 --- a/.github/workflows/on-demand-log-poller.yml +++ b/.github/workflows/on-demand-log-poller.yml @@ -56,7 +56,7 @@ jobs: CHAINLINK_VERSION: ${{ inputs.chainlinkVersion }} SELECTED_NETWORKS: ${{ inputs.selectedNetworks }} REF_NAME: ${{ github.head_ref || github.ref_name }} - runs-on: ubuntu-latest + runs-on: ubuntu20.04-8cores-32GB steps: - name: Get Inputs run: | From e9bfca7689a9b3443c808c642f98d02577aaaa43 Mon Sep 17 00:00:00 2001 From: Bartek Tofel Date: Tue, 7 Nov 2023 19:38:53 +0100 Subject: [PATCH 13/15] show usage of ethereum env builder with eth2 --- integration-tests/docker/test_env/test_env.go | 21 ++++++--- .../docker/test_env/test_env_builder.go | 44 ++++++++++++++----- integration-tests/go.mod | 5 +-- integration-tests/go.sum | 6 --- integration-tests/smoke/log_poller_test.go | 2 +- .../universal/log_poller/helpers.go | 13 +++++- 6 files changed, 64 insertions(+), 27 deletions(-) diff --git a/integration-tests/docker/test_env/test_env.go b/integration-tests/docker/test_env/test_env.go index 506b1410459..e3cad911793 100644 --- a/integration-tests/docker/test_env/test_env.go +++ b/integration-tests/docker/test_env/test_env.go @@ -41,7 +41,6 @@ type CLClusterTestEnv struct { /* components */ ClCluster *ClCluster - Geth *test_env.Geth // for tests using --dev networks PrivateChain []test_env.PrivateChain // for tests using non-dev networks MockAdapter *test_env.Killgrave EVMClient blockchain.EVMClient @@ -59,7 +58,6 @@ func NewTestEnv() (*CLClusterTestEnv, error) { } n := []string{network.Name} return &CLClusterTestEnv{ - Geth: test_env.NewGeth(n), MockAdapter: test_env.NewKillgrave(n, ""), Network: network, l: log.Logger, @@ -71,7 +69,7 @@ func NewTestEnv() (*CLClusterTestEnv, error) { func (te *CLClusterTestEnv) WithTestEnvConfig(cfg *TestEnvConfig) *CLClusterTestEnv { te.Cfg = cfg n := []string{te.Network.Name} - te.Geth = test_env.NewGeth(n, test_env.WithContainerName(te.Cfg.Geth.ContainerName)) + // te.Geth = test_env.NewGeth(n, test_env.WithContainerName(te.Cfg.Geth.ContainerName)) te.MockAdapter = test_env.NewKillgrave(n, te.Cfg.MockAdapter.ImpostersPath, test_env.WithContainerName(te.Cfg.MockAdapter.ContainerName)) return te } @@ -79,7 +77,6 @@ func (te *CLClusterTestEnv) WithTestEnvConfig(cfg *TestEnvConfig) *CLClusterTest func (te *CLClusterTestEnv) WithTestLogger(t *testing.T) *CLClusterTestEnv { te.t = t te.l = logging.GetTestLogger(t) - te.Geth.WithTestLogger(t) te.MockAdapter.WithTestLogger(t) return te } @@ -128,8 +125,20 @@ func (te *CLClusterTestEnv) StartPrivateChain() error { return nil } -func (te *CLClusterTestEnv) StartGeth() (blockchain.EVMNetwork, test_env.InternalDockerUrls, error) { - return te.Geth.StartContainer() +func (te *CLClusterTestEnv) StartEthereumNetwork(b *test_env.EthereumNetworkBuilder) (blockchain.EVMNetwork, test_env.RpcProvider, error) { + b.UsingDockerNetworks([]string{te.Network.Name}) + err := b.Build() + if err != nil { + return blockchain.EVMNetwork{}, test_env.RpcProvider{}, err + } + + n, rpc, err := b.Start() + + if err != nil { + return blockchain.EVMNetwork{}, test_env.RpcProvider{}, err + } + + return n, rpc, nil } func (te *CLClusterTestEnv) StartMockAdapter() error { diff --git a/integration-tests/docker/test_env/test_env_builder.go b/integration-tests/docker/test_env/test_env_builder.go index c07ea762623..4fbfd215d40 100644 --- a/integration-tests/docker/test_env/test_env_builder.go +++ b/integration-tests/docker/test_env/test_env_builder.go @@ -31,8 +31,8 @@ const ( ) type CLTestEnvBuilder struct { - hasLogWatch bool - hasGeth bool + hasLogWatch bool + // hasGeth bool hasKillgrave bool hasForwarders bool clNodeConfig *chainlink.Config @@ -49,6 +49,7 @@ type CLTestEnvBuilder struct { cleanUpCustomFn func() chainOptionsFn []ChainOption evmClientNetworkOption []EVMClientNetworkOption + ethereumNetworkBuilder *test_env.EthereumNetworkBuilder /* funding */ ETHFunds *big.Float @@ -118,8 +119,23 @@ func (b *CLTestEnvBuilder) WithFunding(eth *big.Float) *CLTestEnvBuilder { return b } +// deprecated +// left only for backward compatibility func (b *CLTestEnvBuilder) WithGeth() *CLTestEnvBuilder { - b.hasGeth = true + ethBuilder := test_env.NewEthereumNetworkBuilder(b.t) + err := ethBuilder. + WithConsensusType(test_env.ConsensusType_PoW). + WithExecutionLayer(test_env.ExecutionLayer_Geth). + Build() + + if err != nil { + panic(err) + } + return b +} + +func (b *CLTestEnvBuilder) WithPrivateEthereumNetwork(enb test_env.EthereumNetworkBuilder) *CLTestEnvBuilder { + b.ethereumNetworkBuilder = &enb return b } @@ -191,8 +207,16 @@ func (b *CLTestEnvBuilder) Build() (*CLClusterTestEnv, error) { return nil, err } } + + var enDesc string + if b.ethereumNetworkBuilder != nil { + enDesc = b.ethereumNetworkBuilder.Describe() + } else { + enDesc = "none" + } + b.l.Info(). - Bool("hasGeth", b.hasGeth). + Str("privateEthereumNetwork", enDesc). Bool("hasKillgrave", b.hasKillgrave). Int("clNodesCount", b.clNodesCount). Strs("customNodeCsaKeys", b.customNodeCsaKeys). @@ -260,9 +284,9 @@ func (b *CLTestEnvBuilder) Build() (*CLClusterTestEnv, error) { return b.te, nil } networkConfig := networks.MustGetSelectedNetworksFromEnv()[0] - var internalDockerUrls test_env.InternalDockerUrls - if b.hasGeth && networkConfig.Simulated { - networkConfig, internalDockerUrls, err = b.te.StartGeth() + var rpcProvider test_env.RpcProvider + if b.ethereumNetworkBuilder != nil && networkConfig.Simulated { + networkConfig, rpcProvider, err = b.te.StartEthereumNetwork(b.ethereumNetworkBuilder) if err != nil { return nil, err } @@ -311,8 +335,8 @@ func (b *CLTestEnvBuilder) Build() (*CLClusterTestEnv, error) { var httpUrls []string var wsUrls []string if networkConfig.Simulated { - httpUrls = []string{internalDockerUrls.HttpUrl} - wsUrls = []string{internalDockerUrls.WsUrl} + httpUrls = rpcProvider.PrivateHttpUrls() + wsUrls = rpcProvider.PrivateWsUrsl() } else { httpUrls = networkConfig.HTTPURLs wsUrls = networkConfig.URLs @@ -341,7 +365,7 @@ func (b *CLTestEnvBuilder) Build() (*CLClusterTestEnv, error) { b.defaultNodeCsaKeys = nodeCsaKeys } - if b.hasGeth && b.clNodesCount > 0 && b.ETHFunds != nil { + if b.ethereumNetworkBuilder != nil && b.clNodesCount > 0 && b.ETHFunds != nil { b.te.ParallelTransactions(true) defer b.te.ParallelTransactions(false) if err := b.te.FundChainlinkNodes(b.ETHFunds); err != nil { diff --git a/integration-tests/go.mod b/integration-tests/go.mod index bf23d0e2edf..dae93a206c9 100644 --- a/integration-tests/go.mod +++ b/integration-tests/go.mod @@ -22,7 +22,7 @@ require ( github.com/scylladb/go-reflectx v1.0.1 github.com/segmentio/ksuid v1.0.4 github.com/slack-go/slack v0.12.2 - github.com/smartcontractkit/chainlink-testing-framework v1.18.4-0.20231106170326-cc1b855e6b08 + github.com/smartcontractkit/chainlink-testing-framework v1.18.5-0.20231107160228-1f5f24b6b4ab github.com/smartcontractkit/chainlink/v2 v2.0.0-00010101000000-000000000000 github.com/smartcontractkit/libocr v0.0.0-20231020123319-d255366a6545 github.com/smartcontractkit/ocr2keepers v0.7.27 @@ -42,6 +42,7 @@ require ( // Pin K8s versions as their updates are highly disruptive and go mod keeps wanting to update them replace ( + github.com/smartcontractkit/chainlink-testing-framework => ../../chainlink-testing-framework k8s.io/api => k8s.io/api v0.25.11 k8s.io/client-go => k8s.io/client-go v0.25.11 k8s.io/kube-openapi => k8s.io/kube-openapi v0.0.0-20230303024457-afdc3dddf62d @@ -424,7 +425,6 @@ require ( github.com/whyrusleeping/multiaddr-filter v0.0.0-20160516205228-e903e4adabd7 // indirect github.com/x448/float16 v0.8.4 // indirect github.com/xlab/treeprint v1.1.0 // indirect - github.com/yuin/goldmark v1.4.13 // indirect github.com/yusufpapurcu/wmi v1.2.3 // indirect github.com/zondax/hid v0.9.1 // indirect github.com/zondax/ledger-go v0.14.1 // indirect @@ -452,7 +452,6 @@ require ( golang.org/x/arch v0.4.0 // indirect golang.org/x/crypto v0.14.0 // indirect golang.org/x/exp v0.0.0-20230713183714-613f0c0eb8a1 // indirect - golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 // indirect golang.org/x/mod v0.13.0 // indirect golang.org/x/net v0.17.0 // indirect golang.org/x/oauth2 v0.10.0 // indirect diff --git a/integration-tests/go.sum b/integration-tests/go.sum index 04e146176f8..fe0bc06e55d 100644 --- a/integration-tests/go.sum +++ b/integration-tests/go.sum @@ -2368,10 +2368,6 @@ github.com/smartcontractkit/chainlink-solana v1.0.3-0.20231023133638-72f4e799ab0 github.com/smartcontractkit/chainlink-solana v1.0.3-0.20231023133638-72f4e799ab05/go.mod h1:o0Pn1pbaUluboaK6/yhf8xf7TiFCkyFl6WUOdwqamuU= github.com/smartcontractkit/chainlink-starknet/relayer v0.0.1-beta-test.0.20231024133459-1ef3a11319eb h1:HiluOfEVGOQTM6BTDImOqYdMZZ7qq7fkZ3TJdmItNr8= github.com/smartcontractkit/chainlink-starknet/relayer v0.0.1-beta-test.0.20231024133459-1ef3a11319eb/go.mod h1:/30flFG4L/iCYAFeA3DUzR0xuHSxAMONiWTzyzvsNwo= -github.com/smartcontractkit/chainlink-testing-framework v1.18.2-0.20231030212542-5fb562e774a5 h1:4hTf8pvtdtwoaeKFSEYjBZPvDbZ05WgiHsb0TPL6HqQ= -github.com/smartcontractkit/chainlink-testing-framework v1.18.2-0.20231030212542-5fb562e774a5/go.mod h1:lMdEUTdSmzldCwqf+todFEyebE9Vlb23+5rvIHJBPOk= -github.com/smartcontractkit/chainlink-testing-framework v1.18.4-0.20231106170326-cc1b855e6b08 h1:DIrCqf5alhyyOdrnIp4HSSCV1rxI2yX3gv4Fy9IgdxU= -github.com/smartcontractkit/chainlink-testing-framework v1.18.4-0.20231106170326-cc1b855e6b08/go.mod h1:zScXRqmvbyTFUooyLYrOp4+V/sFPUbFJNRc72YmnuIk= github.com/smartcontractkit/go-plugin v0.0.0-20231003134350-e49dad63b306 h1:ko88+ZznniNJZbZPWAvHQU8SwKAdHngdDZ+pvVgB5ss= github.com/smartcontractkit/go-plugin v0.0.0-20231003134350-e49dad63b306/go.mod h1:w1sAEES3g3PuV/RzUrgow20W2uErMly84hhD3um1WL4= github.com/smartcontractkit/grpc-proxy v0.0.0-20230731113816-f1be6620749f h1:hgJif132UCdjo8u43i7iPN1/MFnu49hv7lFGFftCHKU= @@ -2572,7 +2568,6 @@ github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= -github.com/yuin/goldmark v1.4.13 h1:fVcFKWvrslecOb/tg+Cc05dkeYx540o0FuFt3nUVDoE= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= github.com/yusufpapurcu/wmi v1.2.3 h1:E1ctvB7uKFMOJw3fdOW32DwGE9I7t++CRUEMKvFoFiw= github.com/yusufpapurcu/wmi v1.2.3/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= @@ -2758,7 +2753,6 @@ golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRu golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 h1:VLliZ0d+/avPrXXH+OakdXhpJuEoBZuwh1m2j7U6Iug= golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= diff --git a/integration-tests/smoke/log_poller_test.go b/integration-tests/smoke/log_poller_test.go index 0df7817f1e3..407fcb34c9f 100644 --- a/integration-tests/smoke/log_poller_test.go +++ b/integration-tests/smoke/log_poller_test.go @@ -19,7 +19,7 @@ func TestLogPollerFewFilters(t *testing.T) { }, LoopedConfig: &logpoller.LoopedConfig{ ContractConfig: logpoller.ContractConfig{ - ExecutionCount: 100, + ExecutionCount: 10, }, FuzzConfig: logpoller.FuzzConfig{ MinEmitWaitTimeMs: 200, diff --git a/integration-tests/universal/log_poller/helpers.go b/integration-tests/universal/log_poller/helpers.go index aa488eb1be5..974c4109402 100644 --- a/integration-tests/universal/log_poller/helpers.go +++ b/integration-tests/universal/log_poller/helpers.go @@ -1068,9 +1068,20 @@ func setupLogPollerTestDocker( return network } + ethBuilder := ctf_test_env.NewEthereumNetworkBuilder(t) + err = ethBuilder. + WithConsensusType(ctf_test_env.ConsensusType_PoS). + WithConsensusLayer(ctf_test_env.ConsensusLayer_Prysm). + WithExecutionLayer(ctf_test_env.ExecutionLayer_Geth). + WithBeaconChainConfig(ctf_test_env.BeaconChainConfig{ + SecondsPerSlot: 4, + SlotsPerEpoch: 2, + }). + Build() + env, err = test_env.NewCLTestEnvBuilder(). WithTestLogger(t). - WithGeth(). + WithPrivateEthereumNetwork(ethBuilder). WithCLNodes(clNodesCount). WithCLNodeConfig(clNodeConfig). WithFunding(big.NewFloat(chainlinkNodeFunding)). From e6743452bc5fa0c3ab993997b3a31fbc752644c1 Mon Sep 17 00:00:00 2001 From: Bartek Tofel Date: Wed, 8 Nov 2023 12:48:20 +0100 Subject: [PATCH 14/15] update usage of eth2 --- integration-tests/docker/test_env/test_env.go | 38 +++++++++++-------- .../docker/test_env/test_env_builder.go | 38 +++++++++++-------- .../docker/test_env/test_env_config.go | 10 +++-- integration-tests/smoke/automation_test.go | 4 +- integration-tests/smoke/log_poller_test.go | 2 +- 5 files changed, 54 insertions(+), 38 deletions(-) diff --git a/integration-tests/docker/test_env/test_env.go b/integration-tests/docker/test_env/test_env.go index e3cad911793..3b4f8e8f755 100644 --- a/integration-tests/docker/test_env/test_env.go +++ b/integration-tests/docker/test_env/test_env.go @@ -40,14 +40,16 @@ type CLClusterTestEnv struct { LogWatch *logwatch.LogWatch /* components */ - ClCluster *ClCluster - PrivateChain []test_env.PrivateChain // for tests using non-dev networks - MockAdapter *test_env.Killgrave - EVMClient blockchain.EVMClient - ContractDeployer contracts.ContractDeployer - ContractLoader contracts.ContractLoader - l zerolog.Logger - t *testing.T + ClCluster *ClCluster + PrivateChain []test_env.PrivateChain // for tests using non-dev networks -- unify it with new approach + MockAdapter *test_env.Killgrave + EVMClient blockchain.EVMClient + ContractDeployer contracts.ContractDeployer + ContractLoader contracts.ContractLoader + RpcProvider test_env.RpcProvider + PrivateEthereumConfig *test_env.EthereumNetworkConfig // new approach to private chains, supporting eth1 and eth2 + l zerolog.Logger + t *testing.T } func NewTestEnv() (*CLClusterTestEnv, error) { @@ -65,11 +67,10 @@ func NewTestEnv() (*CLClusterTestEnv, error) { } // WithTestEnvConfig sets the test environment cfg. -// Sets up the Geth and MockAdapter containers with the provided cfg. +// Sets up private ethereum chain and MockAdapter containers with the provided cfg. func (te *CLClusterTestEnv) WithTestEnvConfig(cfg *TestEnvConfig) *CLClusterTestEnv { te.Cfg = cfg n := []string{te.Network.Name} - // te.Geth = test_env.NewGeth(n, test_env.WithContainerName(te.Cfg.Geth.ContainerName)) te.MockAdapter = test_env.NewKillgrave(n, te.Cfg.MockAdapter.ImpostersPath, test_env.WithContainerName(te.Cfg.MockAdapter.ContainerName)) return te } @@ -125,20 +126,27 @@ func (te *CLClusterTestEnv) StartPrivateChain() error { return nil } -func (te *CLClusterTestEnv) StartEthereumNetwork(b *test_env.EthereumNetworkBuilder) (blockchain.EVMNetwork, test_env.RpcProvider, error) { +func (te *CLClusterTestEnv) StartEthereumNetwork(b *test_env.EthereumNetworkBuilder) (blockchain.EVMNetwork, test_env.RpcProvider, test_env.EthereumNetworkConfig, error) { + // if environment is being restored from a previous state, use the existing config + // this might fail terribly if temporary folders with chain data on the host machine were removed + if te.Cfg != nil && te.Cfg.PrivateEthereumConfig != nil { + b.WithExistingConfig(*te.Cfg.PrivateEthereumConfig) + } + + // use Docker Network created or loaded so that all containers are on the same network b.UsingDockerNetworks([]string{te.Network.Name}) err := b.Build() if err != nil { - return blockchain.EVMNetwork{}, test_env.RpcProvider{}, err + return blockchain.EVMNetwork{}, test_env.RpcProvider{}, test_env.EthereumNetworkConfig{}, err } - n, rpc, err := b.Start() + n, rpc, config, err := b.Start() if err != nil { - return blockchain.EVMNetwork{}, test_env.RpcProvider{}, err + return blockchain.EVMNetwork{}, test_env.RpcProvider{}, test_env.EthereumNetworkConfig{}, err } - return n, rpc, nil + return n, rpc, config, nil } func (te *CLClusterTestEnv) StartMockAdapter() error { diff --git a/integration-tests/docker/test_env/test_env_builder.go b/integration-tests/docker/test_env/test_env_builder.go index 4fbfd215d40..ee66190747b 100644 --- a/integration-tests/docker/test_env/test_env_builder.go +++ b/integration-tests/docker/test_env/test_env_builder.go @@ -208,21 +208,6 @@ func (b *CLTestEnvBuilder) Build() (*CLClusterTestEnv, error) { } } - var enDesc string - if b.ethereumNetworkBuilder != nil { - enDesc = b.ethereumNetworkBuilder.Describe() - } else { - enDesc = "none" - } - - b.l.Info(). - Str("privateEthereumNetwork", enDesc). - Bool("hasKillgrave", b.hasKillgrave). - Int("clNodesCount", b.clNodesCount). - Strs("customNodeCsaKeys", b.customNodeCsaKeys). - Strs("defaultNodeCsaKeys", b.defaultNodeCsaKeys). - Msg("Building CL cluster test environment..") - var err error if b.t != nil { b.te.WithTestLogger(b.t) @@ -286,10 +271,16 @@ func (b *CLTestEnvBuilder) Build() (*CLClusterTestEnv, error) { networkConfig := networks.MustGetSelectedNetworksFromEnv()[0] var rpcProvider test_env.RpcProvider if b.ethereumNetworkBuilder != nil && networkConfig.Simulated { - networkConfig, rpcProvider, err = b.te.StartEthereumNetwork(b.ethereumNetworkBuilder) + // TODO here we should save the ethereum network config to te.Cfg, but it doesn't exist at this point + // in general it seems we have no methods for saving config to file and we only load it from file + // but I don't know how that config file is to be created or whether anyone ever done that + var enCfg test_env.EthereumNetworkConfig + networkConfig, rpcProvider, enCfg, err = b.te.StartEthereumNetwork(b.ethereumNetworkBuilder) if err != nil { return nil, err } + b.te.RpcProvider = rpcProvider + b.te.PrivateEthereumConfig = &enCfg } if !b.isNonEVM { @@ -373,5 +364,20 @@ func (b *CLTestEnvBuilder) Build() (*CLClusterTestEnv, error) { } } + var enDesc string + if b.te.PrivateEthereumConfig != nil { + enDesc = b.te.PrivateEthereumConfig.Describe() + } else { + enDesc = "none" + } + + b.l.Info(). + Str("privateEthereumNetwork", enDesc). + Bool("hasKillgrave", b.hasKillgrave). + Int("clNodesCount", b.clNodesCount). + Strs("customNodeCsaKeys", b.customNodeCsaKeys). + Strs("defaultNodeCsaKeys", b.defaultNodeCsaKeys). + Msg("Building CL cluster test environment..") + return b.te, nil } diff --git a/integration-tests/docker/test_env/test_env_config.go b/integration-tests/docker/test_env/test_env_config.go index 1a0c8d5c86a..0d630430190 100644 --- a/integration-tests/docker/test_env/test_env_config.go +++ b/integration-tests/docker/test_env/test_env_config.go @@ -3,14 +3,16 @@ package test_env import ( "encoding/json" + cte "github.com/smartcontractkit/chainlink-testing-framework/docker/test_env" env "github.com/smartcontractkit/chainlink/integration-tests/types/envcommon" ) type TestEnvConfig struct { - Networks []string `json:"networks"` - Geth GethConfig `json:"geth"` - MockAdapter MockAdapterConfig `json:"mock_adapter"` - ClCluster *ClCluster `json:"clCluster"` + Networks []string `json:"networks"` + Geth GethConfig `json:"geth"` + MockAdapter MockAdapterConfig `json:"mock_adapter"` + ClCluster *ClCluster `json:"clCluster"` + PrivateEthereumConfig *cte.EthereumNetworkConfig `json:"private_ethereum_config"` } type MockAdapterConfig struct { diff --git a/integration-tests/smoke/automation_test.go b/integration-tests/smoke/automation_test.go index 9e35b24df1e..4f969c5d68d 100644 --- a/integration-tests/smoke/automation_test.go +++ b/integration-tests/smoke/automation_test.go @@ -1070,8 +1070,8 @@ func setupAutomationTestDocker( var httpUrls []string var wsUrls []string if network.Simulated { - httpUrls = []string{env.Geth.InternalHttpUrl} - wsUrls = []string{env.Geth.InternalWsUrl} + httpUrls = []string{env.RpcProvider.PrivateHttpUrls()[0]} + wsUrls = []string{env.RpcProvider.PrivateWsUrsl()[0]} } else { httpUrls = network.HTTPURLs wsUrls = network.URLs diff --git a/integration-tests/smoke/log_poller_test.go b/integration-tests/smoke/log_poller_test.go index 407fcb34c9f..0df7817f1e3 100644 --- a/integration-tests/smoke/log_poller_test.go +++ b/integration-tests/smoke/log_poller_test.go @@ -19,7 +19,7 @@ func TestLogPollerFewFilters(t *testing.T) { }, LoopedConfig: &logpoller.LoopedConfig{ ContractConfig: logpoller.ContractConfig{ - ExecutionCount: 10, + ExecutionCount: 100, }, FuzzConfig: logpoller.FuzzConfig{ MinEmitWaitTimeMs: 200, From ff56ba171d8b6e520f1dad062d7450e45bede646 Mon Sep 17 00:00:00 2001 From: Bartek Tofel Date: Fri, 10 Nov 2023 19:20:21 +0100 Subject: [PATCH 15/15] adjust to latest --- integration-tests/docker/test_env/test_env.go | 29 +++++++++---------- .../docker/test_env/test_env_builder.go | 24 +++++++++------ .../docker/test_env/test_env_config.go | 10 +++---- integration-tests/go.mod | 3 +- integration-tests/go.sum | 2 ++ .../universal/log_poller/helpers.go | 6 ++-- 6 files changed, 40 insertions(+), 34 deletions(-) diff --git a/integration-tests/docker/test_env/test_env.go b/integration-tests/docker/test_env/test_env.go index 3b4f8e8f755..d3c9d5da0c7 100644 --- a/integration-tests/docker/test_env/test_env.go +++ b/integration-tests/docker/test_env/test_env.go @@ -47,7 +47,7 @@ type CLClusterTestEnv struct { ContractDeployer contracts.ContractDeployer ContractLoader contracts.ContractLoader RpcProvider test_env.RpcProvider - PrivateEthereumConfig *test_env.EthereumNetworkConfig // new approach to private chains, supporting eth1 and eth2 + PrivateEthereumConfig *test_env.EthereumNetwork // new approach to private chains, supporting eth1 and eth2 l zerolog.Logger t *testing.T } @@ -126,27 +126,26 @@ func (te *CLClusterTestEnv) StartPrivateChain() error { return nil } -func (te *CLClusterTestEnv) StartEthereumNetwork(b *test_env.EthereumNetworkBuilder) (blockchain.EVMNetwork, test_env.RpcProvider, test_env.EthereumNetworkConfig, error) { +func (te *CLClusterTestEnv) StartEthereumNetwork(cfg *test_env.EthereumNetwork) (blockchain.EVMNetwork, test_env.RpcProvider, error) { // if environment is being restored from a previous state, use the existing config // this might fail terribly if temporary folders with chain data on the host machine were removed - if te.Cfg != nil && te.Cfg.PrivateEthereumConfig != nil { - b.WithExistingConfig(*te.Cfg.PrivateEthereumConfig) - } - - // use Docker Network created or loaded so that all containers are on the same network - b.UsingDockerNetworks([]string{te.Network.Name}) - err := b.Build() - if err != nil { - return blockchain.EVMNetwork{}, test_env.RpcProvider{}, test_env.EthereumNetworkConfig{}, err + if te.Cfg != nil && te.Cfg.EthereumNetwork != nil { + builder := test_env.NewEthereumNetworkBuilder() + c, err := builder.WithExistingConfig(*te.Cfg.EthereumNetwork). + WithTest(te.t). + Build() + if err != nil { + return blockchain.EVMNetwork{}, test_env.RpcProvider{}, err + } + cfg = &c } - - n, rpc, config, err := b.Start() + n, rpc, err := cfg.Start() if err != nil { - return blockchain.EVMNetwork{}, test_env.RpcProvider{}, test_env.EthereumNetworkConfig{}, err + return blockchain.EVMNetwork{}, test_env.RpcProvider{}, err } - return n, rpc, config, nil + return n, rpc, nil } func (te *CLClusterTestEnv) StartMockAdapter() error { diff --git a/integration-tests/docker/test_env/test_env_builder.go b/integration-tests/docker/test_env/test_env_builder.go index ee66190747b..eb91216d530 100644 --- a/integration-tests/docker/test_env/test_env_builder.go +++ b/integration-tests/docker/test_env/test_env_builder.go @@ -49,7 +49,7 @@ type CLTestEnvBuilder struct { cleanUpCustomFn func() chainOptionsFn []ChainOption evmClientNetworkOption []EVMClientNetworkOption - ethereumNetworkBuilder *test_env.EthereumNetworkBuilder + ethereumNetwork *test_env.EthereumNetwork /* funding */ ETHFunds *big.Float @@ -122,20 +122,24 @@ func (b *CLTestEnvBuilder) WithFunding(eth *big.Float) *CLTestEnvBuilder { // deprecated // left only for backward compatibility func (b *CLTestEnvBuilder) WithGeth() *CLTestEnvBuilder { - ethBuilder := test_env.NewEthereumNetworkBuilder(b.t) - err := ethBuilder. + ethBuilder := test_env.NewEthereumNetworkBuilder() + cfg, err := ethBuilder. WithConsensusType(test_env.ConsensusType_PoW). WithExecutionLayer(test_env.ExecutionLayer_Geth). + WithTest(b.t). Build() if err != nil { panic(err) } + + b.ethereumNetwork = &cfg + return b } -func (b *CLTestEnvBuilder) WithPrivateEthereumNetwork(enb test_env.EthereumNetworkBuilder) *CLTestEnvBuilder { - b.ethereumNetworkBuilder = &enb +func (b *CLTestEnvBuilder) WithPrivateEthereumNetwork(en test_env.EthereumNetwork) *CLTestEnvBuilder { + b.ethereumNetwork = &en return b } @@ -268,14 +272,16 @@ func (b *CLTestEnvBuilder) Build() (*CLClusterTestEnv, error) { } return b.te, nil } + networkConfig := networks.MustGetSelectedNetworksFromEnv()[0] var rpcProvider test_env.RpcProvider - if b.ethereumNetworkBuilder != nil && networkConfig.Simulated { + if b.ethereumNetwork != nil && networkConfig.Simulated { // TODO here we should save the ethereum network config to te.Cfg, but it doesn't exist at this point // in general it seems we have no methods for saving config to file and we only load it from file // but I don't know how that config file is to be created or whether anyone ever done that - var enCfg test_env.EthereumNetworkConfig - networkConfig, rpcProvider, enCfg, err = b.te.StartEthereumNetwork(b.ethereumNetworkBuilder) + var enCfg test_env.EthereumNetwork + b.ethereumNetwork.DockerNetworkNames = []string{b.te.Network.Name} + networkConfig, rpcProvider, err = b.te.StartEthereumNetwork(b.ethereumNetwork) if err != nil { return nil, err } @@ -356,7 +362,7 @@ func (b *CLTestEnvBuilder) Build() (*CLClusterTestEnv, error) { b.defaultNodeCsaKeys = nodeCsaKeys } - if b.ethereumNetworkBuilder != nil && b.clNodesCount > 0 && b.ETHFunds != nil { + if b.ethereumNetwork != nil && b.clNodesCount > 0 && b.ETHFunds != nil { b.te.ParallelTransactions(true) defer b.te.ParallelTransactions(false) if err := b.te.FundChainlinkNodes(b.ETHFunds); err != nil { diff --git a/integration-tests/docker/test_env/test_env_config.go b/integration-tests/docker/test_env/test_env_config.go index 0d630430190..0902deb0c2d 100644 --- a/integration-tests/docker/test_env/test_env_config.go +++ b/integration-tests/docker/test_env/test_env_config.go @@ -8,11 +8,11 @@ import ( ) type TestEnvConfig struct { - Networks []string `json:"networks"` - Geth GethConfig `json:"geth"` - MockAdapter MockAdapterConfig `json:"mock_adapter"` - ClCluster *ClCluster `json:"clCluster"` - PrivateEthereumConfig *cte.EthereumNetworkConfig `json:"private_ethereum_config"` + Networks []string `json:"networks"` + Geth GethConfig `json:"geth"` + MockAdapter MockAdapterConfig `json:"mock_adapter"` + ClCluster *ClCluster `json:"clCluster"` + EthereumNetwork *cte.EthereumNetwork `json:"private_ethereum_config"` } type MockAdapterConfig struct { diff --git a/integration-tests/go.mod b/integration-tests/go.mod index dae93a206c9..11f91ca4f4d 100644 --- a/integration-tests/go.mod +++ b/integration-tests/go.mod @@ -22,7 +22,7 @@ require ( github.com/scylladb/go-reflectx v1.0.1 github.com/segmentio/ksuid v1.0.4 github.com/slack-go/slack v0.12.2 - github.com/smartcontractkit/chainlink-testing-framework v1.18.5-0.20231107160228-1f5f24b6b4ab + github.com/smartcontractkit/chainlink-testing-framework v1.18.6-0.20231110182956-23751e7533b8 github.com/smartcontractkit/chainlink/v2 v2.0.0-00010101000000-000000000000 github.com/smartcontractkit/libocr v0.0.0-20231020123319-d255366a6545 github.com/smartcontractkit/ocr2keepers v0.7.27 @@ -42,7 +42,6 @@ require ( // Pin K8s versions as their updates are highly disruptive and go mod keeps wanting to update them replace ( - github.com/smartcontractkit/chainlink-testing-framework => ../../chainlink-testing-framework k8s.io/api => k8s.io/api v0.25.11 k8s.io/client-go => k8s.io/client-go v0.25.11 k8s.io/kube-openapi => k8s.io/kube-openapi v0.0.0-20230303024457-afdc3dddf62d diff --git a/integration-tests/go.sum b/integration-tests/go.sum index fe0bc06e55d..91f35163966 100644 --- a/integration-tests/go.sum +++ b/integration-tests/go.sum @@ -2368,6 +2368,8 @@ github.com/smartcontractkit/chainlink-solana v1.0.3-0.20231023133638-72f4e799ab0 github.com/smartcontractkit/chainlink-solana v1.0.3-0.20231023133638-72f4e799ab05/go.mod h1:o0Pn1pbaUluboaK6/yhf8xf7TiFCkyFl6WUOdwqamuU= github.com/smartcontractkit/chainlink-starknet/relayer v0.0.1-beta-test.0.20231024133459-1ef3a11319eb h1:HiluOfEVGOQTM6BTDImOqYdMZZ7qq7fkZ3TJdmItNr8= github.com/smartcontractkit/chainlink-starknet/relayer v0.0.1-beta-test.0.20231024133459-1ef3a11319eb/go.mod h1:/30flFG4L/iCYAFeA3DUzR0xuHSxAMONiWTzyzvsNwo= +github.com/smartcontractkit/chainlink-testing-framework v1.18.6-0.20231110182956-23751e7533b8 h1:o4Dkaz9T3iOsewy3WbUSZLy8V58JCTAR4OHJb5szwF8= +github.com/smartcontractkit/chainlink-testing-framework v1.18.6-0.20231110182956-23751e7533b8/go.mod h1:zScXRqmvbyTFUooyLYrOp4+V/sFPUbFJNRc72YmnuIk= github.com/smartcontractkit/go-plugin v0.0.0-20231003134350-e49dad63b306 h1:ko88+ZznniNJZbZPWAvHQU8SwKAdHngdDZ+pvVgB5ss= github.com/smartcontractkit/go-plugin v0.0.0-20231003134350-e49dad63b306/go.mod h1:w1sAEES3g3PuV/RzUrgow20W2uErMly84hhD3um1WL4= github.com/smartcontractkit/grpc-proxy v0.0.0-20230731113816-f1be6620749f h1:hgJif132UCdjo8u43i7iPN1/MFnu49hv7lFGFftCHKU= diff --git a/integration-tests/universal/log_poller/helpers.go b/integration-tests/universal/log_poller/helpers.go index 974c4109402..2dd0ddaa194 100644 --- a/integration-tests/universal/log_poller/helpers.go +++ b/integration-tests/universal/log_poller/helpers.go @@ -1068,8 +1068,8 @@ func setupLogPollerTestDocker( return network } - ethBuilder := ctf_test_env.NewEthereumNetworkBuilder(t) - err = ethBuilder. + ethBuilder := ctf_test_env.NewEthereumNetworkBuilder() + cfg, err := ethBuilder. WithConsensusType(ctf_test_env.ConsensusType_PoS). WithConsensusLayer(ctf_test_env.ConsensusLayer_Prysm). WithExecutionLayer(ctf_test_env.ExecutionLayer_Geth). @@ -1081,7 +1081,7 @@ func setupLogPollerTestDocker( env, err = test_env.NewCLTestEnvBuilder(). WithTestLogger(t). - WithPrivateEthereumNetwork(ethBuilder). + WithPrivateEthereumNetwork(cfg). WithCLNodes(clNodesCount). WithCLNodeConfig(clNodeConfig). WithFunding(big.NewFloat(chainlinkNodeFunding)).