From 95f3e7be9809c71deb112657b83d5dc4cd47088b Mon Sep 17 00:00:00 2001 From: Jordan Krage Date: Mon, 17 Jun 2024 13:35:14 -0500 Subject: [PATCH] core/services/ocr2/plugins/mercury: fix integration test race on shared error (#13555) --- .../ocr2/plugins/mercury/integration_test.go | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/core/services/ocr2/plugins/mercury/integration_test.go b/core/services/ocr2/plugins/mercury/integration_test.go index 680b05bd4d4..7be5177f765 100644 --- a/core/services/ocr2/plugins/mercury/integration_test.go +++ b/core/services/ocr2/plugins/mercury/integration_test.go @@ -184,15 +184,17 @@ func integration_MercuryV1(t *testing.T) { bootstrapNode := Node{App: appBootstrap, KeyBundle: bootstrapKb} logObservers = append(logObservers, observedLogs) - // Commit blocks to finality depth to ensure LogPoller has finalized blocks to read from - ch, err := bootstrapNode.App.GetRelayers().LegacyEVMChains().Get(testutils.SimulatedChainID.String()) - require.NoError(t, err) - finalityDepth := ch.Config().EVM().FinalityDepth() - for i := 0; i < int(finalityDepth); i++ { - backend.Commit() - } - - fromBlock := int(finalityDepth) // cannot use zero, start from finality depth + // cannot use zero, start from finality depth + fromBlock := func() int { + // Commit blocks to finality depth to ensure LogPoller has finalized blocks to read from + ch, err := bootstrapNode.App.GetRelayers().LegacyEVMChains().Get(testutils.SimulatedChainID.String()) + require.NoError(t, err) + finalityDepth := ch.Config().EVM().FinalityDepth() + for i := 0; i < int(finalityDepth); i++ { + backend.Commit() + } + return int(finalityDepth) + }() // Set up n oracles var ( @@ -225,8 +227,7 @@ func integration_MercuryV1(t *testing.T) { createBridge := func(name string, i int, p *big.Int, borm bridges.ORM) (bridgeName string) { bridge := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { - var b []byte - b, err = io.ReadAll(req.Body) + b, err := io.ReadAll(req.Body) require.NoError(t, err) require.Equal(t, `{"data":{"from":"ETH","to":"USD"}}`, string(b))