Skip to content

Commit

Permalink
minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ilija42 committed Jan 8, 2024
1 parent 216bf1a commit a957c10
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 38 deletions.
5 changes: 2 additions & 3 deletions integration-tests/actions/ocr2_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -450,15 +450,14 @@ func StartNewOCR2Round(
return nil
}

// StartNewOCR2RoundChainReaderDemo requests a new round from the ocr2 contracts and waits for confirmation
func StartNewOCR2RoundChainReaderDemo(
// WatchNewOCR2RoundChainReaderDemo requests a new round from the ocr2 contracts and waits for confirmation
func WatchNewOCR2RoundChainReaderDemo(
roundNumber int64,
ocrInstances []contracts.OffchainAggregatorV2,
client blockchain.EVMClient,
timeout time.Duration,
logger zerolog.Logger,
) error {
time.Sleep(5 * time.Second)
for i := 0; i < len(ocrInstances); i++ {
err := ocrInstances[i].RequestNewRound()
if err != nil {
Expand Down
5 changes: 5 additions & 0 deletions integration-tests/contracts/ethereum_contracts.go
Original file line number Diff line number Diff line change
Expand Up @@ -2156,6 +2156,9 @@ func (e EthereumOffchainAggregatorV2ChainReaderDemo) GetRound(ctx context.Contex
if err != nil {
return nil, err
}

fmt.Printf("Get Round data \n RoundId %s \n StartedAt %v \n UpdatedAt %d \n AnsweredInRound %d \n Answer: %d \n\n ", data.RoundId, data.StartedAt, data.UpdatedAt, data.AnsweredInRound, data.Answer)

return &RoundData{
RoundId: data.RoundId,
StartedAt: data.StartedAt,
Expand Down Expand Up @@ -2250,6 +2253,8 @@ func (e *EthereumOffchainAggregatorV2) GetRound(ctx context.Context, roundID *bi
if err != nil {
return nil, err
}
fmt.Printf("Get Round data \n RoundId %s \n StartedAt %v \n UpdatedAt %d \n AnsweredInRound %d \n Answer: %d \n\n ", data.RoundId, data.StartedAt, data.UpdatedAt, data.AnsweredInRound, data.Answer)

return &RoundData{
RoundId: data.RoundId,
StartedAt: data.StartedAt,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/stretchr/testify/require"

"github.com/smartcontractkit/chainlink-testing-framework/utils/testcontext"
"github.com/smartcontractkit/chainlink/v2/core/config/env"

"github.com/smartcontractkit/chainlink-testing-framework/logging"
"github.com/smartcontractkit/chainlink-testing-framework/utils/ptr"
Expand Down Expand Up @@ -39,10 +40,11 @@ func TestOCRv2BasicWithChainReaderAndCodecDemo(t *testing.T) {
node.WithP2Pv2(),
node.WithTracing(),
func(c *chainlink.Config) {
c.Core.WebServer.HTTPMaxSize = ptr.Ptr(utils.FileSize(65536))
c.Core.WebServer.HTTPMaxSize = ptr.Ptr(utils.FileSize(165536))
},
)).
WithCLNodes(6).
WithCLNodeOptions(test_env.WithNodeEnvVars(map[string]string{string(env.MedianPluginCmd): ""})).
WithFunding(big.NewFloat(.1)).
WithStandardCleanup().
WithLogStream().
Expand Down Expand Up @@ -92,50 +94,24 @@ func TestOCRv2BasicWithChainReaderAndCodecDemo(t *testing.T) {
err = env.MockAdapter.SetAdapterBasedIntValuePath("ocr2", []string{http.MethodGet, http.MethodPost}, 50)
require.NoError(t, err)

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

err = actions.WatchNewOCR2RoundChainReaderDemo(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(testcontext.Get(t), big.NewInt(1))
require.NoError(t, err, "Getting latest answer from OCR contract shouldn't fail")
fmt.Println("get latest")

fmt.Printf("want 50 it's %v\n", roundData.Answer.Int64())

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

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

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

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

fmt.Printf("want 10 it's %v\n", roundData.Answer.Int64())

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

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

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

fmt.Printf("want 15 it's %v\n", roundData.Answer.Int64())

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

0 comments on commit a957c10

Please sign in to comment.