From 677173e88a02ad6f2464da7d547d7a90516c41fd Mon Sep 17 00:00:00 2001 From: raghu0891 Date: Tue, 26 Nov 2024 07:00:29 +0100 Subject: [PATCH] Base 1 commit --- .tool-versions | 2 +- Automation_Grants.md | 2 +- LICENSE | 2 - docs/PROTOCOL_v21.md | 2 +- go.mod | 7 ++- internal/util/closer.go | 34 -------------- internal/util/closer_test.go | 29 ------------ pkg/v2/coordinator/coordinator.go | 17 ++++--- pkg/v2/coordinator/mocks/encoder.generated.go | 23 +++++++--- .../mocks/log_provider.generated.go | 19 +++++--- pkg/v2/mocks/logger.generated.go | 11 +++-- pkg/v3/LICENSE | 2 - pkg/v3/coordinator/coordinator.go | 45 +++++++++++-------- pkg/v3/coordinator/coordinator_test.go | 13 ------ pkg/v3/flows/conditional_test.go | 23 ++++------ pkg/v3/tickers/time.go | 34 ++++++++------ pkg/v3/tickers/time_test.go | 4 +- .../types/mocks/block_subscriber.generated.go | 27 ++++++++--- .../conditionalupkeepprovider.generated.go | 15 ++++--- pkg/v3/types/mocks/coordinator.generated.go | 31 ++++++++++--- pkg/v3/types/mocks/encoder.generated.go | 19 +++++--- .../types/mocks/logeventprovider.generated.go | 23 +++++++--- pkg/v3/types/mocks/metadatastore.generated.go | 27 ++++++++--- .../types/mocks/payloadbuilder.generated.go | 15 ++++--- pkg/v3/types/mocks/ratio.generated.go | 15 ++++--- .../mocks/recoverableprovider.generated.go | 15 ++++--- pkg/v3/types/mocks/result_store.generated.go | 15 ++++--- pkg/v3/types/mocks/runnable.generated.go | 15 ++++--- .../transmit_event_provider.generated.go | 15 ++++--- .../mocks/upkeep_state_updater.generated.go | 15 ++++--- sonar-project.properties | 2 +- 31 files changed, 282 insertions(+), 236 deletions(-) delete mode 100644 internal/util/closer.go delete mode 100644 internal/util/closer_test.go diff --git a/.tool-versions b/.tool-versions index 5c14e0c..7d9a0e5 100644 --- a/.tool-versions +++ b/.tool-versions @@ -1,2 +1,2 @@ golang 1.20 -mockery 2.12.1 +mockery 2.43.2 diff --git a/Automation_Grants.md b/Automation_Grants.md index 5aa57d5..c28f70c 100644 --- a/Automation_Grants.md +++ b/Automation_Grants.md @@ -2,4 +2,4 @@ Automation-License-grants Additional Use Grant(s): -You may make use of Plugin Automation (which is available subject to the license here the “Licensed Work”) solely for purposes listed below: +You may make use of plugin Automation (which is available subject to the license here the “Licensed Work”) solely for purposes listed below: diff --git a/LICENSE b/LICENSE index c611f9e..890c005 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,4 @@ -Copyright (c) 2023 SmartContract Plugin Limited SEZC - Portions of this software are licensed as follows: *All content residing under (1) https://github.com/goplugin/pluginv3.0/tree/develop/contracts/src/v0.8/automation/2_1; (2) https://github.com/goplugin/plugin-automation/tree/main/pkg/v3 are licensed under “Business Source License 1.1” with a Change Date of September 12, 2027 and Change License to “MIT License” diff --git a/docs/PROTOCOL_v21.md b/docs/PROTOCOL_v21.md index c20127b..e4936da 100644 --- a/docs/PROTOCOL_v21.md +++ b/docs/PROTOCOL_v21.md @@ -37,7 +37,7 @@ This document aims to give a high level overview of the protocol for Automation ## Abstract -Plugin Automation is a decentralized execution engine for automating smart contracts, +plugin Automation is a decentralized execution engine for automating smart contracts, with a generic and extensible triggering mechanism. The protocol is implemented using the OCR3 interface, which is a decentralized consensus framework for off-chain computation. diff --git a/go.mod b/go.mod index 5b3a561..e26d8ae 100644 --- a/go.mod +++ b/go.mod @@ -14,9 +14,10 @@ require ( github.com/pkg/errors v0.9.1 github.com/prometheus/client_golang v1.17.0 github.com/shopspring/decimal v1.4.0 - github.com/goplugin/plugin-common v0.0.1 - github.com/goplugin/plugin-libocr v0.1.1//changes for plugin update + //github.com/goplugin/plugin-common v0.0.1 //github.com/goplugin/plugin-libocr v0.0.0-20241007185508-adbe57025f12 + github.com/goplugin/plugin-common v0.0.1 + github.com/goplugin/plugin-libocr v0.1.1 github.com/spf13/pflag v1.0.5 github.com/stretchr/testify v1.9.0 golang.org/x/crypto v0.27.0 @@ -73,3 +74,5 @@ require ( gopkg.in/yaml.v3 v3.0.1 // indirect rsc.io/tmplfunc v0.0.3 // indirect ) + +retract [v1.0.0-0, v1.0.5] // reverting to v0 diff --git a/internal/util/closer.go b/internal/util/closer.go deleted file mode 100644 index 8667417..0000000 --- a/internal/util/closer.go +++ /dev/null @@ -1,34 +0,0 @@ -package util - -import ( - "context" - "sync" -) - -type Closer struct { - cancel context.CancelFunc - lock sync.Mutex -} - -func (c *Closer) Store(cancel context.CancelFunc) bool { - c.lock.Lock() - defer c.lock.Unlock() - - if c.cancel != nil { - return false - } - c.cancel = cancel - return true -} - -func (c *Closer) Close() bool { - c.lock.Lock() - defer c.lock.Unlock() - - if c.cancel != nil { - c.cancel() - c.cancel = nil - return true - } - return false -} diff --git a/internal/util/closer_test.go b/internal/util/closer_test.go deleted file mode 100644 index 54cba4f..0000000 --- a/internal/util/closer_test.go +++ /dev/null @@ -1,29 +0,0 @@ -package util - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestCloser(t *testing.T) { - called := false - cancelFn := func() { - called = true - } - closer := &Closer{} - - ok := closer.Close() - assert.False(t, ok) - - ok = closer.Store(cancelFn) - assert.True(t, ok) - - ok = closer.Store(cancelFn) - assert.False(t, ok) - - ok = closer.Close() - assert.True(t, ok) - - assert.True(t, called) -} diff --git a/pkg/v2/coordinator/coordinator.go b/pkg/v2/coordinator/coordinator.go index 5e0652d..37ac183 100644 --- a/pkg/v2/coordinator/coordinator.go +++ b/pkg/v2/coordinator/coordinator.go @@ -32,6 +32,7 @@ import ( "github.com/goplugin/plugin-automation/pkg/util" ocr2keepers "github.com/goplugin/plugin-automation/pkg/v2" + "github.com/goplugin/plugin-common/pkg/services" ) var ( @@ -74,7 +75,7 @@ type reportCoordinator struct { // run state data running atomic.Bool - chStop chan struct{} + chStop services.StopChan } // NewReportCoordinator provides a new report coordinator. The coordinator @@ -228,7 +229,7 @@ func (rc *reportCoordinator) checkLogs(ctx context.Context) error { } } - staleReportLogs, err = rc.logs.StaleReportLogs(context.Background()) + staleReportLogs, err = rc.logs.StaleReportLogs(ctx) // It can happen that in between the time the report is generated and it gets // confirmed on chain something changes and it becomes stale. Current scenarios are: // - Another report for the upkeep is transmitted making this report stale @@ -386,13 +387,20 @@ func (rc *reportCoordinator) Close() error { func (rc *reportCoordinator) run() { cadence := time.Second timer := time.NewTimer(cadence) + defer timer.Stop() + + ctx, cancel := rc.chStop.NewCtx() + defer cancel() for { select { case <-timer.C: startTime := time.Now() - if err := rc.checkLogs(context.Background()); err != nil { + if err := rc.checkLogs(ctx); err != nil { + if ctx.Err() != nil { + return + } rc.logger.Printf("failed to check perform and stale report logs: %s", err) } @@ -407,8 +415,7 @@ func (rc *reportCoordinator) run() { // wait the difference between the cadence and the time taken timer.Reset(cadence - diff) } - case <-rc.chStop: - timer.Stop() + case <-ctx.Done(): return } } diff --git a/pkg/v2/coordinator/mocks/encoder.generated.go b/pkg/v2/coordinator/mocks/encoder.generated.go index 4d71728..eba999f 100644 --- a/pkg/v2/coordinator/mocks/encoder.generated.go +++ b/pkg/v2/coordinator/mocks/encoder.generated.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.28.1. DO NOT EDIT. +// Code generated by mockery v2.43.2. DO NOT EDIT. package mocks @@ -16,6 +16,10 @@ type Encoder struct { func (_m *Encoder) After(_a0 ocr2keepers.BlockKey, _a1 ocr2keepers.BlockKey) (bool, error) { ret := _m.Called(_a0, _a1) + if len(ret) == 0 { + panic("no return value specified for After") + } + var r0 bool var r1 error if rf, ok := ret.Get(0).(func(ocr2keepers.BlockKey, ocr2keepers.BlockKey) (bool, error)); ok { @@ -40,6 +44,10 @@ func (_m *Encoder) After(_a0 ocr2keepers.BlockKey, _a1 ocr2keepers.BlockKey) (bo func (_m *Encoder) Increment(_a0 ocr2keepers.BlockKey) (ocr2keepers.BlockKey, error) { ret := _m.Called(_a0) + if len(ret) == 0 { + panic("no return value specified for Increment") + } + var r0 ocr2keepers.BlockKey var r1 error if rf, ok := ret.Get(0).(func(ocr2keepers.BlockKey) (ocr2keepers.BlockKey, error)); ok { @@ -64,6 +72,10 @@ func (_m *Encoder) Increment(_a0 ocr2keepers.BlockKey) (ocr2keepers.BlockKey, er func (_m *Encoder) SplitUpkeepKey(_a0 ocr2keepers.UpkeepKey) (ocr2keepers.BlockKey, ocr2keepers.UpkeepIdentifier, error) { ret := _m.Called(_a0) + if len(ret) == 0 { + panic("no return value specified for SplitUpkeepKey") + } + var r0 ocr2keepers.BlockKey var r1 ocr2keepers.UpkeepIdentifier var r2 error @@ -93,13 +105,12 @@ func (_m *Encoder) SplitUpkeepKey(_a0 ocr2keepers.UpkeepKey) (ocr2keepers.BlockK return r0, r1, r2 } -type mockConstructorTestingTNewEncoder interface { +// NewEncoder creates a new instance of Encoder. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewEncoder(t interface { mock.TestingT Cleanup(func()) -} - -// NewEncoder creates a new instance of Encoder. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -func NewEncoder(t mockConstructorTestingTNewEncoder) *Encoder { +}) *Encoder { mock := &Encoder{} mock.Mock.Test(t) diff --git a/pkg/v2/coordinator/mocks/log_provider.generated.go b/pkg/v2/coordinator/mocks/log_provider.generated.go index f484c5c..885c043 100644 --- a/pkg/v2/coordinator/mocks/log_provider.generated.go +++ b/pkg/v2/coordinator/mocks/log_provider.generated.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.28.1. DO NOT EDIT. +// Code generated by mockery v2.43.2. DO NOT EDIT. package mocks @@ -19,6 +19,10 @@ type LogProvider struct { func (_m *LogProvider) PerformLogs(_a0 context.Context) ([]ocr2keepers.PerformLog, error) { ret := _m.Called(_a0) + if len(ret) == 0 { + panic("no return value specified for PerformLogs") + } + var r0 []ocr2keepers.PerformLog var r1 error if rf, ok := ret.Get(0).(func(context.Context) ([]ocr2keepers.PerformLog, error)); ok { @@ -45,6 +49,10 @@ func (_m *LogProvider) PerformLogs(_a0 context.Context) ([]ocr2keepers.PerformLo func (_m *LogProvider) StaleReportLogs(_a0 context.Context) ([]ocr2keepers.StaleReportLog, error) { ret := _m.Called(_a0) + if len(ret) == 0 { + panic("no return value specified for StaleReportLogs") + } + var r0 []ocr2keepers.StaleReportLog var r1 error if rf, ok := ret.Get(0).(func(context.Context) ([]ocr2keepers.StaleReportLog, error)); ok { @@ -67,13 +75,12 @@ func (_m *LogProvider) StaleReportLogs(_a0 context.Context) ([]ocr2keepers.Stale return r0, r1 } -type mockConstructorTestingTNewLogProvider interface { +// NewLogProvider creates a new instance of LogProvider. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewLogProvider(t interface { mock.TestingT Cleanup(func()) -} - -// NewLogProvider creates a new instance of LogProvider. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -func NewLogProvider(t mockConstructorTestingTNewLogProvider) *LogProvider { +}) *LogProvider { mock := &LogProvider{} mock.Mock.Test(t) diff --git a/pkg/v2/mocks/logger.generated.go b/pkg/v2/mocks/logger.generated.go index bbc98fd..583cf0d 100644 --- a/pkg/v2/mocks/logger.generated.go +++ b/pkg/v2/mocks/logger.generated.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.28.1. DO NOT EDIT. +// Code generated by mockery v2.43.2. DO NOT EDIT. package mocks @@ -42,13 +42,12 @@ func (_m *MockLogger) Warn(msg string, fields commontypes.LogFields) { _m.Called(msg, fields) } -type mockConstructorTestingTNewMockLogger interface { +// NewMockLogger creates a new instance of MockLogger. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewMockLogger(t interface { mock.TestingT Cleanup(func()) -} - -// NewMockLogger creates a new instance of MockLogger. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -func NewMockLogger(t mockConstructorTestingTNewMockLogger) *MockLogger { +}) *MockLogger { mock := &MockLogger{} mock.Mock.Test(t) diff --git a/pkg/v3/LICENSE b/pkg/v3/LICENSE index 4128d13..df78372 100644 --- a/pkg/v3/LICENSE +++ b/pkg/v3/LICENSE @@ -7,10 +7,8 @@ License text copyright (c) 2017 MariaDB Corporation Ab, All Rights Reserved. Parameters -Licensor: SmartContract Plugin Limited SEZC Licensed Work: Automation v2.1 -The Licensed Work is (c) 2023 SmartContract Plugin Limited SEZC Additional Use Grant: Any uses listed and defined at https://github.com/goplugin/plugin-automation/tree/main/pkg/v3/Automation_v2.1_Grants.md diff --git a/pkg/v3/coordinator/coordinator.go b/pkg/v3/coordinator/coordinator.go index bec4f38..fb90e52 100644 --- a/pkg/v3/coordinator/coordinator.go +++ b/pkg/v3/coordinator/coordinator.go @@ -7,9 +7,9 @@ import ( "log" "time" + "github.com/goplugin/plugin-common/pkg/services" common "github.com/goplugin/plugin-common/pkg/types/automation" - internalutil "github.com/goplugin/plugin-automation/internal/util" "github.com/goplugin/plugin-automation/pkg/util" "github.com/goplugin/plugin-automation/pkg/v3/config" "github.com/goplugin/plugin-automation/pkg/v3/types" @@ -21,7 +21,9 @@ const ( ) type coordinator struct { - closer internalutil.Closer + services.StateMachine + stopCh services.StopChan + done chan struct{} logger *log.Logger eventsProvider types.TransmitEventProvider @@ -46,6 +48,8 @@ type record struct { func NewCoordinator(transmitEventProvider types.TransmitEventProvider, upkeepTypeGetter types.UpkeepTypeGetter, conf config.OffchainConfig, logger *log.Logger) *coordinator { performLockoutWindow := time.Duration(conf.PerformLockoutWindow) * time.Millisecond return &coordinator{ + stopCh: make(chan struct{}), + done: make(chan struct{}), logger: logger, eventsProvider: transmitEventProvider, upkeepTypeGetter: upkeepTypeGetter, @@ -208,16 +212,24 @@ func (c *coordinator) checkEvents(ctx context.Context) error { return nil } -func (c *coordinator) run(ctx context.Context) { +func (c *coordinator) run() { + defer close(c.done) + timer := time.NewTimer(cadence) defer timer.Stop() + ctx, cancel := c.stopCh.NewCtx() + defer cancel() + for { select { case <-timer.C: startTime := time.Now() - if err := c.checkEvents(context.Background()); err != nil { + if err := c.checkEvents(ctx); err != nil { + if ctx.Err() != nil { + return + } c.logger.Printf("failed to check for transmit events: %s", err) } @@ -239,32 +251,29 @@ func (c *coordinator) run(ctx context.Context) { } // Start starts all subprocesses -func (c *coordinator) Start(pctx context.Context) error { - ctx, cancel := context.WithCancel(pctx) - defer cancel() - - if !c.closer.Store(cancel) { - return fmt.Errorf("process already running") +func (c *coordinator) Start(_ context.Context) error { + if err := c.StateMachine.StartOnce("Coordinator", func() error { return nil }); err != nil { + return err } go c.cache.Start(defaultCacheClean) go c.visited.Start(defaultCacheClean) - c.run(ctx) - + c.run() return nil } // Close terminates all subprocesses func (c *coordinator) Close() error { - if !c.closer.Close() { - return fmt.Errorf("process not running") - } + return c.StateMachine.StopOnce("Coordinator", func() error { + close(c.stopCh) + <-c.done - c.cache.Stop() - c.visited.Stop() + c.cache.Stop() + c.visited.Stop() - return nil + return nil + }) } func (c *coordinator) visitedID(e common.TransmitEvent) string { diff --git a/pkg/v3/coordinator/coordinator_test.go b/pkg/v3/coordinator/coordinator_test.go index 59ae8c6..694e7a2 100644 --- a/pkg/v3/coordinator/coordinator_test.go +++ b/pkg/v3/coordinator/coordinator_test.go @@ -145,19 +145,6 @@ func TestNewCoordinator(t *testing.T) { wg.Wait() assert.True(t, strings.Contains(memLog.String(), "check database indexes and other performance improvements")) }) - - t.Run("starting an already started coordinator returns an error", func(t *testing.T) { - c := NewCoordinator(nil, nil, config.OffchainConfig{PerformLockoutWindow: 3600 * 1000, MinConfirmations: 2}, nil) - c.closer.Store(context.CancelFunc(func() {})) - err := c.Start(context.Background()) - assert.Error(t, err) - }) - - t.Run("closing an already closed coordinator returns an error", func(t *testing.T) { - c := NewCoordinator(nil, nil, config.OffchainConfig{PerformLockoutWindow: 3600 * 1000, MinConfirmations: 2}, nil) - err := c.Close() - assert.Error(t, err) - }) } func TestNewCoordinator_checkEvents(t *testing.T) { diff --git a/pkg/v3/flows/conditional_test.go b/pkg/v3/flows/conditional_test.go index 78a5896..23ba521 100644 --- a/pkg/v3/flows/conditional_test.go +++ b/pkg/v3/flows/conditional_test.go @@ -125,11 +125,11 @@ func TestSamplingProposal(t *testing.T) { logger := log.New(io.Discard, "", log.LstdFlags) - runner := new(mocks.MockRunnable) - mStore := new(mocks.MockMetadataStore) - upkeepProvider := new(mocks.MockConditionalUpkeepProvider) - ratio := new(mocks.MockRatio) - coord := new(mocks.MockCoordinator) + runner := mocks.NewMockRunnable(t) + mStore := mocks.NewMockMetadataStore(t) + upkeepProvider := mocks.NewMockConditionalUpkeepProvider(t) + ratio := mocks.NewMockRatio(t) + coord := mocks.NewMockCoordinator(t) ratio.On("OfInt", mock.Anything).Return(0, nil).Times(1) ratio.On("OfInt", mock.Anything).Return(1, nil).Times(1) @@ -193,18 +193,11 @@ func TestSamplingProposal(t *testing.T) { ctx, cancel := context.WithTimeout(context.Background(), time.Second*5) defer cancel() - go func(svc service.Recoverable, ctx context.Context) { + go func(ctx context.Context) { defer wg.Done() assert.NoError(t, svc.Start(ctx)) - }(svc, ctx) - - assert.NoError(t, svc.Close(), "no error expected on shut down") + }(ctx) + t.Cleanup(func() { assert.NoError(t, svc.Close()) }) wg.Wait() - - mStore.AssertExpectations(t) - upkeepProvider.AssertExpectations(t) - coord.AssertExpectations(t) - runner.AssertExpectations(t) - // ratio.AssertExpectations(t) } diff --git a/pkg/v3/tickers/time.go b/pkg/v3/tickers/time.go index 3a9599c..c45ab98 100644 --- a/pkg/v3/tickers/time.go +++ b/pkg/v3/tickers/time.go @@ -2,11 +2,10 @@ package tickers import ( "context" - "fmt" "log" "time" - "github.com/goplugin/plugin-automation/internal/util" + "github.com/goplugin/plugin-common/pkg/services" ) type observer[T any] interface { @@ -16,12 +15,13 @@ type observer[T any] interface { type getterFunc[T any] func(context.Context, time.Time) (Tick[T], error) type timeTicker[T any] struct { - closer util.Closer - + services.StateMachine interval time.Duration observer observer[T] getterFn getterFunc[T] logger *log.Logger + done chan struct{} + stopCh services.StopChan } func NewTimeTicker[T any](interval time.Duration, observer observer[T], getterFn getterFunc[T], logger *log.Logger) *timeTicker[T] { @@ -30,6 +30,8 @@ func NewTimeTicker[T any](interval time.Duration, observer observer[T], getterFn observer: observer, getterFn: getterFn, logger: logger, + done: make(chan struct{}), + stopCh: make(chan struct{}), } return t @@ -38,13 +40,13 @@ func NewTimeTicker[T any](interval time.Duration, observer observer[T], getterFn // Start uses the provided context for each call to the getter function with the // configured interval as a timeout. This function blocks until Close is called // or the parent context is cancelled. -func (t *timeTicker[T]) Start(pctx context.Context) error { - ctx, cancel := context.WithCancel(pctx) - defer cancel() - - if !t.closer.Store(cancel) { - return fmt.Errorf("already running") +func (t *timeTicker[T]) Start(ctx context.Context) error { + if err := t.StartOnce("timeTicker", func() error { return nil }); err != nil { + return err } + defer close(t.done) + ctx, cancel := t.stopCh.Ctx(ctx) + defer cancel() t.logger.Printf("starting ticker service") defer t.logger.Printf("ticker service stopped") @@ -54,6 +56,8 @@ func (t *timeTicker[T]) Start(pctx context.Context) error { for { select { + case <-ctx.Done(): + return nil case tm := <-ticker.C: if t.getterFn == nil { continue @@ -61,6 +65,7 @@ func (t *timeTicker[T]) Start(pctx context.Context) error { tick, err := t.getterFn(ctx, tm) if err != nil { t.logger.Printf("error fetching tick: %s", err.Error()) + continue } // observer.Process can be a heavy call taking upto ObservationProcessLimit seconds // so it is run in a separate goroutine to not block further ticks @@ -70,13 +75,14 @@ func (t *timeTicker[T]) Start(pctx context.Context) error { l.Printf("error processing observer: %s", err.Error()) } }(ctx, tick, t.observer, t.logger) - case <-ctx.Done(): - return nil } } } func (t *timeTicker[T]) Close() error { - _ = t.closer.Close() - return nil + return t.StopOnce("timeTicker", func() error { + close(t.stopCh) + <-t.done + return nil + }) } diff --git a/pkg/v3/tickers/time_test.go b/pkg/v3/tickers/time_test.go index e8b4fcd..1efb7fd 100644 --- a/pkg/v3/tickers/time_test.go +++ b/pkg/v3/tickers/time_test.go @@ -131,7 +131,7 @@ func TestNewTimeTicker(t *testing.T) { } getFn := func(ctx context.Context, t time.Time) (Tick[[]int], error) { - return nil, errors.New("error fetching tick") + return nil, errors.New("test error") } ticker := NewTimeTicker[[]int](100*time.Millisecond, observr, getFn, log.New(msg, "", log.LstdFlags)) @@ -150,7 +150,7 @@ func TestNewTimeTicker(t *testing.T) { wg.Wait() - assert.Contains(t, msg.String(), "error processing observer: boom") + assert.Contains(t, msg.String(), "error fetching tick: test error") }) t.Run("creates a ticker with an observer that errors on processing", func(t *testing.T) { diff --git a/pkg/v3/types/mocks/block_subscriber.generated.go b/pkg/v3/types/mocks/block_subscriber.generated.go index 3135ffa..49aad4b 100644 --- a/pkg/v3/types/mocks/block_subscriber.generated.go +++ b/pkg/v3/types/mocks/block_subscriber.generated.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.28.1. DO NOT EDIT. +// Code generated by mockery v2.43.2. DO NOT EDIT. package mocks @@ -19,6 +19,10 @@ type MockBlockSubscriber struct { func (_m *MockBlockSubscriber) Close() error { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for Close") + } + var r0 error if rf, ok := ret.Get(0).(func() error); ok { r0 = rf() @@ -33,6 +37,10 @@ func (_m *MockBlockSubscriber) Close() error { func (_m *MockBlockSubscriber) Start(_a0 context.Context) error { ret := _m.Called(_a0) + if len(ret) == 0 { + panic("no return value specified for Start") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context) error); ok { r0 = rf(_a0) @@ -47,6 +55,10 @@ func (_m *MockBlockSubscriber) Start(_a0 context.Context) error { func (_m *MockBlockSubscriber) Subscribe() (int, chan automation.BlockHistory, error) { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for Subscribe") + } + var r0 int var r1 chan automation.BlockHistory var r2 error @@ -80,6 +92,10 @@ func (_m *MockBlockSubscriber) Subscribe() (int, chan automation.BlockHistory, e func (_m *MockBlockSubscriber) Unsubscribe(_a0 int) error { ret := _m.Called(_a0) + if len(ret) == 0 { + panic("no return value specified for Unsubscribe") + } + var r0 error if rf, ok := ret.Get(0).(func(int) error); ok { r0 = rf(_a0) @@ -90,13 +106,12 @@ func (_m *MockBlockSubscriber) Unsubscribe(_a0 int) error { return r0 } -type mockConstructorTestingTNewMockBlockSubscriber interface { +// NewMockBlockSubscriber creates a new instance of MockBlockSubscriber. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewMockBlockSubscriber(t interface { mock.TestingT Cleanup(func()) -} - -// NewMockBlockSubscriber creates a new instance of MockBlockSubscriber. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -func NewMockBlockSubscriber(t mockConstructorTestingTNewMockBlockSubscriber) *MockBlockSubscriber { +}) *MockBlockSubscriber { mock := &MockBlockSubscriber{} mock.Mock.Test(t) diff --git a/pkg/v3/types/mocks/conditionalupkeepprovider.generated.go b/pkg/v3/types/mocks/conditionalupkeepprovider.generated.go index 6ab3592..bfe1110 100644 --- a/pkg/v3/types/mocks/conditionalupkeepprovider.generated.go +++ b/pkg/v3/types/mocks/conditionalupkeepprovider.generated.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.28.1. DO NOT EDIT. +// Code generated by mockery v2.43.2. DO NOT EDIT. package mocks @@ -19,6 +19,10 @@ type MockConditionalUpkeepProvider struct { func (_m *MockConditionalUpkeepProvider) GetActiveUpkeeps(_a0 context.Context) ([]automation.UpkeepPayload, error) { ret := _m.Called(_a0) + if len(ret) == 0 { + panic("no return value specified for GetActiveUpkeeps") + } + var r0 []automation.UpkeepPayload var r1 error if rf, ok := ret.Get(0).(func(context.Context) ([]automation.UpkeepPayload, error)); ok { @@ -41,13 +45,12 @@ func (_m *MockConditionalUpkeepProvider) GetActiveUpkeeps(_a0 context.Context) ( return r0, r1 } -type mockConstructorTestingTNewMockConditionalUpkeepProvider interface { +// NewMockConditionalUpkeepProvider creates a new instance of MockConditionalUpkeepProvider. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewMockConditionalUpkeepProvider(t interface { mock.TestingT Cleanup(func()) -} - -// NewMockConditionalUpkeepProvider creates a new instance of MockConditionalUpkeepProvider. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -func NewMockConditionalUpkeepProvider(t mockConstructorTestingTNewMockConditionalUpkeepProvider) *MockConditionalUpkeepProvider { +}) *MockConditionalUpkeepProvider { mock := &MockConditionalUpkeepProvider{} mock.Mock.Test(t) diff --git a/pkg/v3/types/mocks/coordinator.generated.go b/pkg/v3/types/mocks/coordinator.generated.go index ce0eb3f..0c2ba34 100644 --- a/pkg/v3/types/mocks/coordinator.generated.go +++ b/pkg/v3/types/mocks/coordinator.generated.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.28.1. DO NOT EDIT. +// Code generated by mockery v2.43.2. DO NOT EDIT. package mocks @@ -19,6 +19,10 @@ type MockCoordinator struct { func (_m *MockCoordinator) Accept(_a0 automation.ReportedUpkeep) bool { ret := _m.Called(_a0) + if len(ret) == 0 { + panic("no return value specified for Accept") + } + var r0 bool if rf, ok := ret.Get(0).(func(automation.ReportedUpkeep) bool); ok { r0 = rf(_a0) @@ -33,6 +37,10 @@ func (_m *MockCoordinator) Accept(_a0 automation.ReportedUpkeep) bool { func (_m *MockCoordinator) FilterProposals(_a0 []automation.CoordinatedBlockProposal) ([]automation.CoordinatedBlockProposal, error) { ret := _m.Called(_a0) + if len(ret) == 0 { + panic("no return value specified for FilterProposals") + } + var r0 []automation.CoordinatedBlockProposal var r1 error if rf, ok := ret.Get(0).(func([]automation.CoordinatedBlockProposal) ([]automation.CoordinatedBlockProposal, error)); ok { @@ -59,6 +67,10 @@ func (_m *MockCoordinator) FilterProposals(_a0 []automation.CoordinatedBlockProp func (_m *MockCoordinator) FilterResults(_a0 []automation.CheckResult) ([]automation.CheckResult, error) { ret := _m.Called(_a0) + if len(ret) == 0 { + panic("no return value specified for FilterResults") + } + var r0 []automation.CheckResult var r1 error if rf, ok := ret.Get(0).(func([]automation.CheckResult) ([]automation.CheckResult, error)); ok { @@ -85,6 +97,10 @@ func (_m *MockCoordinator) FilterResults(_a0 []automation.CheckResult) ([]automa func (_m *MockCoordinator) PreProcess(_a0 context.Context, payloads []automation.UpkeepPayload) ([]automation.UpkeepPayload, error) { ret := _m.Called(_a0, payloads) + if len(ret) == 0 { + panic("no return value specified for PreProcess") + } + var r0 []automation.UpkeepPayload var r1 error if rf, ok := ret.Get(0).(func(context.Context, []automation.UpkeepPayload) ([]automation.UpkeepPayload, error)); ok { @@ -111,6 +127,10 @@ func (_m *MockCoordinator) PreProcess(_a0 context.Context, payloads []automation func (_m *MockCoordinator) ShouldTransmit(_a0 automation.ReportedUpkeep) bool { ret := _m.Called(_a0) + if len(ret) == 0 { + panic("no return value specified for ShouldTransmit") + } + var r0 bool if rf, ok := ret.Get(0).(func(automation.ReportedUpkeep) bool); ok { r0 = rf(_a0) @@ -121,13 +141,12 @@ func (_m *MockCoordinator) ShouldTransmit(_a0 automation.ReportedUpkeep) bool { return r0 } -type mockConstructorTestingTNewMockCoordinator interface { +// NewMockCoordinator creates a new instance of MockCoordinator. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewMockCoordinator(t interface { mock.TestingT Cleanup(func()) -} - -// NewMockCoordinator creates a new instance of MockCoordinator. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -func NewMockCoordinator(t mockConstructorTestingTNewMockCoordinator) *MockCoordinator { +}) *MockCoordinator { mock := &MockCoordinator{} mock.Mock.Test(t) diff --git a/pkg/v3/types/mocks/encoder.generated.go b/pkg/v3/types/mocks/encoder.generated.go index d4f1425..8e84e28 100644 --- a/pkg/v3/types/mocks/encoder.generated.go +++ b/pkg/v3/types/mocks/encoder.generated.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.28.1. DO NOT EDIT. +// Code generated by mockery v2.43.2. DO NOT EDIT. package mocks @@ -22,6 +22,10 @@ func (_m *MockEncoder) Encode(_a0 ...automation.CheckResult) ([]byte, error) { _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for Encode") + } + var r0 []byte var r1 error if rf, ok := ret.Get(0).(func(...automation.CheckResult) ([]byte, error)); ok { @@ -48,6 +52,10 @@ func (_m *MockEncoder) Encode(_a0 ...automation.CheckResult) ([]byte, error) { func (_m *MockEncoder) Extract(_a0 []byte) ([]automation.ReportedUpkeep, error) { ret := _m.Called(_a0) + if len(ret) == 0 { + panic("no return value specified for Extract") + } + var r0 []automation.ReportedUpkeep var r1 error if rf, ok := ret.Get(0).(func([]byte) ([]automation.ReportedUpkeep, error)); ok { @@ -70,13 +78,12 @@ func (_m *MockEncoder) Extract(_a0 []byte) ([]automation.ReportedUpkeep, error) return r0, r1 } -type mockConstructorTestingTNewMockEncoder interface { +// NewMockEncoder creates a new instance of MockEncoder. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewMockEncoder(t interface { mock.TestingT Cleanup(func()) -} - -// NewMockEncoder creates a new instance of MockEncoder. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -func NewMockEncoder(t mockConstructorTestingTNewMockEncoder) *MockEncoder { +}) *MockEncoder { mock := &MockEncoder{} mock.Mock.Test(t) diff --git a/pkg/v3/types/mocks/logeventprovider.generated.go b/pkg/v3/types/mocks/logeventprovider.generated.go index cfb3f00..68a48a9 100644 --- a/pkg/v3/types/mocks/logeventprovider.generated.go +++ b/pkg/v3/types/mocks/logeventprovider.generated.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.28.1. DO NOT EDIT. +// Code generated by mockery v2.43.2. DO NOT EDIT. package mocks @@ -19,6 +19,10 @@ type MockLogEventProvider struct { func (_m *MockLogEventProvider) Close() error { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for Close") + } + var r0 error if rf, ok := ret.Get(0).(func() error); ok { r0 = rf() @@ -33,6 +37,10 @@ func (_m *MockLogEventProvider) Close() error { func (_m *MockLogEventProvider) GetLatestPayloads(_a0 context.Context) ([]automation.UpkeepPayload, error) { ret := _m.Called(_a0) + if len(ret) == 0 { + panic("no return value specified for GetLatestPayloads") + } + var r0 []automation.UpkeepPayload var r1 error if rf, ok := ret.Get(0).(func(context.Context) ([]automation.UpkeepPayload, error)); ok { @@ -64,6 +72,10 @@ func (_m *MockLogEventProvider) SetConfig(_a0 automation.LogEventProviderConfig) func (_m *MockLogEventProvider) Start(_a0 context.Context) error { ret := _m.Called(_a0) + if len(ret) == 0 { + panic("no return value specified for Start") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context) error); ok { r0 = rf(_a0) @@ -74,13 +86,12 @@ func (_m *MockLogEventProvider) Start(_a0 context.Context) error { return r0 } -type mockConstructorTestingTNewMockLogEventProvider interface { +// NewMockLogEventProvider creates a new instance of MockLogEventProvider. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewMockLogEventProvider(t interface { mock.TestingT Cleanup(func()) -} - -// NewMockLogEventProvider creates a new instance of MockLogEventProvider. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -func NewMockLogEventProvider(t mockConstructorTestingTNewMockLogEventProvider) *MockLogEventProvider { +}) *MockLogEventProvider { mock := &MockLogEventProvider{} mock.Mock.Test(t) diff --git a/pkg/v3/types/mocks/metadatastore.generated.go b/pkg/v3/types/mocks/metadatastore.generated.go index 513e2db..23fc8fe 100644 --- a/pkg/v3/types/mocks/metadatastore.generated.go +++ b/pkg/v3/types/mocks/metadatastore.generated.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.28.1. DO NOT EDIT. +// Code generated by mockery v2.43.2. DO NOT EDIT. package mocks @@ -32,6 +32,10 @@ func (_m *MockMetadataStore) AddProposals(proposals ...automation.CoordinatedBlo func (_m *MockMetadataStore) Close() error { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for Close") + } + var r0 error if rf, ok := ret.Get(0).(func() error); ok { r0 = rf() @@ -46,6 +50,10 @@ func (_m *MockMetadataStore) Close() error { func (_m *MockMetadataStore) GetBlockHistory() automation.BlockHistory { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetBlockHistory") + } + var r0 automation.BlockHistory if rf, ok := ret.Get(0).(func() automation.BlockHistory); ok { r0 = rf() @@ -78,6 +86,10 @@ func (_m *MockMetadataStore) SetBlockHistory(_a0 automation.BlockHistory) { func (_m *MockMetadataStore) Start(_a0 context.Context) error { ret := _m.Called(_a0) + if len(ret) == 0 { + panic("no return value specified for Start") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context) error); ok { r0 = rf(_a0) @@ -92,6 +104,10 @@ func (_m *MockMetadataStore) Start(_a0 context.Context) error { func (_m *MockMetadataStore) ViewProposals(utype types.UpkeepType) []automation.CoordinatedBlockProposal { ret := _m.Called(utype) + if len(ret) == 0 { + panic("no return value specified for ViewProposals") + } + var r0 []automation.CoordinatedBlockProposal if rf, ok := ret.Get(0).(func(types.UpkeepType) []automation.CoordinatedBlockProposal); ok { r0 = rf(utype) @@ -104,13 +120,12 @@ func (_m *MockMetadataStore) ViewProposals(utype types.UpkeepType) []automation. return r0 } -type mockConstructorTestingTNewMockMetadataStore interface { +// NewMockMetadataStore creates a new instance of MockMetadataStore. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewMockMetadataStore(t interface { mock.TestingT Cleanup(func()) -} - -// NewMockMetadataStore creates a new instance of MockMetadataStore. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -func NewMockMetadataStore(t mockConstructorTestingTNewMockMetadataStore) *MockMetadataStore { +}) *MockMetadataStore { mock := &MockMetadataStore{} mock.Mock.Test(t) diff --git a/pkg/v3/types/mocks/payloadbuilder.generated.go b/pkg/v3/types/mocks/payloadbuilder.generated.go index 0822516..f79f3cf 100644 --- a/pkg/v3/types/mocks/payloadbuilder.generated.go +++ b/pkg/v3/types/mocks/payloadbuilder.generated.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.28.1. DO NOT EDIT. +// Code generated by mockery v2.43.2. DO NOT EDIT. package mocks @@ -26,6 +26,10 @@ func (_m *MockPayloadBuilder) BuildPayloads(_a0 context.Context, _a1 ...automati _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for BuildPayloads") + } + var r0 []automation.UpkeepPayload var r1 error if rf, ok := ret.Get(0).(func(context.Context, ...automation.CoordinatedBlockProposal) ([]automation.UpkeepPayload, error)); ok { @@ -48,13 +52,12 @@ func (_m *MockPayloadBuilder) BuildPayloads(_a0 context.Context, _a1 ...automati return r0, r1 } -type mockConstructorTestingTNewMockPayloadBuilder interface { +// NewMockPayloadBuilder creates a new instance of MockPayloadBuilder. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewMockPayloadBuilder(t interface { mock.TestingT Cleanup(func()) -} - -// NewMockPayloadBuilder creates a new instance of MockPayloadBuilder. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -func NewMockPayloadBuilder(t mockConstructorTestingTNewMockPayloadBuilder) *MockPayloadBuilder { +}) *MockPayloadBuilder { mock := &MockPayloadBuilder{} mock.Mock.Test(t) diff --git a/pkg/v3/types/mocks/ratio.generated.go b/pkg/v3/types/mocks/ratio.generated.go index 1f3b9ea..6da99e0 100644 --- a/pkg/v3/types/mocks/ratio.generated.go +++ b/pkg/v3/types/mocks/ratio.generated.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.28.1. DO NOT EDIT. +// Code generated by mockery v2.43.2. DO NOT EDIT. package mocks @@ -13,6 +13,10 @@ type MockRatio struct { func (_m *MockRatio) OfInt(_a0 int) int { ret := _m.Called(_a0) + if len(ret) == 0 { + panic("no return value specified for OfInt") + } + var r0 int if rf, ok := ret.Get(0).(func(int) int); ok { r0 = rf(_a0) @@ -23,13 +27,12 @@ func (_m *MockRatio) OfInt(_a0 int) int { return r0 } -type mockConstructorTestingTNewMockRatio interface { +// NewMockRatio creates a new instance of MockRatio. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewMockRatio(t interface { mock.TestingT Cleanup(func()) -} - -// NewMockRatio creates a new instance of MockRatio. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -func NewMockRatio(t mockConstructorTestingTNewMockRatio) *MockRatio { +}) *MockRatio { mock := &MockRatio{} mock.Mock.Test(t) diff --git a/pkg/v3/types/mocks/recoverableprovider.generated.go b/pkg/v3/types/mocks/recoverableprovider.generated.go index 6c41976..d445e9d 100644 --- a/pkg/v3/types/mocks/recoverableprovider.generated.go +++ b/pkg/v3/types/mocks/recoverableprovider.generated.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.28.1. DO NOT EDIT. +// Code generated by mockery v2.43.2. DO NOT EDIT. package mocks @@ -19,6 +19,10 @@ type MockRecoverableProvider struct { func (_m *MockRecoverableProvider) GetRecoveryProposals(_a0 context.Context) ([]automation.UpkeepPayload, error) { ret := _m.Called(_a0) + if len(ret) == 0 { + panic("no return value specified for GetRecoveryProposals") + } + var r0 []automation.UpkeepPayload var r1 error if rf, ok := ret.Get(0).(func(context.Context) ([]automation.UpkeepPayload, error)); ok { @@ -41,13 +45,12 @@ func (_m *MockRecoverableProvider) GetRecoveryProposals(_a0 context.Context) ([] return r0, r1 } -type mockConstructorTestingTNewMockRecoverableProvider interface { +// NewMockRecoverableProvider creates a new instance of MockRecoverableProvider. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewMockRecoverableProvider(t interface { mock.TestingT Cleanup(func()) -} - -// NewMockRecoverableProvider creates a new instance of MockRecoverableProvider. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -func NewMockRecoverableProvider(t mockConstructorTestingTNewMockRecoverableProvider) *MockRecoverableProvider { +}) *MockRecoverableProvider { mock := &MockRecoverableProvider{} mock.Mock.Test(t) diff --git a/pkg/v3/types/mocks/result_store.generated.go b/pkg/v3/types/mocks/result_store.generated.go index 49fa90c..c44b4a2 100644 --- a/pkg/v3/types/mocks/result_store.generated.go +++ b/pkg/v3/types/mocks/result_store.generated.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.28.1. DO NOT EDIT. +// Code generated by mockery v2.43.2. DO NOT EDIT. package mocks @@ -38,6 +38,10 @@ func (_m *MockResultStore) Remove(_a0 ...string) { func (_m *MockResultStore) View() ([]automation.CheckResult, error) { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for View") + } + var r0 []automation.CheckResult var r1 error if rf, ok := ret.Get(0).(func() ([]automation.CheckResult, error)); ok { @@ -60,13 +64,12 @@ func (_m *MockResultStore) View() ([]automation.CheckResult, error) { return r0, r1 } -type mockConstructorTestingTNewMockResultStore interface { +// NewMockResultStore creates a new instance of MockResultStore. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewMockResultStore(t interface { mock.TestingT Cleanup(func()) -} - -// NewMockResultStore creates a new instance of MockResultStore. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -func NewMockResultStore(t mockConstructorTestingTNewMockResultStore) *MockResultStore { +}) *MockResultStore { mock := &MockResultStore{} mock.Mock.Test(t) diff --git a/pkg/v3/types/mocks/runnable.generated.go b/pkg/v3/types/mocks/runnable.generated.go index 368966e..794d7b6 100644 --- a/pkg/v3/types/mocks/runnable.generated.go +++ b/pkg/v3/types/mocks/runnable.generated.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.28.1. DO NOT EDIT. +// Code generated by mockery v2.43.2. DO NOT EDIT. package mocks @@ -26,6 +26,10 @@ func (_m *MockRunnable) CheckUpkeeps(_a0 context.Context, _a1 ...automation.Upke _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for CheckUpkeeps") + } + var r0 []automation.CheckResult var r1 error if rf, ok := ret.Get(0).(func(context.Context, ...automation.UpkeepPayload) ([]automation.CheckResult, error)); ok { @@ -48,13 +52,12 @@ func (_m *MockRunnable) CheckUpkeeps(_a0 context.Context, _a1 ...automation.Upke return r0, r1 } -type mockConstructorTestingTNewMockRunnable interface { +// NewMockRunnable creates a new instance of MockRunnable. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewMockRunnable(t interface { mock.TestingT Cleanup(func()) -} - -// NewMockRunnable creates a new instance of MockRunnable. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -func NewMockRunnable(t mockConstructorTestingTNewMockRunnable) *MockRunnable { +}) *MockRunnable { mock := &MockRunnable{} mock.Mock.Test(t) diff --git a/pkg/v3/types/mocks/transmit_event_provider.generated.go b/pkg/v3/types/mocks/transmit_event_provider.generated.go index 827dd68..a3640df 100644 --- a/pkg/v3/types/mocks/transmit_event_provider.generated.go +++ b/pkg/v3/types/mocks/transmit_event_provider.generated.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.28.1. DO NOT EDIT. +// Code generated by mockery v2.43.2. DO NOT EDIT. package mocks @@ -19,6 +19,10 @@ type TransmitEventProvider struct { func (_m *TransmitEventProvider) GetLatestEvents(_a0 context.Context) ([]automation.TransmitEvent, error) { ret := _m.Called(_a0) + if len(ret) == 0 { + panic("no return value specified for GetLatestEvents") + } + var r0 []automation.TransmitEvent var r1 error if rf, ok := ret.Get(0).(func(context.Context) ([]automation.TransmitEvent, error)); ok { @@ -41,13 +45,12 @@ func (_m *TransmitEventProvider) GetLatestEvents(_a0 context.Context) ([]automat return r0, r1 } -type mockConstructorTestingTNewTransmitEventProvider interface { +// NewTransmitEventProvider creates a new instance of TransmitEventProvider. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewTransmitEventProvider(t interface { mock.TestingT Cleanup(func()) -} - -// NewTransmitEventProvider creates a new instance of TransmitEventProvider. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -func NewTransmitEventProvider(t mockConstructorTestingTNewTransmitEventProvider) *TransmitEventProvider { +}) *TransmitEventProvider { mock := &TransmitEventProvider{} mock.Mock.Test(t) diff --git a/pkg/v3/types/mocks/upkeep_state_updater.generated.go b/pkg/v3/types/mocks/upkeep_state_updater.generated.go index 0bb139a..6747afe 100644 --- a/pkg/v3/types/mocks/upkeep_state_updater.generated.go +++ b/pkg/v3/types/mocks/upkeep_state_updater.generated.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.28.1. DO NOT EDIT. +// Code generated by mockery v2.43.2. DO NOT EDIT. package mocks @@ -19,6 +19,10 @@ type MockUpkeepStateUpdater struct { func (_m *MockUpkeepStateUpdater) SetUpkeepState(_a0 context.Context, _a1 automation.CheckResult, _a2 automation.UpkeepState) error { ret := _m.Called(_a0, _a1, _a2) + if len(ret) == 0 { + panic("no return value specified for SetUpkeepState") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context, automation.CheckResult, automation.UpkeepState) error); ok { r0 = rf(_a0, _a1, _a2) @@ -29,13 +33,12 @@ func (_m *MockUpkeepStateUpdater) SetUpkeepState(_a0 context.Context, _a1 automa return r0 } -type mockConstructorTestingTNewMockUpkeepStateUpdater interface { +// NewMockUpkeepStateUpdater creates a new instance of MockUpkeepStateUpdater. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewMockUpkeepStateUpdater(t interface { mock.TestingT Cleanup(func()) -} - -// NewMockUpkeepStateUpdater creates a new instance of MockUpkeepStateUpdater. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -func NewMockUpkeepStateUpdater(t mockConstructorTestingTNewMockUpkeepStateUpdater) *MockUpkeepStateUpdater { +}) *MockUpkeepStateUpdater { mock := &MockUpkeepStateUpdater{} mock.Mock.Test(t) diff --git a/sonar-project.properties b/sonar-project.properties index 352a773..57e8e8d 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -10,4 +10,4 @@ sonar.coverage.exclusions=**/*.test.ts, **/*_test.go, **/contracts/test/**/*, ** # Tests' root folder, inclusions (tests to check and count) and exclusions sonar.tests=. -sonar.test.inclusions=**/*_test.go \ No newline at end of file +sonar.test.inclusions=**/*_test.go