shardingMocks

package
v1.7.13 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2024 License: GPL-3.0 Imports: 7 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)
	GetAllShuffledOutValidatorsPublicKeysCalled       func(epoch uint32) (map[uint32][][]byte, error)
	GetShuffledOutToAuctionValidatorsPublicKeysCalled func(epoch uint32) (map[uint32][][]byte, error)
	GetNumTotalEligibleCalled                         func() uint64
}

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) GetAllShuffledOutValidatorsPublicKeys added in v1.7.0

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

GetAllShuffledOutValidatorsPublicKeys -

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) GetShuffledOutToAuctionValidatorsPublicKeys added in v1.7.11

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

GetShuffledOutToAuctionValidatorsPublicKeys -

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) GetWaitingEpochsLeftForPublicKey added in v1.7.0

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

GetWaitingEpochsLeftForPublicKey always returns 0

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 NodesCoordinatorRegistryFactoryMock added in v1.7.0

type NodesCoordinatorRegistryFactoryMock struct {
}

NodesCoordinatorRegistryFactoryMock -

func (*NodesCoordinatorRegistryFactoryMock) CreateNodesCoordinatorRegistry added in v1.7.0

CreateNodesCoordinatorRegistry -

func (*NodesCoordinatorRegistryFactoryMock) GetRegistryData added in v1.7.0

GetRegistryData -

func (*NodesCoordinatorRegistryFactoryMock) IsInterfaceNil added in v1.7.0

func (ncr *NodesCoordinatorRegistryFactoryMock) IsInterfaceNil() bool

IsInterfaceNil -

type NodesCoordinatorStub

type NodesCoordinatorStub struct {
	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
	GetWaitingEpochsLeftForPublicKeyCalled   func(publicKey []byte) (uint32, error)
	GetNumTotalEligibleCalled                func() uint64
}

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) GetAllShuffledOutValidatorsPublicKeys added in v1.7.0

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

GetAllShuffledOutValidatorsPublicKeys -

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) GetShuffledOutToAuctionValidatorsPublicKeys added in v1.7.11

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

GetShuffledOutToAuctionValidatorsPublicKeys -

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) GetWaitingEpochsLeftForPublicKey added in v1.7.0

func (ncm *NodesCoordinatorStub) GetWaitingEpochsLeftForPublicKey(publicKey []byte) (uint32, error)

GetWaitingEpochsLeftForPublicKey -

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

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