From 39a08af0b7152c36ce68c96971351ed8437d536e Mon Sep 17 00:00:00 2001 From: pavelkrolevets Date: Thu, 23 May 2024 16:20:20 +0300 Subject: [PATCH] fix compilation error at operator/duties --- operator/duties/base_handler.go | 4 +- .../base_handler.go => base_handler_mock.go} | 20 +++++---- operator/duties/mocks/scheduler.go | 45 ++++++++++--------- operator/duties/scheduler_test.go | 16 +++---- operator/duties/voluntary_exit_test.go | 2 +- 5 files changed, 46 insertions(+), 41 deletions(-) rename operator/duties/{mocks/base_handler.go => base_handler_mock.go} (82%) diff --git a/operator/duties/base_handler.go b/operator/duties/base_handler.go index 3de9a6ed34..6ae1f5af9f 100644 --- a/operator/duties/base_handler.go +++ b/operator/duties/base_handler.go @@ -3,14 +3,14 @@ package duties import ( "context" - spectypes "github.com/ssvlabs/ssv-spec/types" "go.uber.org/zap" + spectypes "github.com/ssvlabs/ssv-spec/types" "github.com/ssvlabs/ssv/networkconfig" "github.com/ssvlabs/ssv/operator/slotticker" ) -//go:generate mockgen -package=mocks -destination=./mocks/base_handler.go -source=./base_handler.go +//go:generate mockgen -package=duties -destination=./base_handler_mock.go -source=./base_handler.go // ExecuteDutiesFunc is a non-blocking functions which executes the given duties. type ExecuteDutiesFunc func(logger *zap.Logger, duties []*spectypes.BeaconDuty) diff --git a/operator/duties/mocks/base_handler.go b/operator/duties/base_handler_mock.go similarity index 82% rename from operator/duties/mocks/base_handler.go rename to operator/duties/base_handler_mock.go index 164f7a9275..05bb00490c 100644 --- a/operator/duties/mocks/base_handler.go +++ b/operator/duties/base_handler_mock.go @@ -1,17 +1,21 @@ // Code generated by MockGen. DO NOT EDIT. // Source: ./base_handler.go +// +// Generated by this command: +// +// mockgen -package=duties -destination=./base_handler_mock.go -source=./base_handler.go +// -// Package mocks is a generated GoMock package. -package mocks +// Package duties is a generated GoMock package. +package duties import ( context "context" reflect "reflect" - gomock "go.uber.org/mock/gomock" networkconfig "github.com/ssvlabs/ssv/networkconfig" - duties "github.com/ssvlabs/ssv/operator/duties" slotticker "github.com/ssvlabs/ssv/operator/slotticker" + gomock "go.uber.org/mock/gomock" zap "go.uber.org/zap" ) @@ -45,7 +49,7 @@ func (m *MockdutyHandler) HandleDuties(arg0 context.Context) { } // HandleDuties indicates an expected call of HandleDuties. -func (mr *MockdutyHandlerMockRecorder) HandleDuties(arg0 interface{}) *gomock.Call { +func (mr *MockdutyHandlerMockRecorder) HandleDuties(arg0 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HandleDuties", reflect.TypeOf((*MockdutyHandler)(nil).HandleDuties), arg0) } @@ -57,7 +61,7 @@ func (m *MockdutyHandler) HandleInitialDuties(arg0 context.Context) { } // HandleInitialDuties indicates an expected call of HandleInitialDuties. -func (mr *MockdutyHandlerMockRecorder) HandleInitialDuties(arg0 interface{}) *gomock.Call { +func (mr *MockdutyHandlerMockRecorder) HandleInitialDuties(arg0 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HandleInitialDuties", reflect.TypeOf((*MockdutyHandler)(nil).HandleInitialDuties), arg0) } @@ -77,13 +81,13 @@ func (mr *MockdutyHandlerMockRecorder) Name() *gomock.Call { } // Setup mocks base method. -func (m *MockdutyHandler) Setup(arg0 string, arg1 *zap.Logger, arg2 duties.BeaconNode, arg3 duties.ExecutionClient, arg4 networkconfig.NetworkConfig, arg5 duties.ValidatorProvider, arg6 duties.ExecuteDutiesFunc, arg7 duties.ExecuteCommitteeDutiesFunc, arg8 slotticker.Provider, arg9 chan duties.ReorgEvent, arg10 chan struct{}) { +func (m *MockdutyHandler) Setup(arg0 string, arg1 *zap.Logger, arg2 BeaconNode, arg3 ExecutionClient, arg4 networkconfig.NetworkConfig, arg5 ValidatorProvider, arg6 ExecuteDutiesFunc, arg7 ExecuteCommitteeDutiesFunc, arg8 slotticker.Provider, arg9 chan ReorgEvent, arg10 chan struct{}) { m.ctrl.T.Helper() m.ctrl.Call(m, "Setup", arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10) } // Setup indicates an expected call of Setup. -func (mr *MockdutyHandlerMockRecorder) Setup(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10 interface{}) *gomock.Call { +func (mr *MockdutyHandlerMockRecorder) Setup(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Setup", reflect.TypeOf((*MockdutyHandler)(nil).Setup), arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10) } diff --git a/operator/duties/mocks/scheduler.go b/operator/duties/mocks/scheduler.go index d4ea679374..5bc6694d50 100644 --- a/operator/duties/mocks/scheduler.go +++ b/operator/duties/mocks/scheduler.go @@ -1,5 +1,10 @@ // Code generated by MockGen. DO NOT EDIT. // Source: ./scheduler.go +// +// Generated by this command: +// +// mockgen -package=mocks -destination=./mocks/scheduler.go -source=./scheduler.go +// // Package mocks is a generated GoMock package. package mocks @@ -13,9 +18,9 @@ import ( client "github.com/attestantio/go-eth2-client" v1 "github.com/attestantio/go-eth2-client/api/v1" phase0 "github.com/attestantio/go-eth2-client/spec/phase0" - types0 "github.com/ethereum/go-ethereum/core/types" + types "github.com/ethereum/go-ethereum/core/types" + types0 "github.com/ssvlabs/ssv/protocol/v2/types" gomock "go.uber.org/mock/gomock" - types "github.com/ssvlabs/ssv/protocol/v2/types" ) // MockSlotTicker is a mock of SlotTicker interface. @@ -102,7 +107,7 @@ func (m *MockBeaconNode) AttesterDuties(ctx context.Context, epoch phase0.Epoch, } // AttesterDuties indicates an expected call of AttesterDuties. -func (mr *MockBeaconNodeMockRecorder) AttesterDuties(ctx, epoch, validatorIndices interface{}) *gomock.Call { +func (mr *MockBeaconNodeMockRecorder) AttesterDuties(ctx, epoch, validatorIndices any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AttesterDuties", reflect.TypeOf((*MockBeaconNode)(nil).AttesterDuties), ctx, epoch, validatorIndices) } @@ -116,7 +121,7 @@ func (m *MockBeaconNode) Events(ctx context.Context, topics []string, handler cl } // Events indicates an expected call of Events. -func (mr *MockBeaconNodeMockRecorder) Events(ctx, topics, handler interface{}) *gomock.Call { +func (mr *MockBeaconNodeMockRecorder) Events(ctx, topics, handler any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Events", reflect.TypeOf((*MockBeaconNode)(nil).Events), ctx, topics, handler) } @@ -131,7 +136,7 @@ func (m *MockBeaconNode) ProposerDuties(ctx context.Context, epoch phase0.Epoch, } // ProposerDuties indicates an expected call of ProposerDuties. -func (mr *MockBeaconNodeMockRecorder) ProposerDuties(ctx, epoch, validatorIndices interface{}) *gomock.Call { +func (mr *MockBeaconNodeMockRecorder) ProposerDuties(ctx, epoch, validatorIndices any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ProposerDuties", reflect.TypeOf((*MockBeaconNode)(nil).ProposerDuties), ctx, epoch, validatorIndices) } @@ -145,7 +150,7 @@ func (m *MockBeaconNode) SubmitBeaconCommitteeSubscriptions(ctx context.Context, } // SubmitBeaconCommitteeSubscriptions indicates an expected call of SubmitBeaconCommitteeSubscriptions. -func (mr *MockBeaconNodeMockRecorder) SubmitBeaconCommitteeSubscriptions(ctx, subscription interface{}) *gomock.Call { +func (mr *MockBeaconNodeMockRecorder) SubmitBeaconCommitteeSubscriptions(ctx, subscription any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SubmitBeaconCommitteeSubscriptions", reflect.TypeOf((*MockBeaconNode)(nil).SubmitBeaconCommitteeSubscriptions), ctx, subscription) } @@ -159,7 +164,7 @@ func (m *MockBeaconNode) SubmitSyncCommitteeSubscriptions(ctx context.Context, s } // SubmitSyncCommitteeSubscriptions indicates an expected call of SubmitSyncCommitteeSubscriptions. -func (mr *MockBeaconNodeMockRecorder) SubmitSyncCommitteeSubscriptions(ctx, subscription interface{}) *gomock.Call { +func (mr *MockBeaconNodeMockRecorder) SubmitSyncCommitteeSubscriptions(ctx, subscription any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SubmitSyncCommitteeSubscriptions", reflect.TypeOf((*MockBeaconNode)(nil).SubmitSyncCommitteeSubscriptions), ctx, subscription) } @@ -174,7 +179,7 @@ func (m *MockBeaconNode) SyncCommitteeDuties(ctx context.Context, epoch phase0.E } // SyncCommitteeDuties indicates an expected call of SyncCommitteeDuties. -func (mr *MockBeaconNodeMockRecorder) SyncCommitteeDuties(ctx, epoch, indices interface{}) *gomock.Call { +func (mr *MockBeaconNodeMockRecorder) SyncCommitteeDuties(ctx, epoch, indices any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SyncCommitteeDuties", reflect.TypeOf((*MockBeaconNode)(nil).SyncCommitteeDuties), ctx, epoch, indices) } @@ -203,16 +208,16 @@ func (m *MockExecutionClient) EXPECT() *MockExecutionClientMockRecorder { } // BlockByNumber mocks base method. -func (m *MockExecutionClient) BlockByNumber(ctx context.Context, blockNumber *big.Int) (*types0.Block, error) { +func (m *MockExecutionClient) BlockByNumber(ctx context.Context, blockNumber *big.Int) (*types.Block, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "BlockByNumber", ctx, blockNumber) - ret0, _ := ret[0].(*types0.Block) + ret0, _ := ret[0].(*types.Block) ret1, _ := ret[1].(error) return ret0, ret1 } // BlockByNumber indicates an expected call of BlockByNumber. -func (mr *MockExecutionClientMockRecorder) BlockByNumber(ctx, blockNumber interface{}) *gomock.Call { +func (mr *MockExecutionClientMockRecorder) BlockByNumber(ctx, blockNumber any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "BlockByNumber", reflect.TypeOf((*MockExecutionClient)(nil).BlockByNumber), ctx, blockNumber) } @@ -241,43 +246,43 @@ func (m *MockValidatorProvider) EXPECT() *MockValidatorProviderMockRecorder { } // ParticipatingValidators mocks base method. -func (m *MockValidatorProvider) ParticipatingValidators(epoch phase0.Epoch) []*types.SSVShare { +func (m *MockValidatorProvider) ParticipatingValidators(epoch phase0.Epoch) []*types0.SSVShare { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ParticipatingValidators", epoch) - ret0, _ := ret[0].([]*types.SSVShare) + ret0, _ := ret[0].([]*types0.SSVShare) return ret0 } // ParticipatingValidators indicates an expected call of ParticipatingValidators. -func (mr *MockValidatorProviderMockRecorder) ParticipatingValidators(epoch interface{}) *gomock.Call { +func (mr *MockValidatorProviderMockRecorder) ParticipatingValidators(epoch any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ParticipatingValidators", reflect.TypeOf((*MockValidatorProvider)(nil).ParticipatingValidators), epoch) } // SelfParticipatingValidators mocks base method. -func (m *MockValidatorProvider) SelfParticipatingValidators(epoch phase0.Epoch) []*types.SSVShare { +func (m *MockValidatorProvider) SelfParticipatingValidators(epoch phase0.Epoch) []*types0.SSVShare { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "SelfParticipatingValidators", epoch) - ret0, _ := ret[0].([]*types.SSVShare) + ret0, _ := ret[0].([]*types0.SSVShare) return ret0 } // SelfParticipatingValidators indicates an expected call of SelfParticipatingValidators. -func (mr *MockValidatorProviderMockRecorder) SelfParticipatingValidators(epoch interface{}) *gomock.Call { +func (mr *MockValidatorProviderMockRecorder) SelfParticipatingValidators(epoch any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SelfParticipatingValidators", reflect.TypeOf((*MockValidatorProvider)(nil).SelfParticipatingValidators), epoch) } // Validator mocks base method. -func (m *MockValidatorProvider) Validator(pubKey []byte) *types.SSVShare { +func (m *MockValidatorProvider) Validator(pubKey []byte) *types0.SSVShare { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Validator", pubKey) - ret0, _ := ret[0].(*types.SSVShare) + ret0, _ := ret[0].(*types0.SSVShare) return ret0 } // Validator indicates an expected call of Validator. -func (mr *MockValidatorProviderMockRecorder) Validator(pubKey interface{}) *gomock.Call { +func (mr *MockValidatorProviderMockRecorder) Validator(pubKey any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Validator", reflect.TypeOf((*MockValidatorProvider)(nil).Validator), pubKey) } diff --git a/operator/duties/scheduler_test.go b/operator/duties/scheduler_test.go index 2c25f4c974..1dcca516d2 100644 --- a/operator/duties/scheduler_test.go +++ b/operator/duties/scheduler_test.go @@ -9,11 +9,11 @@ import ( "github.com/attestantio/go-eth2-client/spec/phase0" "github.com/prysmaticlabs/prysm/v4/async/event" "github.com/sourcegraph/conc/pool" - spectypes "github.com/ssvlabs/ssv-spec/types" "github.com/stretchr/testify/require" "go.uber.org/mock/gomock" "go.uber.org/zap" + spectypes "github.com/ssvlabs/ssv-spec/types" "github.com/ssvlabs/ssv/logging" "github.com/ssvlabs/ssv/networkconfig" "github.com/ssvlabs/ssv/operator/duties/mocks" @@ -108,7 +108,6 @@ func setupSchedulerAndMocks(t *testing.T, handler dutyHandler, currentSlot *Slot mockSlotService.Subscribe(ticker.Subscribe()) return ticker }, - BuilderProposals: false, } s := NewScheduler(opts) @@ -256,8 +255,8 @@ func TestScheduler_Run(t *testing.T) { mockValidatorProvider := mocks.NewMockValidatorProvider(ctrl) mockTicker := mockslotticker.NewMockSlotTicker(ctrl) // create multiple mock duty handlers - mockDutyHandler1 := mocks.NewMockdutyHandler(ctrl) - mockDutyHandler2 := mocks.NewMockdutyHandler(ctrl) + mockDutyHandler1 := NewMockdutyHandler(ctrl) + mockDutyHandler2 := NewMockdutyHandler(ctrl) mockDutyHandler1.EXPECT().HandleInitialDuties(gomock.Any()).AnyTimes() mockDutyHandler2.EXPECT().HandleInitialDuties(gomock.Any()).AnyTimes() @@ -267,7 +266,6 @@ func TestScheduler_Run(t *testing.T) { BeaconNode: mockBeaconNode, Network: networkconfig.TestNetwork, ValidatorProvider: mockValidatorProvider, - BuilderProposals: false, SlotTickerProvider: func() slotticker.SlotTicker { return mockTicker }, @@ -282,13 +280,13 @@ func TestScheduler_Run(t *testing.T) { // setup mock duty handler expectations for _, mockDutyHandler := range s.handlers { - mockDutyHandler.(*mocks.MockdutyHandler).EXPECT().Setup(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Times(1) - mockDutyHandler.(*mocks.MockdutyHandler).EXPECT().HandleDuties(gomock.Any()). + mockDutyHandler.(*MockdutyHandler).EXPECT().Setup(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Times(1) + mockDutyHandler.(*MockdutyHandler).EXPECT().HandleDuties(gomock.Any()). DoAndReturn(func(ctx context.Context) { <-ctx.Done() }). Times(1) - mockDutyHandler.(*mocks.MockdutyHandler).EXPECT().Name().Times(1) + mockDutyHandler.(*MockdutyHandler).EXPECT().Name().Times(1) } require.NoError(t, s.Start(ctx, logger)) @@ -320,8 +318,6 @@ func TestScheduler_Regression_IndicesChangeStuck(t *testing.T) { return mockTicker }, IndicesChg: make(chan struct{}), - - BuilderProposals: true, } s := NewScheduler(opts) diff --git a/operator/duties/voluntary_exit_test.go b/operator/duties/voluntary_exit_test.go index 4f2a33888c..4211aa77a5 100644 --- a/operator/duties/voluntary_exit_test.go +++ b/operator/duties/voluntary_exit_test.go @@ -9,10 +9,10 @@ import ( "github.com/attestantio/go-eth2-client/spec/phase0" ethtypes "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/trie" - spectypes "github.com/ssvlabs/ssv-spec/types" "github.com/stretchr/testify/require" "go.uber.org/mock/gomock" + spectypes "github.com/ssvlabs/ssv-spec/types" "github.com/ssvlabs/ssv/operator/duties/mocks" mocknetwork "github.com/ssvlabs/ssv/protocol/v2/blockchain/beacon/mocks" )