mock

package
v1.0.108 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2020 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrMockMarshalizer = errors.New("MarshalizerMock generic error")

ErrMockMarshalizer -

View Source
var ErrNilObjectToMarshal = errors.New("nil object to serialize from")

ErrNilObjectToMarshal -

Functions

This section is empty.

Types

type AppStatusHandlerStub

type AppStatusHandlerStub struct {
	AddUint64Handler      func(key string, value uint64)
	IncrementHandler      func(key string)
	DecrementHandler      func(key string)
	SetUInt64ValueHandler func(key string, value uint64)
	SetInt64ValueHandler  func(key string, value int64)
	SetStringValueHandler func(key string, value string)
	CloseHandler          func()
}

AppStatusHandlerStub is a stub implementation of AppStatusHandler

func (*AppStatusHandlerStub) AddUint64

func (ashs *AppStatusHandlerStub) AddUint64(key string, value uint64)

AddUint64 will call the handler of the stub for incrementing

func (*AppStatusHandlerStub) Close

func (ashs *AppStatusHandlerStub) Close()

Close will call the handler of the stub for closing

func (*AppStatusHandlerStub) Decrement

func (ashs *AppStatusHandlerStub) Decrement(key string)

Decrement will call the handler of the stub for decrementing

func (*AppStatusHandlerStub) Increment

func (ashs *AppStatusHandlerStub) Increment(key string)

Increment will call the handler of the stub for incrementing

func (*AppStatusHandlerStub) IsInterfaceNil

func (ashs *AppStatusHandlerStub) IsInterfaceNil() bool

IsInterfaceNil -

func (*AppStatusHandlerStub) SetInt64Value

func (ashs *AppStatusHandlerStub) SetInt64Value(key string, value int64)

SetInt64Value will call the handler of the stub for setting an int64 value

func (*AppStatusHandlerStub) SetStringValue

func (ashs *AppStatusHandlerStub) SetStringValue(key string, value string)

SetStringValue will call the handler of the stub for setting an string value

func (*AppStatusHandlerStub) SetUInt64Value

func (ashs *AppStatusHandlerStub) SetUInt64Value(key string, value uint64)

SetUInt64Value will call the handler of the stub for setting an uint64 value

type ChainStorerMock

type ChainStorerMock struct {
	AddStorerCalled func(key dataRetriever.UnitType, s storage.Storer)
	GetStorerCalled func(unitType dataRetriever.UnitType) storage.Storer
	HasCalled       func(unitType dataRetriever.UnitType, key []byte) (bool, error)
	GetCalled       func(unitType dataRetriever.UnitType, key []byte) ([]byte, error)
	PutCalled       func(unitType dataRetriever.UnitType, key []byte, value []byte) error
	GetAllCalled    func(unitType dataRetriever.UnitType, keys [][]byte) (map[string][]byte, error)
	DestroyCalled   func() error
}

ChainStorerMock is a mock implementation of the ChainStorer interface

func (*ChainStorerMock) AddStorer

func (bc *ChainStorerMock) AddStorer(key dataRetriever.UnitType, s storage.Storer)

AddStorer will add a new storer to the chain map

func (*ChainStorerMock) Destroy

func (bc *ChainStorerMock) Destroy() error

Destroy removes the underlying files/resources used by the storage service

func (*ChainStorerMock) Get

func (bc *ChainStorerMock) Get(unitType dataRetriever.UnitType, key []byte) ([]byte, error)

Get returns the value for the given key if found in the selected storage unit, nil otherwise. It can return an error if the provided unit type is not supported or if the storage unit underlying implementation reports an error

func (*ChainStorerMock) GetAll

func (bc *ChainStorerMock) GetAll(unitType dataRetriever.UnitType, keys [][]byte) (map[string][]byte, error)

GetAll gets all the elements with keys in the keys array, from the selected storage unit It can report an error if the provided unit type is not supported, if there is a missing key in the unit, or if the underlying implementation of the storage unit reports an error.

func (*ChainStorerMock) GetStorer

func (bc *ChainStorerMock) GetStorer(unitType dataRetriever.UnitType) storage.Storer

GetStorer returns the storer from the chain map or nil if the storer was not found

func (*ChainStorerMock) Has

func (bc *ChainStorerMock) Has(unitType dataRetriever.UnitType, key []byte) (bool, error)

Has returns true if the key is found in the selected Unit or false otherwise It can return an error if the provided unit type is not supported or if the underlying implementation of the storage unit reports an error.

func (*ChainStorerMock) Put

func (bc *ChainStorerMock) Put(unitType dataRetriever.UnitType, key []byte, value []byte) error

Put stores the key, value pair in the selected storage unit It can return an error if the provided unit type is not supported or if the storage unit underlying implementation reports an error

type ConnectedAddressesMock

type ConnectedAddressesMock struct {
}

ConnectedAddressesMock represents a mock implementation of the ConnectedAddresses

func (*ConnectedAddressesMock) ConnectedAddresses

func (cam *ConnectedAddressesMock) ConnectedAddresses() []string

ConnectedAddresses returns an empty slice of string

type DatabaseWriterStub

type DatabaseWriterStub struct {
	DoRequestCalled     func(req *esapi.IndexRequest) error
	DoBulkRequestCalled func(buff *bytes.Buffer, index string) error
}

DatabaseWriterStub --

func (*DatabaseWriterStub) CheckAndCreateIndex

func (dwm *DatabaseWriterStub) CheckAndCreateIndex(_ string, _ io.Reader) error

CheckAndCreateIndex --

func (*DatabaseWriterStub) DoBulkRequest

func (dwm *DatabaseWriterStub) DoBulkRequest(buff *bytes.Buffer, index string) error

DoBulkRequest --

func (*DatabaseWriterStub) DoRequest

func (dwm *DatabaseWriterStub) DoRequest(req *esapi.IndexRequest) error

DoRequest --

type EpochStartNotifierStub added in v0.0.5

type EpochStartNotifierStub struct {
	RegisterHandlerCalled   func(handler epochStart.ActionHandler)
	UnregisterHandlerCalled func(handler epochStart.ActionHandler)
	NotifyAllCalled         func(hdr data.HeaderHandler)
	NotifyAllPrepareCalled  func(hdr data.HeaderHandler)
	// contains filtered or unexported fields
}

EpochStartNotifierStub -

func (*EpochStartNotifierStub) IsInterfaceNil added in v0.0.5

func (esnm *EpochStartNotifierStub) IsInterfaceNil() bool

IsInterfaceNil -

func (*EpochStartNotifierStub) NotifyAll added in v0.0.5

func (esnm *EpochStartNotifierStub) NotifyAll(hdr data.HeaderHandler)

NotifyAll -

func (*EpochStartNotifierStub) NotifyAllPrepare added in v0.0.5

func (esnm *EpochStartNotifierStub) NotifyAllPrepare(metaHeader data.HeaderHandler, body data.BodyHandler)

NotifyAllPrepare -

func (*EpochStartNotifierStub) RegisterHandler added in v0.0.5

func (esnm *EpochStartNotifierStub) RegisterHandler(handler epochStart.ActionHandler)

RegisterHandler -

func (*EpochStartNotifierStub) UnregisterHandler added in v0.0.5

func (esnm *EpochStartNotifierStub) UnregisterHandler(handler epochStart.ActionHandler)

UnregisterHandler -

type HasherMock

type HasherMock struct {
}

HasherMock that will be used for testing

func (HasherMock) Compute

func (sha HasherMock) Compute(s string) []byte

Compute will output the SHA's equivalent of the input string

func (HasherMock) EmptyHash

func (sha HasherMock) EmptyHash() []byte

EmptyHash will return the equivalent of empty string SHA's

func (HasherMock) IsInterfaceNil

func (sha HasherMock) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

func (HasherMock) Size

func (HasherMock) Size() int

Size returns the required size in bytes

type MarshalizerMock

type MarshalizerMock struct {
	Fail bool
}

MarshalizerMock that will be used for testing

func (*MarshalizerMock) IsInterfaceNil

func (mm *MarshalizerMock) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

func (*MarshalizerMock) Marshal

func (mm *MarshalizerMock) Marshal(obj interface{}) ([]byte, error)

Marshal converts the input object in a slice of bytes

func (*MarshalizerMock) Unmarshal

func (mm *MarshalizerMock) Unmarshal(obj interface{}, buff []byte) error

Unmarshal applies the serialized values over an instantiated object

type NodesCoordinatorMock added in v0.0.5

type NodesCoordinatorMock struct {
	Validators                               map[uint32][]sharding.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][]sharding.Validator, epoch uint32) error
	ComputeValidatorsGroupCalled             func(randomness []byte, round uint64, shardId uint32, epoch uint32) (validatorsGroup []sharding.Validator, err error)
	GetValidatorWithPublicKeyCalled          func(publicKey []byte, epoch uint32) (validator sharding.Validator, shardId uint32, err error)
	GetAllEligibleValidatorsPublicKeysCalled func(epoch uint32) (map[uint32][][]byte, error)
	GetAllWaitingValidatorsPublicKeysCalled  func() (map[uint32][][]byte, error)
	ConsensusGroupSizeCalled                 func(uint32) int
}

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

func (*NodesCoordinatorMock) ComputeConsensusGroup added in v0.0.5

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

ComputeConsensusGroup -

func (*NodesCoordinatorMock) ComputeLeaving added in v0.0.5

func (ncm *NodesCoordinatorMock) ComputeLeaving(_ []*state.ShardValidatorInfo) ([]sharding.Validator, error)

ComputeLeaving -

func (*NodesCoordinatorMock) ConsensusGroupSize added in v0.0.5

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

ConsensusGroupSize -

func (*NodesCoordinatorMock) GetAllEligibleValidatorsPublicKeys added in v0.0.5

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

GetAllEligibleValidatorsPublicKeys -

func (*NodesCoordinatorMock) GetAllLeavingValidatorsPublicKeys added in v1.0.102

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

GetAllLeavingValidatorsPublicKeys -

func (*NodesCoordinatorMock) GetAllWaitingValidatorsPublicKeys added in v0.0.5

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

GetAllWaitingValidatorsPublicKeys -

func (*NodesCoordinatorMock) GetChance added in v1.0.102

func (ncm *NodesCoordinatorMock) GetChance(uint32) uint32

GetChance -

func (*NodesCoordinatorMock) GetConsensusValidatorsPublicKeys added in v0.0.5

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

GetConsensusValidatorsPublicKeys -

func (*NodesCoordinatorMock) GetConsensusWhitelistedNodes added in v0.0.5

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 added in v0.0.5

func (ncm *NodesCoordinatorMock) GetNumTotalEligible() uint64

GetNumTotalEligible -

func (*NodesCoordinatorMock) GetOwnPublicKey added in v0.0.5

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

GetOwnPublicKey -

func (*NodesCoordinatorMock) GetSavedStateKey added in v0.0.5

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

GetSavedStateKey -

func (*NodesCoordinatorMock) GetSelectedPublicKeys added in v0.0.5

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

GetSelectedPublicKeys -

func (*NodesCoordinatorMock) GetValidatorWithPublicKey added in v0.0.5

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

GetValidatorWithPublicKey -

func (*NodesCoordinatorMock) GetValidatorsIndexes added in v0.0.5

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

GetValidatorsIndexes -

func (*NodesCoordinatorMock) IsInterfaceNil added in v0.0.5

func (ncm *NodesCoordinatorMock) IsInterfaceNil() bool

IsInterfaceNil -

func (*NodesCoordinatorMock) LoadState added in v0.0.5

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

LoadState -

func (*NodesCoordinatorMock) SetNodesPerShards added in v0.0.5

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

SetNodesPerShards -

func (*NodesCoordinatorMock) ShardIdForEpoch added in v0.0.5

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

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

func (*NodesCoordinatorMock) ValidatorsWeights added in v0.0.5

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

ValidatorsWeights -

type PubkeyConverterMock added in v1.0.104

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

PubkeyConverterMock -

func NewPubkeyConverterMock added in v1.0.104

func NewPubkeyConverterMock(addressLen int) *PubkeyConverterMock

NewPubkeyConverterMock -

func (*PubkeyConverterMock) CreateAddressFromBytes added in v1.0.104

func (pcm *PubkeyConverterMock) CreateAddressFromBytes(pkBytes []byte) (state.AddressContainer, error)

CreateAddressFromBytes -

func (*PubkeyConverterMock) CreateAddressFromString added in v1.0.104

func (pcm *PubkeyConverterMock) CreateAddressFromString(humanReadable string) (state.AddressContainer, error)

CreateAddressFromString -

func (*PubkeyConverterMock) Decode added in v1.0.104

func (pcm *PubkeyConverterMock) Decode(humanReadable string) ([]byte, error)

Decode -

func (*PubkeyConverterMock) Encode added in v1.0.104

func (pcm *PubkeyConverterMock) Encode(pkBytes []byte) string

Encode -

func (*PubkeyConverterMock) IsInterfaceNil added in v1.0.104

func (pcm *PubkeyConverterMock) IsInterfaceNil() bool

IsInterfaceNil -

func (*PubkeyConverterMock) Len added in v1.0.104

func (pcm *PubkeyConverterMock) Len() int

Len -

type ShardCoordinatorMock

type ShardCoordinatorMock struct {
}

ShardCoordinatorMock -

func (ShardCoordinatorMock) CommunicationIdentifier

func (scm ShardCoordinatorMock) CommunicationIdentifier(destShardID uint32) string

CommunicationIdentifier -

func (ShardCoordinatorMock) ComputeId

ComputeId -

func (ShardCoordinatorMock) IsInterfaceNil

func (scm ShardCoordinatorMock) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

func (ShardCoordinatorMock) NumberOfShards

func (scm ShardCoordinatorMock) NumberOfShards() uint32

NumberOfShards -

func (ShardCoordinatorMock) SameShard

func (scm ShardCoordinatorMock) SameShard(_, _ state.AddressContainer) bool

SameShard -

func (ShardCoordinatorMock) SelfId

func (scm ShardCoordinatorMock) SelfId() uint32

SelfId -

func (ShardCoordinatorMock) SetSelfId

func (scm ShardCoordinatorMock) SetSelfId(_ uint32) error

SetSelfId -

type ShardStatisticsMock

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

ShardStatisticsMock will hold the tps statistics for each shard

func (*ShardStatisticsMock) AverageBlockTxCount

func (ss *ShardStatisticsMock) AverageBlockTxCount() uint32

AverageBlockTxCount returns an average transaction count for

func (*ShardStatisticsMock) AverageTPS

func (ss *ShardStatisticsMock) AverageTPS() *big.Int

AverageTPS returns an average tps for all processed blocks in a shard

func (*ShardStatisticsMock) CurrentBlockNonce

func (ss *ShardStatisticsMock) CurrentBlockNonce() uint64

CurrentBlockNonce returns the block nounce of the last processed block in a shard

func (*ShardStatisticsMock) IsInterfaceNil

func (ss *ShardStatisticsMock) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

func (*ShardStatisticsMock) LastBlockTxCount

func (ss *ShardStatisticsMock) LastBlockTxCount() uint32

LastBlockTxCount returns the number of transactions included in the last block

func (*ShardStatisticsMock) LiveTPS

func (ss *ShardStatisticsMock) LiveTPS() float64

LiveTPS returns tps for the last block

func (*ShardStatisticsMock) PeakTPS

func (ss *ShardStatisticsMock) PeakTPS() float64

PeakTPS returns peak tps for for all the blocks of the current shard

func (*ShardStatisticsMock) ShardID

func (ss *ShardStatisticsMock) ShardID() uint32

ShardID returns the shard id of the current statistic object

func (*ShardStatisticsMock) TotalProcessedTxCount

func (ss *ShardStatisticsMock) TotalProcessedTxCount() *big.Int

TotalProcessedTxCount returns the total number of processed transactions for this shard

type StableTagProviderStub

type StableTagProviderStub struct {
	FetchTagVersionCalled func() (string, error)
}

StableTagProviderStub --

func (*StableTagProviderStub) FetchTagVersion

func (s *StableTagProviderStub) FetchTagVersion() (string, error)

FetchTagVersion --

func (*StableTagProviderStub) IsInterfaceNil

func (s *StableTagProviderStub) IsInterfaceNil() bool

IsInterfaceNil --

type TpsBenchmarkMock

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

TpsBenchmarkMock will calculate statistics for the network activity

func (*TpsBenchmarkMock) ActiveNodes

func (s *TpsBenchmarkMock) ActiveNodes() uint32

ActiveNodes returns the number of active nodes

func (*TpsBenchmarkMock) AverageBlockTxCount

func (s *TpsBenchmarkMock) AverageBlockTxCount() *big.Int

AverageBlockTxCount returns an average of the tx/block

func (*TpsBenchmarkMock) BlockNumber

func (s *TpsBenchmarkMock) BlockNumber() uint64

BlockNumber returns the last processed block number

func (*TpsBenchmarkMock) IsInterfaceNil

func (s *TpsBenchmarkMock) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

func (*TpsBenchmarkMock) LastBlockTxCount

func (s *TpsBenchmarkMock) LastBlockTxCount() uint32

LastBlockTxCount returns the number of transactions processed in the last block

func (*TpsBenchmarkMock) LiveTPS

func (s *TpsBenchmarkMock) LiveTPS() float64

LiveTPS returns tps for the last block

func (*TpsBenchmarkMock) NrOfShards

func (s *TpsBenchmarkMock) NrOfShards() uint32

NrOfShards returns the number of shards

func (*TpsBenchmarkMock) PeakTPS

func (s *TpsBenchmarkMock) PeakTPS() float64

PeakTPS returns tps for the last block

func (*TpsBenchmarkMock) RoundNumber

func (s *TpsBenchmarkMock) RoundNumber() uint64

RoundNumber returns the round index for this benchmark object

func (*TpsBenchmarkMock) RoundTime

func (s *TpsBenchmarkMock) RoundTime() uint64

RoundTime returns the round duration in seconds

func (*TpsBenchmarkMock) ShardStatistic

func (s *TpsBenchmarkMock) ShardStatistic(shardID uint32) statistics.ShardStatistic

ShardStatistic returns the current statistical state for a given shard

func (*TpsBenchmarkMock) ShardStatistics

func (s *TpsBenchmarkMock) ShardStatistics() map[uint32]statistics.ShardStatistic

ShardStatistics returns the current statistical state for a given shard

func (*TpsBenchmarkMock) TotalProcessedTxCount

func (s *TpsBenchmarkMock) TotalProcessedTxCount() *big.Int

TotalProcessedTxCount returns the total number of processed transactions

func (*TpsBenchmarkMock) Update

func (s *TpsBenchmarkMock) Update(mb data.HeaderHandler)

Update receives a metablock and updates all fields accordingly for each shard available in the meta block

func (*TpsBenchmarkMock) UpdateWithShardStats

func (s *TpsBenchmarkMock) UpdateWithShardStats(mb *block.MetaBlock)

UpdateWithShardStats -

Jump to

Keyboard shortcuts

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