From d88d77faec120335067acfc1c5be1fce8f66c484 Mon Sep 17 00:00:00 2001 From: Damjan Smickovski <32773226+smickovskid@users.noreply.github.com> Date: Wed, 2 Aug 2023 09:32:16 +0200 Subject: [PATCH] Replaced mockserver with mock adapter (#535) * Replaced mockserver with mock adapter --- .github/workflows/e2e_custom_cl.yml | 1 + .github/workflows/e2e_testnet_daily.yml | 2 +- docs/RunningE2eTests.md | 21 +++++++++++++++++++ .../ocr2/inspection/inspectResponses.ts | 2 +- integration-tests/common/common.go | 17 +++++++-------- integration-tests/common/test_common.go | 21 ++----------------- integration-tests/go.mod | 2 +- integration-tests/go.sum | 4 ++-- integration-tests/smoke/ocr2_test.go | 10 +++------ integration-tests/soak/ocr2_soak_test.go | 1 - 10 files changed, 39 insertions(+), 42 deletions(-) diff --git a/.github/workflows/e2e_custom_cl.yml b/.github/workflows/e2e_custom_cl.yml index 11c1308a9..2141a27a6 100644 --- a/.github/workflows/e2e_custom_cl.yml +++ b/.github/workflows/e2e_custom_cl.yml @@ -148,6 +148,7 @@ jobs: CHAINLINK_ENV_USER: ${{ github.actor }} TEST_LOG_LEVEL: debug SELECTED_NETWORKS: SIMULATED + INTERNAL_DOCKER_REPO: ${{ secrets.QA_AWS_ACCOUNT_NUMBER }}.dkr.ecr.${{ secrets.QA_AWS_REGION }}.amazonaws.com steps: - name: Collect Metrics if: always() diff --git a/.github/workflows/e2e_testnet_daily.yml b/.github/workflows/e2e_testnet_daily.yml index f469c3737..53ffc5e41 100644 --- a/.github/workflows/e2e_testnet_daily.yml +++ b/.github/workflows/e2e_testnet_daily.yml @@ -170,7 +170,7 @@ jobs: LINK_TOKEN: Dmw5mDvteezKfop9zd3RQbJmZfBATF3QuSqDU66axyts VAULT_ADDRESS: G27m7KxTh4KVLapxB9MXfEA8HLUfYuGYQ1ELEs2zQdiQ PRIVATE_KEY: ${{ github.event_name == 'schedule' && secrets.PRIVATE_KEY || github.event.inputs.PRIVATE_KEY }} - + INTERNAL_DOCKER_REPO: ${{ secrets.QA_AWS_ACCOUNT_NUMBER }}.dkr.ecr.${{ secrets.QA_AWS_REGION }}.amazonaws.com steps: - name: Collect Metrics if: always() diff --git a/docs/RunningE2eTests.md b/docs/RunningE2eTests.md index 3659677fd..5e1e1e60d 100644 --- a/docs/RunningE2eTests.md +++ b/docs/RunningE2eTests.md @@ -12,4 +12,25 @@ Steps to run the e2e tests: - `make test_smoke` will run the ocr2 e2e tests - `make test_chaos` will run the chaos tests +## Env variables +```bash +CHAINLINK_ENV_USER=John; +CHAINLINK_IMAGE={AWS_OIDC}.dkr.ecr.{AWS_REGION}.amazonaws.com/chainlink; +CHAINLINK_VERSION=develop; # Can be SHA +SELECTED_NETWORKS=SIMULATED; +INTERNAL_DOCKER_REPO={AWS_OIDC}.dkr.ecr.{AWS_REGION}.amazonaws.com +TTL=72h; # optional +TEST_LOG_LEVEL=debug # optional + +# Running on testnet +LINK_TOKEN=Dmw5mDvteezKfop9zd3RQbJmZfBATF3QuSqDU66axyts; +PROGRAM_ID_ACCESS_CONTROLLER=9xi644bRR8birboDGdTiwBq3C7VEeR7VuamRYYXCubUW; +PROGRAM_ID_OCR2=cjg3oHmg9uuPsP8D6g29NWvhySJkdYdAo9D25PRbKXJ; +PROGRAM_ID_STORE=HEvSKofvBgfaexv23kMabbYqxasxU3mQ4ibBMEmJWHny; +VAULT_ADDRESS=G27m7KxTh4KVLapxB9MXfEA8HLUfYuGYQ1ELEs2zQdiQ; +PRIVATE_KEY=[123, 123, ...]; +RPC_URL=https://api.devnet.solana.com; +WS_URL=wss://api.devnet.solana.com/; +``` + You can always look at the [Makefile](../Makefile) in this repo to see other commands or tests that have been added since this readme was last updated. \ No newline at end of file diff --git a/gauntlet/packages/gauntlet-solana-contracts/src/commands/contracts/ocr2/inspection/inspectResponses.ts b/gauntlet/packages/gauntlet-solana-contracts/src/commands/contracts/ocr2/inspection/inspectResponses.ts index fdbf98a01..6a904cd2d 100644 --- a/gauntlet/packages/gauntlet-solana-contracts/src/commands/contracts/ocr2/inspection/inspectResponses.ts +++ b/gauntlet/packages/gauntlet-solana-contracts/src/commands/contracts/ocr2/inspection/inspectResponses.ts @@ -154,7 +154,7 @@ export default class OCR2InspectResponses extends SolanaCommand { transmissionDetails.push({ latestTransmissionNo: i + 1, roundId: event.roundId, - answer: parseInt(event.answer.toString(), 2), + answer: parseInt(event.answer.toString(), 10), transmitter: transmitters[event.transmitter].toString(), }) // Log oracles that are not responsive diff --git a/integration-tests/common/common.go b/integration-tests/common/common.go index c333aecc7..72e54e219 100644 --- a/integration-tests/common/common.go +++ b/integration-tests/common/common.go @@ -21,15 +21,13 @@ import ( "github.com/smartcontractkit/chainlink-env/environment" "github.com/smartcontractkit/chainlink-env/pkg/alias" "github.com/smartcontractkit/chainlink-env/pkg/helm/chainlink" - "github.com/smartcontractkit/chainlink-env/pkg/helm/mockserver" - mockservercfg "github.com/smartcontractkit/chainlink-env/pkg/helm/mockserver-cfg" + "github.com/smartcontractkit/chainlink-env/pkg/helm/mock-adapter" "github.com/smartcontractkit/chainlink-env/pkg/helm/sol" "github.com/smartcontractkit/libocr/offchainreporting2/confighelper" "github.com/smartcontractkit/libocr/offchainreporting2/reportingplugin/median" "github.com/smartcontractkit/libocr/offchainreporting2/types" - ctfClient "github.com/smartcontractkit/chainlink-testing-framework/client" "github.com/smartcontractkit/chainlink/integration-tests/client" "github.com/smartcontractkit/chainlink/integration-tests/contracts" "github.com/smartcontractkit/chainlink/v2/core/services/job" @@ -279,7 +277,7 @@ func OffChainConfigParamsFromNodes(nodes []*client.Chainlink, nkb []client.NodeK }, nil } -func CreateBridges(ContractsIdxMapToContractsNodeInfo map[int]*ContractNodeInfo, mock *ctfClient.MockserverClient) error { +func CreateBridges(ContractsIdxMapToContractsNodeInfo map[int]*ContractNodeInfo, mockUrl string) error { for i, nodesInfo := range ContractsIdxMapToContractsNodeInfo { // Bootstrap node first nodeContractPairID, err := BuildNodeContractPairID(nodesInfo.BootstrapNode, nodesInfo.OCR2.Address()) @@ -288,7 +286,7 @@ func CreateBridges(ContractsIdxMapToContractsNodeInfo map[int]*ContractNodeInfo, } sourceValueBridge := client.BridgeTypeAttributes{ Name: nodeContractPairID, - URL: fmt.Sprintf("%s/%s", mock.Config.ClusterURL, nodeContractPairID), + URL: fmt.Sprintf("%s/%s", mockUrl, "five"), RequestData: "{}", } observationSource := client.ObservationSourceSpecBridge(&sourceValueBridge) @@ -298,7 +296,7 @@ func CreateBridges(ContractsIdxMapToContractsNodeInfo map[int]*ContractNodeInfo, } juelsBridge := client.BridgeTypeAttributes{ Name: nodeContractPairID + "juels", - URL: fmt.Sprintf("%s/juels", mock.Config.ClusterURL), + URL: fmt.Sprintf("%s/%s", mockUrl, "five"), RequestData: "{}", } juelsSource := client.ObservationSourceSpecBridge(&juelsBridge) @@ -315,7 +313,7 @@ func CreateBridges(ContractsIdxMapToContractsNodeInfo map[int]*ContractNodeInfo, } sourceValueBridge := client.BridgeTypeAttributes{ Name: nodeContractPairID, - URL: fmt.Sprintf("%s/%s", mock.Config.ClusterURL, nodeContractPairID), + URL: fmt.Sprintf("%s/%s", mockUrl, "five"), RequestData: "{}", } observationSource := client.ObservationSourceSpecBridge(&sourceValueBridge) @@ -325,7 +323,7 @@ func CreateBridges(ContractsIdxMapToContractsNodeInfo map[int]*ContractNodeInfo, } juelsBridge := client.BridgeTypeAttributes{ Name: nodeContractPairID + "juels", - URL: fmt.Sprintf("%s/juels", mock.Config.ClusterURL), + URL: fmt.Sprintf("%s/%s", mockUrl, "five"), RequestData: "{}", } juelsSource := client.ObservationSourceSpecBridge(&juelsBridge) @@ -440,9 +438,8 @@ DeltaReconcile = '5s' ListenAddresses = ['0.0.0.0:6690'] `, c.ChainId, c.SolanaUrl) c.Env = environment.New(c.K8Config). - AddHelm(mockservercfg.New(nil)). - AddHelm(mockserver.New(nil)). AddHelm(sol.New(nil)). + AddHelm(mock_adapter.New(nil)). AddHelm(chainlink.New(0, map[string]interface{}{ "toml": baseTOML, "replicas": c.NodeCount, diff --git a/integration-tests/common/test_common.go b/integration-tests/common/test_common.go index b45582fed..43b616227 100644 --- a/integration-tests/common/test_common.go +++ b/integration-tests/common/test_common.go @@ -15,7 +15,6 @@ import ( "github.com/smartcontractkit/chainlink-testing-framework/utils" "github.com/stretchr/testify/require" - ctfClient "github.com/smartcontractkit/chainlink-testing-framework/client" "github.com/smartcontractkit/chainlink/integration-tests/client" "golang.org/x/sync/errgroup" ) @@ -140,7 +139,6 @@ type OCRv2TestState struct { Contracts []Contracts ContractsNodeSetup map[int]*ContractNodeInfo NodeKeysBundle []client.NodeKeysBundle - MockServer *ctfClient.MockserverClient Client *solclient.Client RoundsFound int LastRoundTime map[string]time.Time @@ -217,8 +215,6 @@ func (m *OCRv2TestState) NewSolanaClientSetup(networkSettings *solclient.SolNetw func (m *OCRv2TestState) SetupClients() { m.Client, m.err = m.NewSolanaClientSetup(m.Client.Config)(m.Common.Env) require.NoError(m.T, m.err) - m.MockServer, m.err = ctfClient.ConnectMockServer(m.Common.Env) - require.NoError(m.T, m.err) m.ChainlinkNodes, m.err = client.ConnectChainlinkNodes(m.Common.Env) require.NoError(m.T, m.err) } @@ -314,11 +310,10 @@ func (m *OCRv2TestState) DeployContracts(contractsDir string) { // CreateJobs creating OCR jobs and EA stubs func (m *OCRv2TestState) CreateJobs() { - m.err = m.MockServer.SetValuePath("/juels", 1) - require.NoError(m.T, m.err) + m.err = m.Common.CreateSolanaChainAndNode(m.ChainlinkNodes) require.NoError(m.T, m.err) - m.err = CreateBridges(m.ContractsNodeSetup, m.MockServer) + m.err = CreateBridges(m.ContractsNodeSetup, m.Common.Env.URLs["qa_mock_adapter_internal"][0]) require.NoError(m.T, m.err) g := errgroup.Group{} for i := 0; i < len(m.ContractsNodeSetup); i++ { @@ -332,18 +327,6 @@ func (m *OCRv2TestState) CreateJobs() { require.NoError(m.T, g.Wait()) } -func (m *OCRv2TestState) SetAllAdapterResponsesToTheSameValue(response int) { - for i := 0; i < len(m.ContractsNodeSetup); i++ { - for _, node := range m.ContractsNodeSetup[i].Nodes { - nodeContractPairID, err := BuildNodeContractPairID(node, m.ContractsNodeSetup[i].OCR2.Address()) - require.NoError(m.T, err) - path := fmt.Sprintf("/%s", nodeContractPairID) - m.err = m.MockServer.SetValuePath(path, response) - require.NoError(m.T, m.err) - } - } -} - func (m *OCRv2TestState) ValidateNoRoundsAfter(chaosStartTime time.Time) { m.RoundsFound = 0 for _, c := range m.Contracts { diff --git a/integration-tests/go.mod b/integration-tests/go.mod index b5d00a523..2e3036116 100644 --- a/integration-tests/go.mod +++ b/integration-tests/go.mod @@ -12,7 +12,7 @@ require ( github.com/onsi/gomega v1.27.8 github.com/rs/zerolog v1.29.1 github.com/satori/go.uuid v1.2.1-0.20181028125025-b2ce2384e17b - github.com/smartcontractkit/chainlink-env v0.35.0 + github.com/smartcontractkit/chainlink-env v0.36.1-0.20230802063028-a432269a7384 github.com/smartcontractkit/chainlink-solana v1.0.3-0.20230612131011-369bfb503592 github.com/smartcontractkit/chainlink-testing-framework v1.14.0 github.com/smartcontractkit/chainlink/integration-tests v0.0.0-20230713025544-29b418df4ded diff --git a/integration-tests/go.sum b/integration-tests/go.sum index 92a9c676b..f57ec28ca 100644 --- a/integration-tests/go.sum +++ b/integration-tests/go.sum @@ -1336,8 +1336,8 @@ github.com/slack-go/slack v0.12.2/go.mod h1:hlGi5oXA+Gt+yWTPP0plCdRKmjsDxecdHxYQ github.com/smartcontractkit/caigo v0.0.0-20230621050857-b29a4ca8c704 h1:T3lFWumvbfM1u/etVq42Afwq/jtNSBSOA8n5jntnNPo= github.com/smartcontractkit/caigo v0.0.0-20230621050857-b29a4ca8c704/go.mod h1:2QuJdEouTWjh5BDy5o/vgGXQtR4Gz8yH1IYB5eT7u4M= github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20230525203711-20bed74ac906 h1:u7Lw7oqLEjADlJPJQnzlCLNSbj038QttaKY0lCa3V78= -github.com/smartcontractkit/chainlink-env v0.35.0 h1:bjF+OOqWJUEIGmoiOZ6k1D4q6J6S/MqD269m37u0Ub8= -github.com/smartcontractkit/chainlink-env v0.35.0/go.mod h1:hMOkTDW5k0C5B5lup1+xpPiZQPkq84YGLuFDVdTKU7A= +github.com/smartcontractkit/chainlink-env v0.36.1-0.20230802063028-a432269a7384 h1:AGEK80chNqkA9VouRtxkHZPG/WDrNGfpR/P7NyhRyYA= +github.com/smartcontractkit/chainlink-env v0.36.1-0.20230802063028-a432269a7384/go.mod h1:NbRExHmJGnKSYXmvNuJx5VErSx26GtE1AEN/CRzYOg8= github.com/smartcontractkit/chainlink-relay v0.1.7-0.20230620171700-bbcb3a99b7d3 h1:rlNWHk15A2im/e9U95q4AkHZk5Wbc77lpx6ys4kUyCE= github.com/smartcontractkit/chainlink-relay v0.1.7-0.20230620171700-bbcb3a99b7d3/go.mod h1:MfZBUifutkv3aK7abyw5YmTJbqt8iFwcQDFikrxC/uI= github.com/smartcontractkit/chainlink-starknet/relayer v0.0.1-beta-test.0.20230622060316-7ce48476dd7d h1:4jSCp6i/p/EIaAkYQDxPK8nXDuv0fBXzKIcVYzetCoI= diff --git a/integration-tests/smoke/ocr2_test.go b/integration-tests/smoke/ocr2_test.go index c611909f9..45588de6c 100644 --- a/integration-tests/smoke/ocr2_test.go +++ b/integration-tests/smoke/ocr2_test.go @@ -43,7 +43,6 @@ func TestSolanaOCRV2Smoke(t *testing.T) { l.Error().Err(err).Msg("Error tearing down environment") } }) - state.SetAllAdapterResponsesToTheSameValue(10) state.ValidateRoundsAfter(time.Now(), common.NewRoundCheckTimeout, 1) } @@ -67,7 +66,6 @@ func TestSolanaGauntletOCRV2Smoke(t *testing.T) { l.Error().Err(err).Msg("Error tearing down environment") } }) - state.SetupClients() state.NodeKeysBundle, err = state.Common.CreateNodeKeysBundle(state.ChainlinkNodes) require.NoError(t, err) @@ -131,8 +129,6 @@ func TestSolanaGauntletOCRV2Smoke(t *testing.T) { err = state.Common.CreateSolanaChainAndNode(state.ChainlinkNodes) require.NoError(t, err) - err = state.MockServer.SetValuePath("/juels", 1) - require.NoError(t, err) // TODO - This needs to be decoupled into one method as in common.go // TODO - The current setup in common.go is using the solana validator, so we need to create one method for both gauntlet and solana @@ -167,7 +163,7 @@ func TestSolanaGauntletOCRV2Smoke(t *testing.T) { } sourceValueBridge := client.BridgeTypeAttributes{ Name: "mockserver-bridge", - URL: fmt.Sprintf("%s/%s", state.MockServer.Config.ClusterURL, "juels"), + URL: fmt.Sprintf("%s/%s", state.Common.Env.URLs["qa_mock_adapter_internal"][0], "five"), RequestData: "{}", } @@ -190,7 +186,7 @@ func TestSolanaGauntletOCRV2Smoke(t *testing.T) { require.NoError(t, err, "Error sending Funds") sourceValueBridge := client.BridgeTypeAttributes{ Name: "mockserver-bridge", - URL: fmt.Sprintf("%s/%s", state.MockServer.Config.ClusterURL, "juels"), + URL: fmt.Sprintf("%s/%s", state.Common.Env.URLs["qa_mock_adapter_internal"][0], "five"), RequestData: "{}", } _, err := node.CreateBridge(&sourceValueBridge) @@ -225,7 +221,7 @@ func TestSolanaGauntletOCRV2Smoke(t *testing.T) { l.Info().Str("Contract", sg.OcrAddress).Str("No", "Transmissions") } else { l.Info().Str("Contract", sg.OcrAddress).Interface("Answer", transmissions[0].Answer).Int64("RoundID", transmissions[0].RoundId).Msg("New answer found") - assert.Equal(t, transmissions[0].Answer, int64(1), fmt.Sprintf("Actual: %d, Expected: 1", transmissions[0].Answer)) + assert.Equal(t, transmissions[0].Answer, int64(5), fmt.Sprintf("Actual: %d, Expected: 5", transmissions[0].Answer)) assert.Less(t, transmissions[1].RoundId, transmissions[0].RoundId, fmt.Sprintf("Expected round %d to be less than %d", transmissions[1].RoundId, transmissions[0].RoundId)) } time.Sleep(time.Second * 6) diff --git a/integration-tests/soak/ocr2_soak_test.go b/integration-tests/soak/ocr2_soak_test.go index 64d4e201f..2d52bae4c 100644 --- a/integration-tests/soak/ocr2_soak_test.go +++ b/integration-tests/soak/ocr2_soak_test.go @@ -19,6 +19,5 @@ func TestSolanaOCRV2SoakTest(t *testing.T) { return } state.DeployCluster(utils.ContractsDir) - state.SetAllAdapterResponsesToTheSameValue(10) state.ValidateRoundsAfter(time.Now(), common.NewSoakRoundsCheckTimeout, 20000) }