Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replaced mockserver with mock adapter #535

Merged
merged 5 commits into from
Aug 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/e2e_custom_cl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/e2e_testnet_daily.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
21 changes: 21 additions & 0 deletions docs/RunningE2eTests.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 7 additions & 10 deletions integration-tests/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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())
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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,
Expand Down
21 changes: 2 additions & 19 deletions integration-tests/common/test_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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++ {
Expand All @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions integration-tests/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
10 changes: 3 additions & 7 deletions integration-tests/smoke/ocr2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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: "{}",
}

Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion integration-tests/soak/ocr2_soak_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,5 @@ func TestSolanaOCRV2SoakTest(t *testing.T) {
return
}
state.DeployCluster(utils.ContractsDir)
state.SetAllAdapterResponsesToTheSameValue(10)
state.ValidateRoundsAfter(time.Now(), common.NewSoakRoundsCheckTimeout, 20000)
}
Loading