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

integration-tests/smoke: TestOCRv2BasicWithChainReaderAndCodec add subtests for pulgins and chainreader/codec #11756

Closed
wants to merge 1 commit into from
Closed
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
203 changes: 112 additions & 91 deletions integration-tests/smoke/chain_reader_and_codec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"github.com/smartcontractkit/chainlink-common/pkg/utils/tests"
"github.com/smartcontractkit/chainlink-testing-framework/logging"
"github.com/smartcontractkit/chainlink-testing-framework/utils/ptr"
"github.com/smartcontractkit/chainlink/v2/core/config/env"

"github.com/smartcontractkit/chainlink/v2/core/services/chainlink"
"github.com/smartcontractkit/chainlink/v2/core/utils"
Expand All @@ -23,96 +24,116 @@
)

func TestOCRv2BasicWithChainReaderAndCodec(t *testing.T) {
l := logging.GetTestLogger(t)

env, err := test_env.NewCLTestEnvBuilder().
WithTestInstance(t).
WithGeth().
WithMockAdapter().
WithCLNodeConfig(node.NewConfig(node.NewBaseConfig(),
node.WithOCR2(),
node.WithP2Pv2(),
node.WithTracing(),
func(c *chainlink.Config) {
c.Core.WebServer.HTTPMaxSize = ptr.Ptr(utils.FileSize(65536))
},
)).
WithCLNodes(6).
WithFunding(big.NewFloat(.1)).
WithStandardCleanup().
WithLogStream().
Build()
fmt.Println("Done starting")

env.ParallelTransactions(true)

nodeClients := env.ClCluster.NodeAPIs()
bootstrapNode, workerNodes := nodeClients[0], nodeClients[1:]

linkToken, err := env.ContractDeployer.DeployLinkTokenContract()
require.NoError(t, err, "Deploying Link Token Contract shouldn't fail")

err = actions.FundChainlinkNodesLocal(workerNodes, env.EVMClient, big.NewFloat(.05))
require.NoError(t, err, "Error funding Chainlink nodes")

// Gather transmitters
var transmitters []string
for _, node := range workerNodes {
addr, err := node.PrimaryEthAddress()
if err != nil {
require.NoError(t, fmt.Errorf("error getting node's primary ETH address: %w", err))
}
transmitters = append(transmitters, addr)
t.Parallel()

noMedianPlugin := map[string]string{string(env.MedianPluginCmd): ""}
medianPlugin := map[string]string{string(env.MedianPluginCmd): "chainlink-feeds"}
for _, test := range []struct {
name string
env map[string]string
chainReaderAndCodec bool
}{
{"legacy", noMedianPlugin, false},
{"legacy-chain-reader", noMedianPlugin, true},
{"plugins", medianPlugin, false},
{"plugins-chain-reader", medianPlugin, true},
} {
test := test
t.Run(test.name, func(t *testing.T) {
t.Parallel()

l := logging.GetTestLogger(t)

env, err := test_env.NewCLTestEnvBuilder().

Check failure on line 47 in integration-tests/smoke/chain_reader_and_codec_test.go

View workflow job for this annotation

GitHub Actions / Build and Lint integration-tests

ineffectual assignment to err (ineffassign)
WithTestInstance(t).
WithGeth().
WithMockAdapter().
WithCLNodeConfig(node.NewConfig(node.NewBaseConfig(),
node.WithOCR2(),
node.WithP2Pv2(),
node.WithTracing(),
func(c *chainlink.Config) {
c.Core.WebServer.HTTPMaxSize = ptr.Ptr(utils.FileSize(65536))
},
)).
WithCLNodes(6).
WithFunding(big.NewFloat(.1)).
WithStandardCleanup().
WithLogStream().
Build()
fmt.Println("Done starting")

env.ParallelTransactions(true)

nodeClients := env.ClCluster.NodeAPIs()
bootstrapNode, workerNodes := nodeClients[0], nodeClients[1:]

linkToken, err := env.ContractDeployer.DeployLinkTokenContract()
require.NoError(t, err, "Deploying Link Token Contract shouldn't fail")

err = actions.FundChainlinkNodesLocal(workerNodes, env.EVMClient, big.NewFloat(.05))
require.NoError(t, err, "Error funding Chainlink nodes")

// Gather transmitters
var transmitters []string
for _, node := range workerNodes {
addr, err := node.PrimaryEthAddress()
if err != nil {
require.NoError(t, fmt.Errorf("error getting node's primary ETH address: %w", err))
}
transmitters = append(transmitters, addr)
}

ocrOffchainOptions := contracts.DefaultOffChainAggregatorOptions()
aggregatorContracts, err := actions.DeployOCRv2Contracts(1, linkToken, env.ContractDeployer, transmitters, env.EVMClient, ocrOffchainOptions)
require.NoError(t, err, "Error deploying OCRv2 aggregator contracts")

err = actions.CreateOCRv2JobsLocal(aggregatorContracts, bootstrapNode, workerNodes, env.MockAdapter, "ocr2", 5, env.EVMClient.GetChainID().Uint64(), false, true)
require.NoError(t, err, "Error creating OCRv2 jobs")
fmt.Println("Jobs done")

ocrv2Config, err := actions.BuildMedianOCR2ConfigLocal(workerNodes, ocrOffchainOptions)
require.NoError(t, err)
require.NoError(t, err, "Error building OCRv2 config")
fmt.Println("built local")

err = actions.ConfigureOCRv2AggregatorContracts(env.EVMClient, ocrv2Config, aggregatorContracts)
require.NoError(t, err, "Error configuring OCRv2 aggregator contracts")
fmt.Println("built agg")

err = actions.StartNewOCR2Round(1, aggregatorContracts, env.EVMClient, time.Minute*5, l)

require.NoError(t, err, "Error starting new OCR2 round")
fmt.Println("round done")

roundData, err := aggregatorContracts[0].GetRound(tests.Context(t), big.NewInt(1))
require.NoError(t, err, "Getting latest answer from OCR contract shouldn't fail")
fmt.Println("get latest")

require.Equal(t, int64(5), roundData.Answer.Int64(),
"Expected latest answer from OCR contract to be 5 but got %d",
roundData.Answer.Int64(),
)
fmt.Println("answer")

err = env.MockAdapter.SetAdapterBasedIntValuePath("ocr2", []string{http.MethodGet, http.MethodPost}, 10)
require.NoError(t, err)
fmt.Println("adapter")

err = actions.StartNewOCR2Round(2, aggregatorContracts, env.EVMClient, time.Minute*5, l)
require.NoError(t, err)
fmt.Println("new round 2")

roundData, err = aggregatorContracts[0].GetRound(tests.Context(t), big.NewInt(2))
require.NoError(t, err, "Error getting latest OCR answer")
fmt.Println("got answer 2")

require.Equal(t, int64(10), roundData.Answer.Int64(),
"Expected latest answer from OCR contract to be 10 but got %d",
roundData.Answer.Int64(),
)
fmt.Println("values equal")
require.Fail(t, "Capture logs")
})
}

ocrOffchainOptions := contracts.DefaultOffChainAggregatorOptions()
aggregatorContracts, err := actions.DeployOCRv2Contracts(1, linkToken, env.ContractDeployer, transmitters, env.EVMClient, ocrOffchainOptions)
require.NoError(t, err, "Error deploying OCRv2 aggregator contracts")

err = actions.CreateOCRv2JobsLocal(aggregatorContracts, bootstrapNode, workerNodes, env.MockAdapter, "ocr2", 5, env.EVMClient.GetChainID().Uint64(), false, true)
require.NoError(t, err, "Error creating OCRv2 jobs")
fmt.Println("Jobs done")

ocrv2Config, err := actions.BuildMedianOCR2ConfigLocal(workerNodes, ocrOffchainOptions)
require.NoError(t, err)
require.NoError(t, err, "Error building OCRv2 config")
fmt.Println("built local")

err = actions.ConfigureOCRv2AggregatorContracts(env.EVMClient, ocrv2Config, aggregatorContracts)
require.NoError(t, err, "Error configuring OCRv2 aggregator contracts")
fmt.Println("built agg")

err = actions.StartNewOCR2Round(1, aggregatorContracts, env.EVMClient, time.Minute*5, l)

require.NoError(t, err, "Error starting new OCR2 round")
fmt.Println("round done")

roundData, err := aggregatorContracts[0].GetRound(tests.Context(t), big.NewInt(1))
require.NoError(t, err, "Getting latest answer from OCR contract shouldn't fail")
fmt.Println("get latest")

require.Equal(t, int64(5), roundData.Answer.Int64(),
"Expected latest answer from OCR contract to be 5 but got %d",
roundData.Answer.Int64(),
)
fmt.Println("answer")

err = env.MockAdapter.SetAdapterBasedIntValuePath("ocr2", []string{http.MethodGet, http.MethodPost}, 10)
require.NoError(t, err)
fmt.Println("adapter")

err = actions.StartNewOCR2Round(2, aggregatorContracts, env.EVMClient, time.Minute*5, l)
require.NoError(t, err)
fmt.Println("new round 2")

roundData, err = aggregatorContracts[0].GetRound(tests.Context(t), big.NewInt(2))
require.NoError(t, err, "Error getting latest OCR answer")
fmt.Println("got answer 2")

require.Equal(t, int64(10), roundData.Answer.Int64(),
"Expected latest answer from OCR contract to be 10 but got %d",
roundData.Answer.Int64(),
)
fmt.Println("values equal")
require.Fail(t, "Capture logs")
}
Loading