2022-01-26 14:48:20 +00:00
|
|
|
package mock
|
2021-02-11 21:08:36 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
2022-08-16 12:20:13 +00:00
|
|
|
"github.com/prysmaticlabs/prysm/v3/beacon-chain/state"
|
|
|
|
types "github.com/prysmaticlabs/prysm/v3/consensus-types/primitives"
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-19 04:38:04 +00:00
|
|
|
// StateByRootIfCachedNoCopy --
|
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")
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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")
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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
|
|
|
|
}
|
|
|
|
|
2022-09-30 09:39:07 +00:00
|
|
|
// BalancesByRoot --
|
|
|
|
func (*MockStateManager) BalancesByRoot(_ context.Context, _ [32]byte) ([]uint64, error) {
|
|
|
|
return []uint64{}, nil
|
|
|
|
}
|
|
|
|
|
2021-02-11 21:08:36 +00:00
|
|
|
// 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
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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
|
|
|
|
}
|
2022-04-06 21:24:00 +00:00
|
|
|
|
|
|
|
// DeleteStateFromCaches --
|
|
|
|
func (m *MockStateManager) DeleteStateFromCaches(context.Context, [32]byte) error {
|
|
|
|
return nil
|
|
|
|
}
|