diff --git a/core/chains/evm/logpoller/disabled.go b/core/chains/evm/logpoller/disabled.go index 05d591042f..9bc04ff0ed 100644 --- a/core/chains/evm/logpoller/disabled.go +++ b/core/chains/evm/logpoller/disabled.go @@ -21,6 +21,10 @@ func (disabled) Name() string { return "disabledLogPoller" } func (disabled) Start(ctx context.Context) error { return ErrDisabled } +func (disabled) Healthy() error { + return ErrDisabled +} + func (disabled) Close() error { return ErrDisabled } func (disabled) Ready() error { return ErrDisabled } diff --git a/core/chains/evm/logpoller/log_poller.go b/core/chains/evm/logpoller/log_poller.go index bf2e9b234a..922762467e 100644 --- a/core/chains/evm/logpoller/log_poller.go +++ b/core/chains/evm/logpoller/log_poller.go @@ -35,6 +35,7 @@ import ( //go:generate mockery --quiet --name LogPoller --output ./mocks/ --case=underscore --structname LogPoller --filename log_poller.go type LogPoller interface { services.Service + Healthy() error Replay(ctx context.Context, fromBlock int64) error ReplayAsync(fromBlock int64) RegisterFilter(filter Filter, qopts ...pg.QOpt) error @@ -213,7 +214,7 @@ func (filter *Filter) Contains(other *Filter) bool { return true } -func (lp *logPoller) Ready() error { +func (lp *logPoller) Healthy() error { if lp.finalityViolated.Load() { return ErrFinalityViolated } diff --git a/core/chains/evm/logpoller/log_poller_test.go b/core/chains/evm/logpoller/log_poller_test.go index ed8c938f9c..4fec4b4fa0 100644 --- a/core/chains/evm/logpoller/log_poller_test.go +++ b/core/chains/evm/logpoller/log_poller_test.go @@ -1025,7 +1025,7 @@ func TestLogPoller_ReorgDeeperThanFinality(t *testing.T) { // Polling should get us the L1 log. firstPoll := th.PollAndSaveLogs(testutils.Context(t), 1) assert.Equal(t, int64(5), firstPoll) - assert.NoError(t, th.LogPoller.Ready()) + assert.NoError(t, th.LogPoller.Healthy()) // Fork deeper than finality depth // Chain gen <- 1 <- 2 <- 3 (finalized) <- 4 (L1_1) @@ -1049,7 +1049,7 @@ func TestLogPoller_ReorgDeeperThanFinality(t *testing.T) { secondPoll := th.PollAndSaveLogs(testutils.Context(t), firstPoll) assert.Equal(t, firstPoll, secondPoll) - assert.Equal(t, logpoller.ErrFinalityViolated, th.LogPoller.Ready()) + assert.Equal(t, logpoller.ErrFinalityViolated, th.LogPoller.Healthy()) // Manually remove latest block from the log poller to bring it back to life // LogPoller should be healthy again after first poll @@ -1059,7 +1059,7 @@ func TestLogPoller_ReorgDeeperThanFinality(t *testing.T) { // Poll from latest recoveryPoll := th.PollAndSaveLogs(testutils.Context(t), 1) assert.Equal(t, int64(10), recoveryPoll) - assert.NoError(t, th.LogPoller.Ready()) + assert.NoError(t, th.LogPoller.Healthy()) }) } } @@ -1107,7 +1107,7 @@ func TestLogPoller_PollAndSaveLogsDeepReorg(t *testing.T) { // Polling should get us the L1 log. newStart := th.PollAndSaveLogs(testutils.Context(t), 1) assert.Equal(t, int64(3), newStart) - assert.NoError(t, th.LogPoller.Ready()) + assert.NoError(t, th.LogPoller.Healthy()) // Check that L1_1 has a proper data payload lgs, err := th.ORM.SelectLogsByBlockRange(2, 2) require.NoError(t, err) @@ -1133,7 +1133,7 @@ func TestLogPoller_PollAndSaveLogsDeepReorg(t *testing.T) { newStart = th.PollAndSaveLogs(testutils.Context(t), newStart) assert.Equal(t, int64(10), newStart) - assert.NoError(t, th.LogPoller.Ready()) + assert.NoError(t, th.LogPoller.Healthy()) // Expect L1_2 to be properly updated lgs, err = th.ORM.SelectLogsByBlockRange(2, 2) diff --git a/core/chains/evm/logpoller/mocks/log_poller.go b/core/chains/evm/logpoller/mocks/log_poller.go index 65d808b98d..453eeac272 100644 --- a/core/chains/evm/logpoller/mocks/log_poller.go +++ b/core/chains/evm/logpoller/mocks/log_poller.go @@ -114,6 +114,24 @@ func (_m *LogPoller) HealthReport() map[string]error { return r0 } +// Healthy provides a mock function with given fields: +func (_m *LogPoller) Healthy() error { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Healthy") + } + + var r0 error + if rf, ok := ret.Get(0).(func() error); ok { + r0 = rf() + } else { + r0 = ret.Error(0) + } + + return r0 +} + // IndexedLogs provides a mock function with given fields: eventSig, address, topicIndex, topicValues, confs, qopts func (_m *LogPoller) IndexedLogs(eventSig common.Hash, address common.Address, topicIndex int, topicValues []common.Hash, confs logpoller.Confirmations, qopts ...pg.QOpt) ([]logpoller.Log, error) { _va := make([]interface{}, len(qopts))