Skip to content

Commit

Permalink
[TT-1179] median plugin fix (#13239)
Browse files Browse the repository at this point in the history
* add support for median plugin in OCR2 tests

* add support for median plugin in OCR2 tests
  • Loading branch information
Tofel authored May 17, 2024
1 parent 0b100ad commit e25f129
Showing 1 changed file with 21 additions and 10 deletions.
31 changes: 21 additions & 10 deletions integration-tests/smoke/ocr2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,27 @@ import (
"github.com/smartcontractkit/chainlink/integration-tests/types/config/node"
)

type ocr2test struct {
name string
env map[string]string
chainReaderAndCodec bool
}

func defaultTestData() ocr2test {
return ocr2test{
name: "n/a",
env: make(map[string]string),
chainReaderAndCodec: false,
}
}

// Tests a basic OCRv2 median feed
func TestOCRv2Basic(t *testing.T) {
t.Parallel()

noMedianPlugin := map[string]string{string(env.MedianPlugin.Cmd): ""}
medianPlugin := map[string]string{string(env.MedianPlugin.Cmd): "chainlink-feeds"}
for _, test := range []struct {
name string
env map[string]string
chainReaderAndCodec bool
}{
for _, test := range []ocr2test{
{"legacy", noMedianPlugin, false},
{"legacy-chain-reader", noMedianPlugin, true},
{"plugins", medianPlugin, false},
Expand All @@ -46,7 +56,7 @@ func TestOCRv2Basic(t *testing.T) {
t.Parallel()
l := logging.GetTestLogger(t)

env, aggregatorContracts, sethClient := prepareORCv2SmokeTestEnv(t, l, 5)
env, aggregatorContracts, sethClient := prepareORCv2SmokeTestEnv(t, test, l, 5)

err := env.MockAdapter.SetAdapterBasedIntValuePath("ocr2", []string{http.MethodGet, http.MethodPost}, 10)
require.NoError(t, err)
Expand All @@ -68,7 +78,7 @@ func TestOCRv2Request(t *testing.T) {
t.Parallel()
l := logging.GetTestLogger(t)

_, aggregatorContracts, sethClient := prepareORCv2SmokeTestEnv(t, l, 5)
_, aggregatorContracts, sethClient := prepareORCv2SmokeTestEnv(t, defaultTestData(), l, 5)

// Keep the mockserver value the same and continually request new rounds
for round := 2; round <= 4; round++ {
Expand All @@ -90,7 +100,7 @@ func TestOCRv2JobReplacement(t *testing.T) {
t.Parallel()
l := logging.GetTestLogger(t)

env, aggregatorContracts, sethClient := prepareORCv2SmokeTestEnv(t, l, 5)
env, aggregatorContracts, sethClient := prepareORCv2SmokeTestEnv(t, defaultTestData(), l, 5)
nodeClients := env.ClCluster.NodeAPIs()
bootstrapNode, workerNodes := nodeClients[0], nodeClients[1:]

Expand Down Expand Up @@ -126,7 +136,7 @@ func TestOCRv2JobReplacement(t *testing.T) {
)
}

func prepareORCv2SmokeTestEnv(t *testing.T, l zerolog.Logger, firstRoundResult int) (*test_env.CLClusterTestEnv, []contracts.OffchainAggregatorV2, *seth.Client) {
func prepareORCv2SmokeTestEnv(t *testing.T, testData ocr2test, l zerolog.Logger, firstRoundResult int) (*test_env.CLClusterTestEnv, []contracts.OffchainAggregatorV2, *seth.Client) {
config, err := tc.GetConfig("Smoke", tc.OCR2)
if err != nil {
t.Fatal(err)
Expand All @@ -145,6 +155,7 @@ func prepareORCv2SmokeTestEnv(t *testing.T, l zerolog.Logger, firstRoundResult i
node.WithP2Pv2(),
node.WithTracing(),
)).
WithCLNodeOptions(test_env.WithNodeEnvVars(testData.env)).
WithCLNodes(6).
WithFunding(big.NewFloat(.1)).
WithStandardCleanup().
Expand Down Expand Up @@ -179,7 +190,7 @@ func prepareORCv2SmokeTestEnv(t *testing.T, l zerolog.Logger, firstRoundResult i
aggregatorContracts, err := actions_seth.DeployOCRv2Contracts(l, sethClient, 1, common.HexToAddress(linkContract.Address()), transmitters, ocrOffchainOptions)
require.NoError(t, err, "Error deploying OCRv2 aggregator contracts")

err = actions.CreateOCRv2JobsLocal(aggregatorContracts, bootstrapNode, workerNodes, env.MockAdapter, "ocr2", 5, uint64(sethClient.ChainID), false, false)
err = actions.CreateOCRv2JobsLocal(aggregatorContracts, bootstrapNode, workerNodes, env.MockAdapter, "ocr2", 5, uint64(sethClient.ChainID), false, testData.chainReaderAndCodec)
require.NoError(t, err, "Error creating OCRv2 jobs")

ocrv2Config, err := actions.BuildMedianOCR2ConfigLocal(workerNodes, ocrOffchainOptions)
Expand Down

0 comments on commit e25f129

Please sign in to comment.