From 82ed297d4aed41024a2e10f7b8cbf086d44180d2 Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 30 Nov 2023 12:22:14 -0500 Subject: [PATCH] Increase blocks number for mercury v1 to 10 (#11410) * Increase blocks number for mercury v1 to 10 * Fix test --- core/scripts/go.mod | 2 +- core/scripts/go.sum | 4 +- .../relay/evm/mercury/v1/data_source_test.go | 42 ++++++------------- go.mod | 2 +- go.sum | 4 +- integration-tests/go.mod | 2 +- integration-tests/go.sum | 4 +- 7 files changed, 21 insertions(+), 39 deletions(-) diff --git a/core/scripts/go.mod b/core/scripts/go.mod index 1eb186931f8..c1ed59097cc 100644 --- a/core/scripts/go.mod +++ b/core/scripts/go.mod @@ -304,7 +304,7 @@ require ( github.com/shirou/gopsutil/v3 v3.23.10 // indirect github.com/sirupsen/logrus v1.9.3 // indirect github.com/smartcontractkit/caigo v0.0.0-20230621050857-b29a4ca8c704 // indirect - github.com/smartcontractkit/chainlink-common v0.1.7-0.20231127213516-5b67a57f9248 // indirect + github.com/smartcontractkit/chainlink-common v0.1.7-0.20231129142348-7087174fecde // indirect github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20231117191236-12eab01a4542 // indirect github.com/smartcontractkit/chainlink-feeds v0.0.0-20231127231053-2232d3a6766d // indirect github.com/smartcontractkit/chainlink-solana v1.0.3-0.20231129183458-faee879168b3 // indirect diff --git a/core/scripts/go.sum b/core/scripts/go.sum index 2a77f2066db..de86a457218 100644 --- a/core/scripts/go.sum +++ b/core/scripts/go.sum @@ -1504,8 +1504,8 @@ github.com/smartcontractkit/caigo v0.0.0-20230621050857-b29a4ca8c704 h1:T3lFWumv github.com/smartcontractkit/caigo v0.0.0-20230621050857-b29a4ca8c704/go.mod h1:2QuJdEouTWjh5BDy5o/vgGXQtR4Gz8yH1IYB5eT7u4M= github.com/smartcontractkit/chainlink-automation v1.0.1 h1:vVjBFq2Zsz21kPy1Pb0wpjF9zrbJX+zjXphDeeR4XZk= github.com/smartcontractkit/chainlink-automation v1.0.1/go.mod h1:INSchkV3ntyDdlZKGWA030MPDpp6pbeuiRkRKYFCm2k= -github.com/smartcontractkit/chainlink-common v0.1.7-0.20231127213516-5b67a57f9248 h1:HJCPvJ+ZjU9TSX4YD5rxBJqGAvqhDfzoJgI3WmfeWeI= -github.com/smartcontractkit/chainlink-common v0.1.7-0.20231127213516-5b67a57f9248/go.mod h1:Hrru9i7n+WEYyW2aIt3/YGPhxLX+HEGWnhk3yVXeDF8= +github.com/smartcontractkit/chainlink-common v0.1.7-0.20231129142348-7087174fecde h1:yulX+cnJbiS/iACjOdJfFtD5bD9M6TnXy7Og/PBafew= +github.com/smartcontractkit/chainlink-common v0.1.7-0.20231129142348-7087174fecde/go.mod h1:Hrru9i7n+WEYyW2aIt3/YGPhxLX+HEGWnhk3yVXeDF8= github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20231117191236-12eab01a4542 h1:oewYJtdRkJKUHCNDCj5C2LQe6Oq6qy975g931nfG0cc= github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20231117191236-12eab01a4542/go.mod h1:EpvRoycRD+kniYlz+pCpRT5e+fmPm0mSD/vmND+0oMg= github.com/smartcontractkit/chainlink-feeds v0.0.0-20231127231053-2232d3a6766d h1:w4MsbOtNk6nD/mcXLstHWk9hB6g7QLtcAfhPjhwvOaQ= diff --git a/core/services/relay/evm/mercury/v1/data_source_test.go b/core/services/relay/evm/mercury/v1/data_source_test.go index 6eb9f430c60..45a99f29196 100644 --- a/core/services/relay/evm/mercury/v1/data_source_test.go +++ b/core/services/relay/evm/mercury/v1/data_source_test.go @@ -356,49 +356,31 @@ func TestMercury_Observe(t *testing.T) { ht2.AssertExpectations(t) }) t.Run("when chain is long enough", func(t *testing.T) { - h1 := &evmtypes.Head{ - Number: 1, - } - h2 := &evmtypes.Head{ - Number: 2, - Parent: h1, - } - h3 := &evmtypes.Head{ - Number: 3, - Parent: h2, - } - h4 := &evmtypes.Head{ - Number: 4, - Parent: h3, - } - h5 := &evmtypes.Head{ - Number: 5, - Parent: h4, - } - h6 := &evmtypes.Head{ - Number: 6, - Parent: h5, + heads := make([]*evmtypes.Head, nBlocksObservation+5) + for i := range heads { + heads[i] = &evmtypes.Head{Number: int64(i)} + if i > 0 { + heads[i].Parent = heads[i-1] + } } ht2 := commonmocks.NewHeadTracker[*evmtypes.Head, common.Hash](t) - ht2.On("LatestChain").Return(h6) + ht2.On("LatestChain").Return(heads[len(heads)-1]) ds.chainReader = evm.NewChainReader(ht2) obs, err := ds.Observe(ctx, repts, true) assert.NoError(t, err) - assert.Len(t, obs.LatestBlocks, 5) - assert.Equal(t, 6, int(obs.LatestBlocks[0].Num)) - assert.Equal(t, 5, int(obs.LatestBlocks[1].Num)) - assert.Equal(t, 4, int(obs.LatestBlocks[2].Num)) - assert.Equal(t, 3, int(obs.LatestBlocks[3].Num)) - assert.Equal(t, 2, int(obs.LatestBlocks[4].Num)) + assert.Len(t, obs.LatestBlocks, nBlocksObservation) + highestBlockNum := heads[len(heads)-1].Number + for i := range obs.LatestBlocks { + assert.Equal(t, int(highestBlockNum)-i, int(obs.LatestBlocks[i].Num)) + } ht2.AssertExpectations(t) }) t.Run("when chain reader returns an error", func(t *testing.T) { - ds.chainReader = &mockChainReader{ err: io.EOF, obs: nil, diff --git a/go.mod b/go.mod index c105c1c6000..688f5810529 100644 --- a/go.mod +++ b/go.mod @@ -66,7 +66,7 @@ require ( github.com/shopspring/decimal v1.3.1 github.com/smartcontractkit/caigo v0.0.0-20230621050857-b29a4ca8c704 github.com/smartcontractkit/chainlink-automation v1.0.1 - github.com/smartcontractkit/chainlink-common v0.1.7-0.20231127213516-5b67a57f9248 + github.com/smartcontractkit/chainlink-common v0.1.7-0.20231129142348-7087174fecde github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20231117191236-12eab01a4542 github.com/smartcontractkit/chainlink-feeds v0.0.0-20231127231053-2232d3a6766d github.com/smartcontractkit/chainlink-solana v1.0.3-0.20231129183458-faee879168b3 diff --git a/go.sum b/go.sum index 18d78d4815e..d522aabb08a 100644 --- a/go.sum +++ b/go.sum @@ -1507,8 +1507,8 @@ github.com/smartcontractkit/caigo v0.0.0-20230621050857-b29a4ca8c704 h1:T3lFWumv github.com/smartcontractkit/caigo v0.0.0-20230621050857-b29a4ca8c704/go.mod h1:2QuJdEouTWjh5BDy5o/vgGXQtR4Gz8yH1IYB5eT7u4M= github.com/smartcontractkit/chainlink-automation v1.0.1 h1:vVjBFq2Zsz21kPy1Pb0wpjF9zrbJX+zjXphDeeR4XZk= github.com/smartcontractkit/chainlink-automation v1.0.1/go.mod h1:INSchkV3ntyDdlZKGWA030MPDpp6pbeuiRkRKYFCm2k= -github.com/smartcontractkit/chainlink-common v0.1.7-0.20231127213516-5b67a57f9248 h1:HJCPvJ+ZjU9TSX4YD5rxBJqGAvqhDfzoJgI3WmfeWeI= -github.com/smartcontractkit/chainlink-common v0.1.7-0.20231127213516-5b67a57f9248/go.mod h1:Hrru9i7n+WEYyW2aIt3/YGPhxLX+HEGWnhk3yVXeDF8= +github.com/smartcontractkit/chainlink-common v0.1.7-0.20231129142348-7087174fecde h1:yulX+cnJbiS/iACjOdJfFtD5bD9M6TnXy7Og/PBafew= +github.com/smartcontractkit/chainlink-common v0.1.7-0.20231129142348-7087174fecde/go.mod h1:Hrru9i7n+WEYyW2aIt3/YGPhxLX+HEGWnhk3yVXeDF8= github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20231117191236-12eab01a4542 h1:oewYJtdRkJKUHCNDCj5C2LQe6Oq6qy975g931nfG0cc= github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20231117191236-12eab01a4542/go.mod h1:EpvRoycRD+kniYlz+pCpRT5e+fmPm0mSD/vmND+0oMg= github.com/smartcontractkit/chainlink-feeds v0.0.0-20231127231053-2232d3a6766d h1:w4MsbOtNk6nD/mcXLstHWk9hB6g7QLtcAfhPjhwvOaQ= diff --git a/integration-tests/go.mod b/integration-tests/go.mod index e83859f2f46..b03819e2066 100644 --- a/integration-tests/go.mod +++ b/integration-tests/go.mod @@ -24,7 +24,7 @@ require ( github.com/segmentio/ksuid v1.0.4 github.com/slack-go/slack v0.12.2 github.com/smartcontractkit/chainlink-automation v1.0.1 - github.com/smartcontractkit/chainlink-common v0.1.7-0.20231127213516-5b67a57f9248 + github.com/smartcontractkit/chainlink-common v0.1.7-0.20231129142348-7087174fecde github.com/smartcontractkit/chainlink-testing-framework v1.19.7 github.com/smartcontractkit/chainlink-vrf v0.0.0-20231120191722-fef03814f868 github.com/smartcontractkit/chainlink/v2 v2.0.0-00010101000000-000000000000 diff --git a/integration-tests/go.sum b/integration-tests/go.sum index 9a647daaffb..74fe9e4dc4d 100644 --- a/integration-tests/go.sum +++ b/integration-tests/go.sum @@ -2376,8 +2376,8 @@ github.com/smartcontractkit/caigo v0.0.0-20230621050857-b29a4ca8c704 h1:T3lFWumv github.com/smartcontractkit/caigo v0.0.0-20230621050857-b29a4ca8c704/go.mod h1:2QuJdEouTWjh5BDy5o/vgGXQtR4Gz8yH1IYB5eT7u4M= github.com/smartcontractkit/chainlink-automation v1.0.1 h1:vVjBFq2Zsz21kPy1Pb0wpjF9zrbJX+zjXphDeeR4XZk= github.com/smartcontractkit/chainlink-automation v1.0.1/go.mod h1:INSchkV3ntyDdlZKGWA030MPDpp6pbeuiRkRKYFCm2k= -github.com/smartcontractkit/chainlink-common v0.1.7-0.20231127213516-5b67a57f9248 h1:HJCPvJ+ZjU9TSX4YD5rxBJqGAvqhDfzoJgI3WmfeWeI= -github.com/smartcontractkit/chainlink-common v0.1.7-0.20231127213516-5b67a57f9248/go.mod h1:Hrru9i7n+WEYyW2aIt3/YGPhxLX+HEGWnhk3yVXeDF8= +github.com/smartcontractkit/chainlink-common v0.1.7-0.20231129142348-7087174fecde h1:yulX+cnJbiS/iACjOdJfFtD5bD9M6TnXy7Og/PBafew= +github.com/smartcontractkit/chainlink-common v0.1.7-0.20231129142348-7087174fecde/go.mod h1:Hrru9i7n+WEYyW2aIt3/YGPhxLX+HEGWnhk3yVXeDF8= github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20231117191236-12eab01a4542 h1:oewYJtdRkJKUHCNDCj5C2LQe6Oq6qy975g931nfG0cc= github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20231117191236-12eab01a4542/go.mod h1:EpvRoycRD+kniYlz+pCpRT5e+fmPm0mSD/vmND+0oMg= github.com/smartcontractkit/chainlink-feeds v0.0.0-20231127231053-2232d3a6766d h1:w4MsbOtNk6nD/mcXLstHWk9hB6g7QLtcAfhPjhwvOaQ=