diff --git a/mocks/pkg/contractreader/extended.go b/mocks/pkg/contractreader/extended.go index 8d642f0e..2b748854 100644 --- a/mocks/pkg/contractreader/extended.go +++ b/mocks/pkg/contractreader/extended.go @@ -404,6 +404,53 @@ func (_c *MockExtended_GetLatestValue_Call) RunAndReturn(run func(context.Contex return _c } +// HealthReport provides a mock function with given fields: +func (_m *MockExtended) HealthReport() map[string]error { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for HealthReport") + } + + var r0 map[string]error + if rf, ok := ret.Get(0).(func() map[string]error); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(map[string]error) + } + } + + return r0 +} + +// MockExtended_HealthReport_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'HealthReport' +type MockExtended_HealthReport_Call struct { + *mock.Call +} + +// HealthReport is a helper method to define mock.On call +func (_e *MockExtended_Expecter) HealthReport() *MockExtended_HealthReport_Call { + return &MockExtended_HealthReport_Call{Call: _e.mock.On("HealthReport")} +} + +func (_c *MockExtended_HealthReport_Call) Run(run func()) *MockExtended_HealthReport_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *MockExtended_HealthReport_Call) Return(_a0 map[string]error) *MockExtended_HealthReport_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockExtended_HealthReport_Call) RunAndReturn(run func() map[string]error) *MockExtended_HealthReport_Call { + _c.Call.Return(run) + return _c +} + // QueryKey provides a mock function with given fields: ctx, contract, filter, limitAndSort, sequenceDataType func (_m *MockExtended) QueryKey(ctx context.Context, contract types.BoundContract, filter query.KeyFilter, limitAndSort query.LimitAndSort, sequenceDataType interface{}) ([]types.Sequence, error) { ret := _m.Called(ctx, contract, filter, limitAndSort, sequenceDataType) @@ -466,6 +513,53 @@ func (_c *MockExtended_QueryKey_Call) RunAndReturn(run func(context.Context, typ return _c } +// Unbind provides a mock function with given fields: ctx, bindings +func (_m *MockExtended) Unbind(ctx context.Context, bindings []types.BoundContract) error { + ret := _m.Called(ctx, bindings) + + if len(ret) == 0 { + panic("no return value specified for Unbind") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, []types.BoundContract) error); ok { + r0 = rf(ctx, bindings) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockExtended_Unbind_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Unbind' +type MockExtended_Unbind_Call struct { + *mock.Call +} + +// Unbind is a helper method to define mock.On call +// - ctx context.Context +// - bindings []types.BoundContract +func (_e *MockExtended_Expecter) Unbind(ctx interface{}, bindings interface{}) *MockExtended_Unbind_Call { + return &MockExtended_Unbind_Call{Call: _e.mock.On("Unbind", ctx, bindings)} +} + +func (_c *MockExtended_Unbind_Call) Run(run func(ctx context.Context, bindings []types.BoundContract)) *MockExtended_Unbind_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].([]types.BoundContract)) + }) + return _c +} + +func (_c *MockExtended_Unbind_Call) Return(_a0 error) *MockExtended_Unbind_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockExtended_Unbind_Call) RunAndReturn(run func(context.Context, []types.BoundContract) error) *MockExtended_Unbind_Call { + _c.Call.Return(run) + return _c +} + // NewMockExtended creates a new instance of MockExtended. 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 NewMockExtended(t interface { diff --git a/pkg/contractreader/extended.go b/pkg/contractreader/extended.go index 97c395f3..aa0a4eee 100644 --- a/pkg/contractreader/extended.go +++ b/pkg/contractreader/extended.go @@ -24,6 +24,11 @@ var ( // Extended version of a ContractReader. type Extended interface { + // Unbind is included for compatibility with ContractReader + Unbind(ctx context.Context, bindings []types.BoundContract) error + // HealthReport is included for compatibility with ContractReader + HealthReport() map[string]error + Bind(ctx context.Context, bindings []types.BoundContract) error GetBindings(contractName string) []ExtendedBoundContract @@ -278,19 +283,19 @@ func (e *extendedContractReader) bindingExists(b types.BoundContract) bool { } func (e *extendedContractReader) hasFinalityViolation() bool { - if e.reader == nil { - return false - } - - if _, ok := e.reader.(Extended); ok { - panic("bad news") - } - report := e.reader.HealthReport() return services.ContainsError( report, clcommontypes.ErrFinalityViolated) } +func (e *extendedContractReader) Unbind(ctx context.Context, bindings []types.BoundContract) error { + return e.reader.Unbind(ctx, bindings) +} + +func (e *extendedContractReader) HealthReport() map[string]error { + return e.reader.HealthReport() +} + // Interface compliance check var _ Extended = (*extendedContractReader)(nil) diff --git a/pkg/reader/rmn_home.go b/pkg/reader/rmn_home.go index d138f7b1..6fc52e24 100644 --- a/pkg/reader/rmn_home.go +++ b/pkg/reader/rmn_home.go @@ -61,7 +61,7 @@ type rmnHomePoller struct { stopCh services.StopChan sync services.StateMachine mutex *sync.RWMutex - contractReader contractreader.Extended + contractReader contractreader.ContractReaderFacade rmnHomeBoundContract types.BoundContract lggr logger.Logger rmnHomeState rmnHomeState @@ -70,7 +70,7 @@ type rmnHomePoller struct { } func NewRMNHomePoller( - contractReader contractreader.Extended, + contractReader contractreader.ContractReaderFacade, rmnHomeBoundContract types.BoundContract, lggr logger.Logger, pollingInterval time.Duration,