Skip to content

Commit

Permalink
Merge branch 'refs/heads/alan/no-fork' into alan/test-message-validation
Browse files Browse the repository at this point in the history
  • Loading branch information
nkryuchkov committed May 23, 2024
2 parents fbee3c3 + 39a08af commit adedb90
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 41 deletions.
4 changes: 2 additions & 2 deletions operator/duties/base_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 25 additions & 20 deletions operator/duties/mocks/scheduler.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 6 additions & 10 deletions operator/duties/scheduler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -108,7 +108,6 @@ func setupSchedulerAndMocks(t *testing.T, handler dutyHandler, currentSlot *Slot
mockSlotService.Subscribe(ticker.Subscribe())
return ticker
},
BuilderProposals: false,
}

s := NewScheduler(opts)
Expand Down Expand Up @@ -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()
Expand All @@ -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
},
Expand All @@ -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))
Expand Down Expand Up @@ -320,8 +318,6 @@ func TestScheduler_Regression_IndicesChangeStuck(t *testing.T) {
return mockTicker
},
IndicesChg: make(chan struct{}),

BuilderProposals: true,
}

s := NewScheduler(opts)
Expand Down
2 changes: 1 addition & 1 deletion operator/duties/voluntary_exit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down

0 comments on commit adedb90

Please sign in to comment.