2022-01-26 14:48:20 +00:00
|
|
|
package mock
|
2021-02-11 21:08:36 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
2021-02-16 07:45:34 +00:00
|
|
|
types "github.com/prysmaticlabs/eth2-types"
|
2021-07-23 16:11:21 +00:00
|
|
|
"github.com/prysmaticlabs/prysm/beacon-chain/state"
|
2021-08-30 23:57:08 +00:00
|
|
|
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
2021-07-28 21:23:44 +00:00
|
|
|
"github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/block"
|
2021-02-11 21:08:36 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// MockStateManager is a fake implementation of StateManager.
|
|
|
|
type MockStateManager struct {
|
2021-07-23 16:11:21 +00:00
|
|
|
StatesByRoot map[[32]byte]state.BeaconState
|
|
|
|
StatesBySlot map[types.Slot]state.BeaconState
|
2021-02-11 21:08:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// NewMockService --
|
|
|
|
func NewMockService() *MockStateManager {
|
|
|
|
return &MockStateManager{
|
2021-07-23 16:11:21 +00:00
|
|
|
StatesByRoot: make(map[[32]byte]state.BeaconState),
|
|
|
|
StatesBySlot: make(map[types.Slot]state.BeaconState),
|
2021-02-11 21:08:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-19 01:14:56 +00:00
|
|
|
// StateByRootIfCached
|
2021-12-07 17:52:39 +00:00
|
|
|
func (_ *MockStateManager) StateByRootIfCachedNoCopy(_ [32]byte) state.BeaconState {
|
2021-11-19 01:14:56 +00:00
|
|
|
panic("implement me")
|
|
|
|
}
|
|
|
|
|
2021-02-11 21:08:36 +00:00
|
|
|
// Resume --
|
2021-12-07 17:52:39 +00:00
|
|
|
func (_ *MockStateManager) Resume(_ context.Context, _ state.BeaconState) (state.BeaconState, error) {
|
2021-02-11 21:08:36 +00:00
|
|
|
panic("implement me")
|
|
|
|
}
|
|
|
|
|
|
|
|
// SaveFinalizedState --
|
2021-12-07 17:52:39 +00:00
|
|
|
func (_ *MockStateManager) SaveFinalizedState(_ types.Slot, _ [32]byte, _ state.BeaconState) {
|
2021-02-11 21:08:36 +00:00
|
|
|
panic("implement me")
|
|
|
|
}
|
|
|
|
|
|
|
|
// MigrateToCold --
|
2021-12-07 17:52:39 +00:00
|
|
|
func (_ *MockStateManager) MigrateToCold(_ context.Context, _ [32]byte) error {
|
2021-02-11 21:08:36 +00:00
|
|
|
panic("implement me")
|
|
|
|
}
|
|
|
|
|
|
|
|
// ReplayBlocks --
|
2021-12-07 17:52:39 +00:00
|
|
|
func (_ *MockStateManager) ReplayBlocks(
|
2021-09-20 20:51:59 +00:00
|
|
|
_ context.Context,
|
|
|
|
_ state.BeaconState,
|
|
|
|
_ []block.SignedBeaconBlock,
|
|
|
|
_ types.Slot,
|
2021-07-23 16:11:21 +00:00
|
|
|
) (state.BeaconState, error) {
|
2021-02-11 21:08:36 +00:00
|
|
|
panic("implement me")
|
|
|
|
}
|
|
|
|
|
|
|
|
// LoadBlocks --
|
2021-12-07 17:52:39 +00:00
|
|
|
func (_ *MockStateManager) LoadBlocks(
|
2021-09-20 20:51:59 +00:00
|
|
|
_ context.Context,
|
|
|
|
_, _ types.Slot,
|
|
|
|
_ [32]byte,
|
2021-07-23 20:10:15 +00:00
|
|
|
) ([]block.SignedBeaconBlock, error) {
|
2021-02-11 21:08:36 +00:00
|
|
|
panic("implement me")
|
|
|
|
}
|
|
|
|
|
|
|
|
// HasState --
|
2021-12-07 17:52:39 +00:00
|
|
|
func (_ *MockStateManager) HasState(_ context.Context, _ [32]byte) (bool, error) {
|
2021-02-11 21:08:36 +00:00
|
|
|
panic("implement me")
|
|
|
|
}
|
|
|
|
|
|
|
|
// HasStateInCache --
|
2021-12-07 17:52:39 +00:00
|
|
|
func (_ *MockStateManager) HasStateInCache(_ context.Context, _ [32]byte) (bool, error) {
|
2021-02-11 21:08:36 +00:00
|
|
|
panic("implement me")
|
|
|
|
}
|
|
|
|
|
|
|
|
// StateByRoot --
|
2021-09-20 20:51:59 +00:00
|
|
|
func (m *MockStateManager) StateByRoot(_ context.Context, blockRoot [32]byte) (state.BeaconState, error) {
|
2021-02-11 21:08:36 +00:00
|
|
|
return m.StatesByRoot[blockRoot], nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// StateByRootInitialSync --
|
2021-12-07 17:52:39 +00:00
|
|
|
func (_ *MockStateManager) StateByRootInitialSync(_ context.Context, _ [32]byte) (state.BeaconState, error) {
|
2021-02-11 21:08:36 +00:00
|
|
|
panic("implement me")
|
|
|
|
}
|
|
|
|
|
|
|
|
// StateBySlot --
|
2021-09-20 20:51:59 +00:00
|
|
|
func (m *MockStateManager) StateBySlot(_ context.Context, slot types.Slot) (state.BeaconState, error) {
|
2021-02-11 21:08:36 +00:00
|
|
|
return m.StatesBySlot[slot], nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// RecoverStateSummary --
|
2021-12-07 17:52:39 +00:00
|
|
|
func (_ *MockStateManager) RecoverStateSummary(
|
2021-09-20 20:51:59 +00:00
|
|
|
_ context.Context,
|
|
|
|
_ [32]byte,
|
2021-08-30 23:57:08 +00:00
|
|
|
) (*ethpb.StateSummary, error) {
|
2021-02-11 21:08:36 +00:00
|
|
|
panic("implement me")
|
|
|
|
}
|
|
|
|
|
|
|
|
// SaveState --
|
2021-12-07 17:52:39 +00:00
|
|
|
func (_ *MockStateManager) SaveState(_ context.Context, _ [32]byte, _ state.BeaconState) error {
|
2021-02-11 21:08:36 +00:00
|
|
|
panic("implement me")
|
|
|
|
}
|
|
|
|
|
|
|
|
// ForceCheckpoint --
|
2021-12-07 17:52:39 +00:00
|
|
|
func (_ *MockStateManager) ForceCheckpoint(_ context.Context, _ []byte) error {
|
2021-02-11 21:08:36 +00:00
|
|
|
panic("implement me")
|
|
|
|
}
|
|
|
|
|
|
|
|
// EnableSaveHotStateToDB --
|
2021-12-07 17:52:39 +00:00
|
|
|
func (_ *MockStateManager) EnableSaveHotStateToDB(_ context.Context) {
|
2021-02-11 21:08:36 +00:00
|
|
|
panic("implement me")
|
|
|
|
}
|
|
|
|
|
|
|
|
// DisableSaveHotStateToDB --
|
2021-12-07 17:52:39 +00:00
|
|
|
func (_ *MockStateManager) DisableSaveHotStateToDB(_ context.Context) error {
|
2021-02-11 21:08:36 +00:00
|
|
|
panic("implement me")
|
|
|
|
}
|
|
|
|
|
|
|
|
// AddStateForRoot --
|
2021-07-23 16:11:21 +00:00
|
|
|
func (m *MockStateManager) AddStateForRoot(state state.BeaconState, blockRoot [32]byte) {
|
2021-02-11 21:08:36 +00:00
|
|
|
m.StatesByRoot[blockRoot] = state
|
|
|
|
}
|
|
|
|
|
|
|
|
// AddStateForSlot --
|
2021-07-23 16:11:21 +00:00
|
|
|
func (m *MockStateManager) AddStateForSlot(state state.BeaconState, slot types.Slot) {
|
2021-02-11 21:08:36 +00:00
|
|
|
m.StatesBySlot[slot] = state
|
|
|
|
}
|