Skip to content

Commit

Permalink
Modify the chainlink-solana test structs to handle more than one data… (
Browse files Browse the repository at this point in the history
#189)

* Modify the chainlink-solana test structs to handle more than one data source

* format
  • Loading branch information
gheorghestrimtu authored Feb 7, 2022
1 parent 5136184 commit c31d761
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
26 changes: 20 additions & 6 deletions tests/e2e/common/test_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
)

const (
SourcePath = "/variable"
ContractsStateFile = "contracts-chaos-state.json"
NewRoundCheckTimeout = 90 * time.Second
NewRoundCheckPollInterval = 1 * time.Second
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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()
Expand All @@ -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)
}
}()
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/smoke/ocr2_test.go
Original file line number Diff line number Diff line change
@@ -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() {
Expand Down

0 comments on commit c31d761

Please sign in to comment.