validatorsmock

package
v1.19.14 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 4, 2025 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Overview

Package validatorsmock provides mock implementations for validator management

Index

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 NewState

func NewState(t *testing.T) *State

NewState creates a new mock validator state

func (*State) GetChainID

func (s *State) GetChainID(chainID ids.ID) (ids.ID, error)

GetChainID returns the chain ID for a given chain

func (*State) GetCurrentHeight

func (s *State) GetCurrentHeight(ctx context.Context) (uint64, error)

GetCurrentHeight returns the current height

func (*State) GetMinimumHeight

func (s *State) GetMinimumHeight(ctx context.Context) (uint64, error)

GetMinimumHeight returns the minimum height

func (*State) GetNetID

func (s *State) GetNetID(ctx context.Context, chainID ids.ID) (ids.ID, error)

GetNetID returns the network ID for a given chain

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) SetChainID

func (s *State) SetChainID(chainID ids.ID)

SetChainID sets the chain ID

func (*State) SetHeight

func (s *State) SetHeight(height uint64)

SetHeight sets the current height

func (*State) SetMinimumHeight

func (s *State) SetMinimumHeight(height uint64)

SetMinimumHeight sets the minimum height

func (*State) SetValidatorSet

func (s *State) SetValidatorSet(height uint64, validators []Validator)

SetValidatorSet sets the validator set at a given height

type Validator

type Validator struct {
	ID     ids.NodeID
	Weight uint64
}

Validator represents a validator

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL