From 068b3fe3cc075b5958f85e37d99534e401bedce6 Mon Sep 17 00:00:00 2001 From: Makram Date: Tue, 30 Jul 2024 16:17:30 +0200 Subject: [PATCH] core/services/ocr2/plugins/ccip: fix CLO test (#1230) ## Motivation We were getting this log in the CLO integration test: ``` panic: Log in goroutine after Test_CLOSpecApprovalFlow_dynamicPriceGetter has completed: 2024-07-30T12:04:28.447Z ERROR Feeds wsrpc@v0.7.3/client.go:512 failed to connect to server at http://localhost:8080, got: [wsrpc] error while dialing dial tcp: lookup http on 127.0.0.53:53: server misbehaving {"version": "2.14.0-ccip1.4.13@dadff37"} ``` This appears to be due to the wsrpc client trying to connect to the CLO server when it doesn't actually exist. We set the mocked out connection manager previously, but it happened after the RegisterManager call, when it should be before. ## Solution Set the connections manager of the feeds service to the mock connection manager prior to registering the manager, since registering triggers a connect loop which uses wsrpc and has reconnection logic. --- .../ocr2/plugins/ccip/testhelpers/integration/chainlink.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/core/services/ocr2/plugins/ccip/testhelpers/integration/chainlink.go b/core/services/ocr2/plugins/ccip/testhelpers/integration/chainlink.go index 6546d44d10..ad42078248 100644 --- a/core/services/ocr2/plugins/ccip/testhelpers/integration/chainlink.go +++ b/core/services/ocr2/plugins/ccip/testhelpers/integration/chainlink.go @@ -639,14 +639,15 @@ func (c *CCIPIntegrationTestHarness) SetupFeedsManager(t *testing.T) { PublicKey: *pkey, } - _, err = f.RegisterManager(testutils.Context(t), m) - require.NoError(t, err) - connManager := feedsMocks.NewConnectionsManager(t) + connManager.On("Connect", mock.Anything).Maybe() connManager.On("GetClient", mock.Anything).Maybe().Return(NoopFeedsClient{}, nil) connManager.On("Close").Maybe().Return() connManager.On("IsConnected", mock.Anything).Maybe().Return(true) f.Unsafe_SetConnectionsManager(connManager) + + _, err = f.RegisterManager(testutils.Context(t), m) + require.NoError(t, err) } }