From c31d761a91e790502da2232428b169b824875cb1 Mon Sep 17 00:00:00 2001 From: Gheorghe Strimtu Date: Mon, 7 Feb 2022 19:49:51 +0200 Subject: [PATCH] =?UTF-8?q?Modify=20the=20chainlink-solana=20test=20struct?= =?UTF-8?q?s=20to=20handle=20more=20than=20one=20data=E2=80=A6=20(#189)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Modify the chainlink-solana test structs to handle more than one data source * format --- tests/e2e/common/test_common.go | 26 ++++++++++++++++++++------ tests/e2e/smoke/ocr2_test.go | 2 +- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/tests/e2e/common/test_common.go b/tests/e2e/common/test_common.go index fd13f30bd..675943d8a 100644 --- a/tests/e2e/common/test_common.go +++ b/tests/e2e/common/test_common.go @@ -20,7 +20,6 @@ import ( ) const ( - SourcePath = "/variable" ContractsStateFile = "contracts-chaos-state.json" NewRoundCheckTimeout = 90 * time.Second NewRoundCheckPollInterval = 1 * time.Second @@ -240,7 +239,7 @@ func (m *OCRv2TestState) createJobs() { } sourceValueBridge := client.BridgeTypeAttributes{ Name: "variable", - URL: fmt.Sprintf("%s/variable", m.MockServer.Config.ClusterURL), + URL: fmt.Sprintf("%s/node%d", m.MockServer.Config.ClusterURL, nIdx), RequestData: "{}", } observationSource := client.ObservationSourceSpecBridge(sourceValueBridge) @@ -274,9 +273,24 @@ func (m *OCRv2TestState) createJobs() { } } +func (m *OCRv2TestState) SetAllAdapterResponsesToTheSameValue(response int) { + for i := range m.ChainlinkNodes { + path := fmt.Sprintf("/node%d", i) + m.err = m.MockServer.SetValuePath(path, response) + Expect(m.err).ShouldNot(HaveOccurred()) + } +} + +func (m *OCRv2TestState) SetAllAdapterResponsesToDifferentValues(responses []int) { + Expect(len(responses)).Should(BeNumerically("==", len(m.ChainlinkNodes))) + for i := range m.ChainlinkNodes { + m.err = m.MockServer.SetValuePath(fmt.Sprintf("/node%d", i), responses[i]) + Expect(m.err).ShouldNot(HaveOccurred()) + } +} + func (m *OCRv2TestState) CreateJobs() { - m.err = m.MockServer.SetValuePath("/variable", 5) - Expect(m.err).ShouldNot(HaveOccurred()) + m.SetAllAdapterResponsesToTheSameValue(5) m.err = m.MockServer.SetValuePath("/juels", 1) Expect(m.err).ShouldNot(HaveOccurred()) m.createJobs() @@ -285,9 +299,9 @@ func (m *OCRv2TestState) CreateJobs() { func (m *OCRv2TestState) ImitateSource(changeInterval time.Duration, min int, max int) { go func() { for { - _ = m.MockServer.SetValuePath(SourcePath, min) + m.SetAllAdapterResponsesToTheSameValue(min) time.Sleep(changeInterval) - _ = m.MockServer.SetValuePath(SourcePath, max) + m.SetAllAdapterResponsesToTheSameValue(max) time.Sleep(changeInterval) } }() diff --git a/tests/e2e/smoke/ocr2_test.go b/tests/e2e/smoke/ocr2_test.go index 64a2cba6d..9a1dd7e8b 100644 --- a/tests/e2e/smoke/ocr2_test.go +++ b/tests/e2e/smoke/ocr2_test.go @@ -1,13 +1,13 @@ package smoke import ( + "github.com/smartcontractkit/integrations-framework/actions" "time" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "github.com/rs/zerolog/log" "github.com/smartcontractkit/chainlink-solana/tests/e2e/common" - "github.com/smartcontractkit/integrations-framework/actions" ) var _ = Describe("Solana OCRv2", func() {