github.com/prysmaticlabs/prysm@v1.4.4/beacon-chain/state/stategen/mock.go (about)

     1  package stategen
     2  
     3  import (
     4  	"context"
     5  
     6  	types "github.com/prysmaticlabs/eth2-types"
     7  	iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface"
     8  	ethereum_beacon_p2p_v1 "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
     9  	"github.com/prysmaticlabs/prysm/proto/interfaces"
    10  )
    11  
    12  // MockStateManager is a fake implementation of StateManager.
    13  type MockStateManager struct {
    14  	StatesByRoot map[[32]byte]iface.BeaconState
    15  	StatesBySlot map[types.Slot]iface.BeaconState
    16  }
    17  
    18  // NewMockService --
    19  func NewMockService() *MockStateManager {
    20  	return &MockStateManager{
    21  		StatesByRoot: make(map[[32]byte]iface.BeaconState),
    22  		StatesBySlot: make(map[types.Slot]iface.BeaconState),
    23  	}
    24  }
    25  
    26  // Resume --
    27  func (m *MockStateManager) Resume(ctx context.Context) (iface.BeaconState, error) {
    28  	panic("implement me")
    29  }
    30  
    31  // SaveFinalizedState --
    32  func (m *MockStateManager) SaveFinalizedState(fSlot types.Slot, fRoot [32]byte, fState iface.BeaconState) {
    33  	panic("implement me")
    34  }
    35  
    36  // MigrateToCold --
    37  func (m *MockStateManager) MigrateToCold(ctx context.Context, fRoot [32]byte) error {
    38  	panic("implement me")
    39  }
    40  
    41  // ReplayBlocks --
    42  func (m *MockStateManager) ReplayBlocks(
    43  	ctx context.Context,
    44  	state iface.BeaconState,
    45  	signed []interfaces.SignedBeaconBlock,
    46  	targetSlot types.Slot,
    47  ) (iface.BeaconState, error) {
    48  	panic("implement me")
    49  }
    50  
    51  // LoadBlocks --
    52  func (m *MockStateManager) LoadBlocks(
    53  	ctx context.Context,
    54  	startSlot, endSlot types.Slot,
    55  	endBlockRoot [32]byte,
    56  ) ([]interfaces.SignedBeaconBlock, error) {
    57  	panic("implement me")
    58  }
    59  
    60  // HasState --
    61  func (m *MockStateManager) HasState(ctx context.Context, blockRoot [32]byte) (bool, error) {
    62  	panic("implement me")
    63  }
    64  
    65  // HasStateInCache --
    66  func (m *MockStateManager) HasStateInCache(ctx context.Context, blockRoot [32]byte) (bool, error) {
    67  	panic("implement me")
    68  }
    69  
    70  // StateByRoot --
    71  func (m *MockStateManager) StateByRoot(ctx context.Context, blockRoot [32]byte) (iface.BeaconState, error) {
    72  	return m.StatesByRoot[blockRoot], nil
    73  }
    74  
    75  // StateByRootInitialSync --
    76  func (m *MockStateManager) StateByRootInitialSync(ctx context.Context, blockRoot [32]byte) (iface.BeaconState, error) {
    77  	panic("implement me")
    78  }
    79  
    80  // StateBySlot --
    81  func (m *MockStateManager) StateBySlot(ctx context.Context, slot types.Slot) (iface.BeaconState, error) {
    82  	return m.StatesBySlot[slot], nil
    83  }
    84  
    85  // RecoverStateSummary --
    86  func (m *MockStateManager) RecoverStateSummary(
    87  	ctx context.Context,
    88  	blockRoot [32]byte,
    89  ) (*ethereum_beacon_p2p_v1.StateSummary, error) {
    90  	panic("implement me")
    91  }
    92  
    93  // SaveState --
    94  func (m *MockStateManager) SaveState(ctx context.Context, root [32]byte, st iface.BeaconState) error {
    95  	panic("implement me")
    96  }
    97  
    98  // ForceCheckpoint --
    99  func (m *MockStateManager) ForceCheckpoint(ctx context.Context, root []byte) error {
   100  	panic("implement me")
   101  }
   102  
   103  // EnableSaveHotStateToDB --
   104  func (m *MockStateManager) EnableSaveHotStateToDB(_ context.Context) {
   105  	panic("implement me")
   106  }
   107  
   108  // DisableSaveHotStateToDB --
   109  func (m *MockStateManager) DisableSaveHotStateToDB(ctx context.Context) error {
   110  	panic("implement me")
   111  }
   112  
   113  // AddStateForRoot --
   114  func (m *MockStateManager) AddStateForRoot(state iface.BeaconState, blockRoot [32]byte) {
   115  	m.StatesByRoot[blockRoot] = state
   116  }
   117  
   118  // AddStateForSlot --
   119  func (m *MockStateManager) AddStateForSlot(state iface.BeaconState, slot types.Slot) {
   120  	m.StatesBySlot[slot] = state
   121  }