Skip to content

Commit

Permalink
Refrains From Explicitly Requesting New OCR Rounds (#11656)
Browse files Browse the repository at this point in the history
* Refrains From Explicitly Requesting New OCR Rounds

* Fix Forwarder as Well
  • Loading branch information
kalverra authored Jan 5, 2024
1 parent 3ea324f commit 094b252
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 7 deletions.
19 changes: 19 additions & 0 deletions integration-tests/actions/ocr_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,25 @@ func StartNewRound(
return nil
}

// WatchNewRound watches for a new OCR round, similarly to StartNewRound, but it does not explicitly request a new
// round from the contract, as this can cause some odd behavior in some cases
func WatchNewRound(
roundNumber int64,
ocrInstances []contracts.OffchainAggregator,
client blockchain.EVMClient,
logger zerolog.Logger,
) error {
for i := 0; i < len(ocrInstances); i++ {
ocrRound := contracts.NewOffchainAggregatorRoundConfirmer(ocrInstances[i], big.NewInt(roundNumber), client.GetNetworkConfig().Timeout.Duration, logger)
client.AddHeaderEventSubscription(ocrInstances[i].Address(), ocrRound)
err := client.WaitForEvents()
if err != nil {
return fmt.Errorf("failed to wait for event subscriptions of OCR instance %d: %w", i+1, err)
}
}
return nil
}

// SetAdapterResponse sets a single adapter response that correlates with an ocr contract and a chainlink node
func SetAdapterResponse(
response int,
Expand Down
4 changes: 2 additions & 2 deletions integration-tests/smoke/forwarder_ocr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func TestForwarderOCRBasic(t *testing.T) {

err = actions.CreateOCRJobsWithForwarderLocal(ocrInstances, bootstrapNode, workerNodes, 5, env.MockAdapter, env.EVMClient.GetChainID().String())
require.NoError(t, err, "failed to setup forwarder jobs")
err = actions.StartNewRound(1, ocrInstances, env.EVMClient, l)
err = actions.WatchNewRound(1, ocrInstances, env.EVMClient, l)
require.NoError(t, err)
err = env.EVMClient.WaitForEvents()
require.NoError(t, err, "Error waiting for events")
Expand All @@ -79,7 +79,7 @@ func TestForwarderOCRBasic(t *testing.T) {

err = actions.SetAllAdapterResponsesToTheSameValueLocal(10, ocrInstances, workerNodes, env.MockAdapter)
require.NoError(t, err)
err = actions.StartNewRound(2, ocrInstances, env.EVMClient, l)
err = actions.WatchNewRound(2, ocrInstances, env.EVMClient, l)
require.NoError(t, err)
err = env.EVMClient.WaitForEvents()
require.NoError(t, err, "Error waiting for events")
Expand Down
10 changes: 5 additions & 5 deletions integration-tests/smoke/ocr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func TestOCRBasic(t *testing.T) {
err = actions.CreateOCRJobsLocal(ocrInstances, bootstrapNode, workerNodes, 5, env.MockAdapter, env.EVMClient.GetChainID())
require.NoError(t, err)

err = actions.StartNewRound(1, ocrInstances, env.EVMClient, l)
err = actions.WatchNewRound(1, ocrInstances, env.EVMClient, l)
require.NoError(t, err)

answer, err := ocrInstances[0].GetLatestAnswer(testcontext.Get(t))
Expand All @@ -56,7 +56,7 @@ func TestOCRBasic(t *testing.T) {

err = actions.SetAllAdapterResponsesToTheSameValueLocal(10, ocrInstances, workerNodes, env.MockAdapter)
require.NoError(t, err)
err = actions.StartNewRound(2, ocrInstances, env.EVMClient, l)
err = actions.WatchNewRound(2, ocrInstances, env.EVMClient, l)
require.NoError(t, err)

answer, err = ocrInstances[0].GetLatestAnswer(testcontext.Get(t))
Expand Down Expand Up @@ -94,7 +94,7 @@ func TestOCRJobReplacement(t *testing.T) {
err = actions.CreateOCRJobsLocal(ocrInstances, bootstrapNode, workerNodes, 5, env.MockAdapter, env.EVMClient.GetChainID())
require.NoError(t, err)

err = actions.StartNewRound(1, ocrInstances, env.EVMClient, l)
err = actions.WatchNewRound(1, ocrInstances, env.EVMClient, l)
require.NoError(t, err)

answer, err := ocrInstances[0].GetLatestAnswer(testcontext.Get(t))
Expand All @@ -103,7 +103,7 @@ func TestOCRJobReplacement(t *testing.T) {

err = actions.SetAllAdapterResponsesToTheSameValueLocal(10, ocrInstances, workerNodes, env.MockAdapter)
require.NoError(t, err)
err = actions.StartNewRound(2, ocrInstances, env.EVMClient, l)
err = actions.WatchNewRound(2, ocrInstances, env.EVMClient, l)
require.NoError(t, err)

answer, err = ocrInstances[0].GetLatestAnswer(testcontext.Get(t))
Expand All @@ -120,7 +120,7 @@ func TestOCRJobReplacement(t *testing.T) {
err = actions.CreateOCRJobsLocal(ocrInstances, bootstrapNode, workerNodes, 5, env.MockAdapter, env.EVMClient.GetChainID())
require.NoError(t, err)

err = actions.StartNewRound(1, ocrInstances, env.EVMClient, l)
err = actions.WatchNewRound(1, ocrInstances, env.EVMClient, l)
require.NoError(t, err)

answer, err = ocrInstances[0].GetLatestAnswer(testcontext.Get(t))
Expand Down

0 comments on commit 094b252

Please sign in to comment.