shardingMocks

package
v1.6.3 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2023 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type NodeInfoMock

type NodeInfoMock struct {
	// contains filtered or unexported fields
}

NodeInfoMock -

func NewNodeInfo

func NewNodeInfo(address []byte, pubKey []byte, shardId uint32, initialRating uint32) *NodeInfoMock

NewNodeInfo -

func (*NodeInfoMock) AddressBytes

func (n *NodeInfoMock) AddressBytes() []byte

AddressBytes -

func (*NodeInfoMock) AssignedShard

func (n *NodeInfoMock) AssignedShard() uint32

AssignedShard -

func (*NodeInfoMock) GetInitialRating

func (n *NodeInfoMock) GetInitialRating() uint32

GetInitialRating -

func (*NodeInfoMock) IsInterfaceNil

func (n *NodeInfoMock) IsInterfaceNil() bool

IsInterfaceNil -

func (*NodeInfoMock) PubKeyBytes

func (n *NodeInfoMock) PubKeyBytes() []byte

PubKeyBytes -

type NodeShufflerMock

type NodeShufflerMock struct {
}

NodeShufflerMock -

func (*NodeShufflerMock) IsInterfaceNil

func (nsm *NodeShufflerMock) IsInterfaceNil() bool

IsInterfaceNil -

func (*NodeShufflerMock) UpdateNodeLists

UpdateNodeLists -

func (*NodeShufflerMock) UpdateParams

func (nsm *NodeShufflerMock) UpdateParams(
	_ uint32,
	_ uint32,
	_ float32,
	_ bool,
)

UpdateParams -

type NodesCoordinatorMock

type NodesCoordinatorMock struct {
	Validators                               map[uint32][]nodesCoordinator.Validator
	ShardConsensusSize                       uint32
	MetaConsensusSize                        uint32
	ShardId                                  uint32
	NbShards                                 uint32
	GetSelectedPublicKeysCalled              func(selection []byte, shardId uint32, epoch uint32) (publicKeys []string, err error)
	GetValidatorsPublicKeysCalled            func(randomness []byte, round uint64, shardId uint32, epoch uint32) ([]string, error)
	GetValidatorsRewardsAddressesCalled      func(randomness []byte, round uint64, shardId uint32, epoch uint32) ([]string, error)
	SetNodesPerShardsCalled                  func(nodes map[uint32][]nodesCoordinator.Validator, epoch uint32) error
	ComputeValidatorsGroupCalled             func(randomness []byte, round uint64, shardId uint32, epoch uint32) (validatorsGroup []nodesCoordinator.Validator, err error)
	GetValidatorWithPublicKeyCalled          func(publicKey []byte) (validator nodesCoordinator.Validator, shardId uint32, err error)
	GetAllEligibleValidatorsPublicKeysCalled func(epoch uint32) (map[uint32][][]byte, error)
	GetAllWaitingValidatorsPublicKeysCalled  func() (map[uint32][][]byte, error)
	ConsensusGroupSizeCalled                 func(uint32) int
	GetValidatorsIndexesCalled               func(publicKeys []string, epoch uint32) ([]uint64, error)
}

NodesCoordinatorMock defines the behaviour of a struct able to do validator group selection

func NewNodesCoordinatorMock

func NewNodesCoordinatorMock() *NodesCoordinatorMock

NewNodesCoordinatorMock -

func (*NodesCoordinatorMock) ComputeAdditionalLeaving

func (ncm *NodesCoordinatorMock) ComputeAdditionalLeaving(_ []*state.ShardValidatorInfo) (map[uint32][]nodesCoordinator.Validator, error)

ComputeAdditionalLeaving -

func (*NodesCoordinatorMock) ComputeConsensusGroup

func (ncm *NodesCoordinatorMock) ComputeConsensusGroup(
	randomess []byte,
	round uint64,
	shardId uint32,
	epoch uint32,
) ([]nodesCoordinator.Validator, error)

ComputeConsensusGroup -

func (*NodesCoordinatorMock) ConsensusGroupSize

func (ncm *NodesCoordinatorMock) ConsensusGroupSize(shardId uint32) int

ConsensusGroupSize -

func (*NodesCoordinatorMock) GetAllEligibleValidatorsPublicKeys

func (ncm *NodesCoordinatorMock) GetAllEligibleValidatorsPublicKeys(epoch uint32) (map[uint32][][]byte, error)

GetAllEligibleValidatorsPublicKeys -

func (*NodesCoordinatorMock) GetAllLeavingValidatorsPublicKeys

func (ncm *NodesCoordinatorMock) GetAllLeavingValidatorsPublicKeys(_ uint32) (map[uint32][][]byte, error)

GetAllLeavingValidatorsPublicKeys -

func (*NodesCoordinatorMock) GetAllWaitingValidatorsPublicKeys

func (ncm *NodesCoordinatorMock) GetAllWaitingValidatorsPublicKeys(_ uint32) (map[uint32][][]byte, error)

GetAllWaitingValidatorsPublicKeys -

func (*NodesCoordinatorMock) GetChance

func (ncm *NodesCoordinatorMock) GetChance(uint32) uint32

GetChance -

func (*NodesCoordinatorMock) GetConsensusValidatorsPublicKeys

func (ncm *NodesCoordinatorMock) GetConsensusValidatorsPublicKeys(
	randomness []byte,
	round uint64,
	shardId uint32,
	epoch uint32,
) ([]string, error)

GetConsensusValidatorsPublicKeys -

func (*NodesCoordinatorMock) GetConsensusWhitelistedNodes

func (ncm *NodesCoordinatorMock) GetConsensusWhitelistedNodes(
	_ uint32,
) (map[string]struct{}, error)

GetConsensusWhitelistedNodes return the whitelisted nodes allowed to send consensus messages, for each of the shards

func (*NodesCoordinatorMock) GetNumTotalEligible

func (ncm *NodesCoordinatorMock) GetNumTotalEligible() uint64

GetNumTotalEligible -

func (*NodesCoordinatorMock) GetOwnPublicKey

func (ncm *NodesCoordinatorMock) GetOwnPublicKey() []byte

GetOwnPublicKey -

func (*NodesCoordinatorMock) GetSavedStateKey

func (ncm *NodesCoordinatorMock) GetSavedStateKey() []byte

GetSavedStateKey -

func (*NodesCoordinatorMock) GetSelectedPublicKeys

func (ncm *NodesCoordinatorMock) GetSelectedPublicKeys(selection []byte, shardId uint32, epoch uint32) (publicKeys []string, err error)

GetSelectedPublicKeys -

func (*NodesCoordinatorMock) GetValidatorWithPublicKey

func (ncm *NodesCoordinatorMock) GetValidatorWithPublicKey(publicKey []byte) (nodesCoordinator.Validator, uint32, error)

GetValidatorWithPublicKey -

func (*NodesCoordinatorMock) GetValidatorsIndexes

func (ncm *NodesCoordinatorMock) GetValidatorsIndexes(publicKeys []string, epoch uint32) ([]uint64, error)

GetValidatorsIndexes -

func (*NodesCoordinatorMock) IsInterfaceNil

func (ncm *NodesCoordinatorMock) IsInterfaceNil() bool

IsInterfaceNil -

func (*NodesCoordinatorMock) LoadState

func (ncm *NodesCoordinatorMock) LoadState(_ []byte) error

LoadState -

func (*NodesCoordinatorMock) SetNodesPerShards

func (ncm *NodesCoordinatorMock) SetNodesPerShards(
	eligible map[uint32][]nodesCoordinator.Validator,
	_ map[uint32][]nodesCoordinator.Validator,
	epoch uint32,
) error

SetNodesPerShards -

func (*NodesCoordinatorMock) ShardIdForEpoch

func (ncm *NodesCoordinatorMock) ShardIdForEpoch(_ uint32) (uint32, error)

ShardIdForEpoch returns the nodesCoordinator configured ShardId for specified epoch if epoch configuration exists, otherwise error

func (*NodesCoordinatorMock) ShuffleOutForEpoch

func (ncm *NodesCoordinatorMock) ShuffleOutForEpoch(_ uint32)

ShuffleOutForEpoch verifies if the shards changed in the new epoch and calls the shuffleOutHandler

func (*NodesCoordinatorMock) ValidatorsWeights

func (ncm *NodesCoordinatorMock) ValidatorsWeights(validators []nodesCoordinator.Validator) ([]uint32, error)

ValidatorsWeights -

type NodesCoordinatorStub

type NodesCoordinatorStub struct {
	ComputeValidatorsGroupCalled             func(randomness []byte, round uint64, shardId uint32, epoch uint32) ([]nodesCoordinator.Validator, error)
	GetValidatorsPublicKeysCalled            func(randomness []byte, round uint64, shardId uint32, epoch uint32) ([]string, error)
	GetValidatorsRewardsAddressesCalled      func(randomness []byte, round uint64, shardId uint32, epoch uint32) ([]string, error)
	GetValidatorWithPublicKeyCalled          func(publicKey []byte) (validator nodesCoordinator.Validator, shardId uint32, err error)
	GetAllValidatorsPublicKeysCalled         func() (map[uint32][][]byte, error)
	GetAllWaitingValidatorsPublicKeysCalled  func(_ uint32) (map[uint32][][]byte, error)
	GetAllEligibleValidatorsPublicKeysCalled func(epoch uint32) (map[uint32][][]byte, error)
	ConsensusGroupSizeCalled                 func(shardID uint32) int
	ComputeConsensusGroupCalled              func(randomness []byte, round uint64, shardId uint32, epoch uint32) (validatorsGroup []nodesCoordinator.Validator, err error)
	EpochStartPrepareCalled                  func(metaHdr data.HeaderHandler, body data.BodyHandler)
	GetConsensusWhitelistedNodesCalled       func(epoch uint32) (map[string]struct{}, error)
	GetOwnPublicKeyCalled                    func() []byte
}

NodesCoordinatorStub -

func (*NodesCoordinatorStub) ComputeAdditionalLeaving

func (ncm *NodesCoordinatorStub) ComputeAdditionalLeaving(_ []*state.ShardValidatorInfo) (map[uint32][]nodesCoordinator.Validator, error)

ComputeAdditionalLeaving -

func (*NodesCoordinatorStub) ComputeConsensusGroup

func (ncm *NodesCoordinatorStub) ComputeConsensusGroup(
	randomness []byte,
	round uint64,
	shardId uint32,
	epoch uint32,
) (validatorsGroup []nodesCoordinator.Validator, err error)

ComputeConsensusGroup -

func (*NodesCoordinatorStub) ConsensusGroupSize

func (ncm *NodesCoordinatorStub) ConsensusGroupSize(shardID uint32) int

ConsensusGroupSize -

func (*NodesCoordinatorStub) EpochStartPrepare

func (ncm *NodesCoordinatorStub) EpochStartPrepare(metaHdr data.HeaderHandler, body data.BodyHandler)

EpochStartPrepare -

func (*NodesCoordinatorStub) GetAllEligibleValidatorsPublicKeys

func (ncm *NodesCoordinatorStub) GetAllEligibleValidatorsPublicKeys(epoch uint32) (map[uint32][][]byte, error)

GetAllEligibleValidatorsPublicKeys -

func (*NodesCoordinatorStub) GetAllLeavingValidatorsPublicKeys

func (ncm *NodesCoordinatorStub) GetAllLeavingValidatorsPublicKeys(_ uint32) (map[uint32][][]byte, error)

GetAllLeavingValidatorsPublicKeys -

func (*NodesCoordinatorStub) GetAllValidatorsPublicKeys

func (ncm *NodesCoordinatorStub) GetAllValidatorsPublicKeys(_ uint32) (map[uint32][][]byte, error)

GetAllValidatorsPublicKeys -

func (*NodesCoordinatorStub) GetAllWaitingValidatorsPublicKeys

func (ncm *NodesCoordinatorStub) GetAllWaitingValidatorsPublicKeys(epoch uint32) (map[uint32][][]byte, error)

GetAllWaitingValidatorsPublicKeys -

func (*NodesCoordinatorStub) GetChance

func (ncm *NodesCoordinatorStub) GetChance(uint32) uint32

GetChance -

func (*NodesCoordinatorStub) GetConsensusValidatorsPublicKeys

func (ncm *NodesCoordinatorStub) GetConsensusValidatorsPublicKeys(
	randomness []byte,
	round uint64,
	shardId uint32,
	epoch uint32,
) ([]string, error)

GetConsensusValidatorsPublicKeys -

func (*NodesCoordinatorStub) GetConsensusWhitelistedNodes

func (ncm *NodesCoordinatorStub) GetConsensusWhitelistedNodes(epoch uint32) (map[string]struct{}, error)

GetConsensusWhitelistedNodes return the whitelisted nodes allowed to send consensus messages, for each of the shards

func (*NodesCoordinatorStub) GetNumTotalEligible

func (ncm *NodesCoordinatorStub) GetNumTotalEligible() uint64

GetNumTotalEligible -

func (*NodesCoordinatorStub) GetOwnPublicKey

func (ncm *NodesCoordinatorStub) GetOwnPublicKey() []byte

GetOwnPublicKey -

func (*NodesCoordinatorStub) GetSavedStateKey

func (ncm *NodesCoordinatorStub) GetSavedStateKey() []byte

GetSavedStateKey -

func (*NodesCoordinatorStub) GetSelectedPublicKeys

func (ncm *NodesCoordinatorStub) GetSelectedPublicKeys(_ []byte, _ uint32, _ uint32) ([]string, error)

GetSelectedPublicKeys -

func (*NodesCoordinatorStub) GetValidatorWithPublicKey

func (ncm *NodesCoordinatorStub) GetValidatorWithPublicKey(publicKey []byte) (nodesCoordinator.Validator, uint32, error)

GetValidatorWithPublicKey -

func (*NodesCoordinatorStub) GetValidatorsIndexes

func (ncm *NodesCoordinatorStub) GetValidatorsIndexes(_ []string, _ uint32) ([]uint64, error)

GetValidatorsIndexes -

func (*NodesCoordinatorStub) IsInterfaceNil

func (ncm *NodesCoordinatorStub) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

func (*NodesCoordinatorStub) LoadState

func (ncm *NodesCoordinatorStub) LoadState(_ []byte) error

LoadState -

func (*NodesCoordinatorStub) NodesCoordinatorToRegistry

func (ncm *NodesCoordinatorStub) NodesCoordinatorToRegistry() *nodesCoordinator.NodesCoordinatorRegistry

NodesCoordinatorToRegistry -

func (*NodesCoordinatorStub) SetConfig

SetConfig -

func (*NodesCoordinatorStub) SetNodesPerShards

SetNodesPerShards -

func (*NodesCoordinatorStub) ShardIdForEpoch

func (ncm *NodesCoordinatorStub) ShardIdForEpoch(_ uint32) (uint32, error)

ShardIdForEpoch returns the nodesCoordinator configured ShardId for specified epoch if epoch configuration exists, otherwise error

func (*NodesCoordinatorStub) ShuffleOutForEpoch

func (ncm *NodesCoordinatorStub) ShuffleOutForEpoch(_ uint32)

ShuffleOutForEpoch verifies if the shards changed in the new epoch and calls the shuffleOutHandler

func (*NodesCoordinatorStub) ValidatorsWeights

func (ncm *NodesCoordinatorStub) ValidatorsWeights(_ []nodesCoordinator.Validator) ([]uint32, error)

ValidatorsWeights -

type ValidatorMock

type ValidatorMock struct {
	PubKeyCalled func() []byte
	// contains filtered or unexported fields
}

ValidatorMock defines a mocked validator

func NewValidatorMock

func NewValidatorMock(pubKey []byte, chances uint32, index uint32) *ValidatorMock

NewValidatorMock creates a new instance of a validator

func (*ValidatorMock) Chances

func (v *ValidatorMock) Chances() uint32

Chances returns the validator's chances

func (*ValidatorMock) Index

func (v *ValidatorMock) Index() uint32

Index returns the validators index

func (*ValidatorMock) IsInterfaceNil

func (v *ValidatorMock) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

func (*ValidatorMock) PubKey

func (v *ValidatorMock) PubKey() []byte

PubKey returns the validator's public key

func (*ValidatorMock) Size

func (v *ValidatorMock) Size() int

Size -

Jump to

Keyboard shortcuts

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