Skip to content

Commit

Permalink
mockgen: use typed mocks for compile time check (#10103)
Browse files Browse the repository at this point in the history
Use `mockgen -typed=true` to generate mocks with type-safe `Return`,
`Do`, `DoAndReturn` function -
https://github.com/uber-go/mock?tab=readme-ov-file#flags
  • Loading branch information
taratorio authored Apr 28, 2024
1 parent 63578a8 commit 4bc3bc6
Show file tree
Hide file tree
Showing 48 changed files with 4,983 additions and 464 deletions.
58 changes: 53 additions & 5 deletions cl/aggregation/mock_services/aggregation_pool_mock.go

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

2 changes: 1 addition & 1 deletion cl/aggregation/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"github.com/ledgerwatch/erigon/cl/cltypes/solid"
)

//go:generate mockgen -destination=./mock_services/aggregation_pool_mock.go -package=mock_services . AggregationPool
//go:generate mockgen -typed=true -destination=./mock_services/aggregation_pool_mock.go -package=mock_services . AggregationPool
type AggregationPool interface {
// AddAttestation adds a single attestation to the pool.
AddAttestation(att *solid.Attestation) error
Expand Down
2 changes: 1 addition & 1 deletion cl/beacon/synced_data/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package synced_data

import "github.com/ledgerwatch/erigon/cl/phase1/core/state"

//go:generate mockgen -destination=./mock_services/synced_data_mock.go -package=mock_services . SyncedData
//go:generate mockgen -typed=true -destination=./mock_services/synced_data_mock.go -package=mock_services . SyncedData
type SyncedData interface {
OnHeadState(newState *state.CachingBeaconState) (err error)
HeadState() *state.CachingBeaconState
Expand Down
142 changes: 131 additions & 11 deletions cl/beacon/synced_data/mock_services/synced_data_mock.go

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

2 changes: 1 addition & 1 deletion cl/phase1/core/state/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import libcommon "github.com/ledgerwatch/erigon-lib/common"

// BeaconStateReader is an interface for reading the beacon state.
//
//go:generate mockgen -destination=./mock_services/beacon_state_reader_mock.go -package=mock_services . BeaconStateReader
//go:generate mockgen -typed=true -destination=./mock_services/beacon_state_reader_mock.go -package=mock_services . BeaconStateReader
type BeaconStateReader interface {
ValidatorPublicKey(index int) (libcommon.Bytes48, error)
GetDomain(domainType [4]byte, epoch uint64) ([]byte, error)
Expand Down
Loading

0 comments on commit 4bc3bc6

Please sign in to comment.