From b584df5c4f99a9e2c8734959a40cf730bbb1435a Mon Sep 17 00:00:00 2001 From: krehermann Date: Fri, 21 Jun 2024 09:51:15 -0600 Subject: [PATCH] fix error scope to avoid data race (#13642) * fix error scope to avoid data race * fix another instance, and local scope other errors * MERC-5697: reinstate test in CI --- .../ocr2/plugins/mercury/integration_test.go | 51 +++++++++---------- 1 file changed, 24 insertions(+), 27 deletions(-) diff --git a/core/services/ocr2/plugins/mercury/integration_test.go b/core/services/ocr2/plugins/mercury/integration_test.go index 16d992974c3..832a39237ee 100644 --- a/core/services/ocr2/plugins/mercury/integration_test.go +++ b/core/services/ocr2/plugins/mercury/integration_test.go @@ -126,7 +126,6 @@ func setupBlockchain(t *testing.T) (*bind.TransactOpts, *backends.SimulatedBacke } func TestIntegration_MercuryV1(t *testing.T) { - testutils.SkipFlakey(t, "https://smartcontract-it.atlassian.net/browse/MERC-5697") t.Parallel() integration_MercuryV1(t) @@ -228,8 +227,8 @@ 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) { - b, err := io.ReadAll(req.Body) - require.NoError(t, err) + b, herr := io.ReadAll(req.Body) + require.NoError(t, herr) require.Equal(t, `{"data":{"from":"ETH","to":"USD"}}`, string(b)) r := rand.Int63n(101) @@ -237,13 +236,13 @@ func integration_MercuryV1(t *testing.T) { res.WriteHeader(http.StatusOK) val := decimal.NewFromBigInt(p, 0).Div(decimal.NewFromInt(multiplier)).Add(decimal.NewFromInt(int64(i)).Div(decimal.NewFromInt(100))).String() resp := fmt.Sprintf(`{"result": %s}`, val) - _, err = res.Write([]byte(resp)) - require.NoError(t, err) + _, herr = res.Write([]byte(resp)) + require.NoError(t, herr) } else { res.WriteHeader(http.StatusInternalServerError) resp := `{"error": "pError test error"}` - _, err = res.Write([]byte(resp)) - require.NoError(t, err) + _, herr = res.Write([]byte(resp)) + require.NoError(t, herr) } })) t.Cleanup(bridge.Close) @@ -330,7 +329,7 @@ func integration_MercuryV1(t *testing.T) { "offchainConfig", offchainConfig, ) - _, err = verifier.SetConfig( + _, ferr := verifier.SetConfig( steve, feed.id, signerAddresses, @@ -341,7 +340,7 @@ func integration_MercuryV1(t *testing.T) { offchainConfig, nil, ) - require.NoError(t, err) + require.NoError(t, ferr) backend.Commit() } @@ -582,9 +581,8 @@ func integration_MercuryV2(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) - require.NoError(t, err) + b, herr := io.ReadAll(req.Body) + require.NoError(t, herr) require.Equal(t, `{"data":{"from":"ETH","to":"USD"}}`, string(b)) r := rand.Int63n(101) @@ -592,13 +590,13 @@ func integration_MercuryV2(t *testing.T) { res.WriteHeader(http.StatusOK) val := decimal.NewFromBigInt(p, 0).Div(decimal.NewFromInt(multiplier)).Add(decimal.NewFromInt(int64(i)).Div(decimal.NewFromInt(100))).String() resp := fmt.Sprintf(`{"result": %s}`, val) - _, err = res.Write([]byte(resp)) - require.NoError(t, err) + _, herr = res.Write([]byte(resp)) + require.NoError(t, herr) } else { res.WriteHeader(http.StatusInternalServerError) resp := `{"error": "pError test error"}` - _, err = res.Write([]byte(resp)) - require.NoError(t, err) + _, herr = res.Write([]byte(resp)) + require.NoError(t, herr) } })) t.Cleanup(bridge.Close) @@ -670,7 +668,7 @@ func integration_MercuryV2(t *testing.T) { } for _, feed := range feeds { - _, err = verifier.SetConfig( + _, ferr := verifier.SetConfig( steve, feed.id, signerAddresses, @@ -681,7 +679,7 @@ func integration_MercuryV2(t *testing.T) { offchainConfig, nil, ) - require.NoError(t, err) + require.NoError(t, ferr) backend.Commit() } @@ -872,9 +870,8 @@ func integration_MercuryV3(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) - require.NoError(t, err) + b, herr := io.ReadAll(req.Body) + require.NoError(t, herr) require.Equal(t, `{"data":{"from":"ETH","to":"USD"}}`, string(b)) r := rand.Int63n(101) @@ -882,13 +879,13 @@ func integration_MercuryV3(t *testing.T) { res.WriteHeader(http.StatusOK) val := decimal.NewFromBigInt(p, 0).Div(decimal.NewFromInt(multiplier)).Add(decimal.NewFromInt(int64(i)).Div(decimal.NewFromInt(100))).String() resp := fmt.Sprintf(`{"result": %s}`, val) - _, err = res.Write([]byte(resp)) - require.NoError(t, err) + _, herr = res.Write([]byte(resp)) + require.NoError(t, herr) } else { res.WriteHeader(http.StatusInternalServerError) resp := `{"error": "pError test error"}` - _, err = res.Write([]byte(resp)) - require.NoError(t, err) + _, herr = res.Write([]byte(resp)) + require.NoError(t, herr) } })) t.Cleanup(bridge.Close) @@ -963,7 +960,7 @@ func integration_MercuryV3(t *testing.T) { } for _, feed := range feeds { - _, err = verifier.SetConfig( + _, ferr := verifier.SetConfig( steve, feed.id, signerAddresses, @@ -974,7 +971,7 @@ func integration_MercuryV3(t *testing.T) { offchainConfig, nil, ) - require.NoError(t, err) + require.NoError(t, ferr) backend.Commit() }