Documentation
¶
Overview ¶
Package validatorsmock provides mock implementations for validator management
Index ¶
- type MockValidatorSet
- func (m *MockValidatorSet) AddValidator(nodeID ids.NodeID, weight uint64)
- func (m *MockValidatorSet) Contains(nodeID ids.NodeID) bool
- func (m *MockValidatorSet) GetValidators(ctx context.Context) []Validator
- func (m *MockValidatorSet) GetWeight(nodeID ids.NodeID) uint64
- func (m *MockValidatorSet) Size() int
- type State
- func (s *State) GetChainID(chainID ids.ID) (ids.ID, error)
- func (s *State) GetCurrentHeight(ctx context.Context) (uint64, error)
- func (s *State) GetMinimumHeight(ctx context.Context) (uint64, error)
- func (s *State) GetNetID(ctx context.Context, chainID ids.ID) (ids.ID, error)
- func (s *State) GetValidatorSet(ctx context.Context, height uint64, subnetID ids.ID) ([]Validator, error)
- func (s *State) SetChainID(chainID ids.ID)
- func (s *State) SetHeight(height uint64)
- func (s *State) SetMinimumHeight(height uint64)
- func (s *State) SetValidatorSet(height uint64, validators []Validator)
- type Validator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MockValidatorSet ¶
type MockValidatorSet struct {
// contains filtered or unexported fields
}
MockValidatorSet provides a mock implementation for validator sets
func NewMockValidatorSet ¶
func NewMockValidatorSet() *MockValidatorSet
NewMockValidatorSet creates a new mock validator set
func (*MockValidatorSet) AddValidator ¶
func (m *MockValidatorSet) AddValidator(nodeID ids.NodeID, weight uint64)
AddValidator adds a validator to the set
func (*MockValidatorSet) Contains ¶
func (m *MockValidatorSet) Contains(nodeID ids.NodeID) bool
Contains checks if a node is a validator
func (*MockValidatorSet) GetValidators ¶
func (m *MockValidatorSet) GetValidators(ctx context.Context) []Validator
GetValidators returns all validators
func (*MockValidatorSet) GetWeight ¶
func (m *MockValidatorSet) GetWeight(nodeID ids.NodeID) uint64
GetWeight returns the weight of a validator
func (*MockValidatorSet) Size ¶
func (m *MockValidatorSet) Size() int
Size returns the number of validators
type State ¶
type State struct {
T *testing.T
// Function fields that can be overridden
GetNetIDF func(context.Context, ids.ID) (ids.ID, error)
GetCurrentHeightF func(context.Context) (uint64, error)
GetMinimumHeightF func(context.Context) (uint64, error)
GetValidatorSetF func(context.Context, uint64, ids.ID) ([]Validator, error)
GetChainIDF func(ids.ID) (ids.ID, error)
// contains filtered or unexported fields
}
State provides a mock implementation for validator state
func (*State) GetChainID ¶
GetChainID returns the chain ID for a given chain
func (*State) GetCurrentHeight ¶
GetCurrentHeight returns the current height
func (*State) GetMinimumHeight ¶
GetMinimumHeight returns the minimum height
func (*State) GetValidatorSet ¶
func (s *State) GetValidatorSet(ctx context.Context, height uint64, subnetID ids.ID) ([]Validator, error)
GetValidatorSet returns the validator set at a given height and subnet
func (*State) SetMinimumHeight ¶
SetMinimumHeight sets the minimum height
func (*State) SetValidatorSet ¶
SetValidatorSet sets the validator set at a given height