mock

package
v1.0.17 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2019 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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

Functions

This section is empty.

Types

type AppStatusHandlerStub

type AppStatusHandlerStub struct {
	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) 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

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 ChianStorer 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 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 IndexerMock added in v1.0.3

type IndexerMock struct {
	SaveBlockCalled func(body block.Body, header *block.Header)
}

IndexerMock is a mock implementation fot the Indexer interface

func (*IndexerMock) IsInterfaceNil added in v1.0.16

func (im *IndexerMock) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

func (*IndexerMock) SaveBlock added in v1.0.3

func (im *IndexerMock) SaveBlock(body data.BodyHandler, header data.HeaderHandler, txPool map[string]data.TransactionHandler)

func (*IndexerMock) UpdateTPS added in v1.0.3

func (im *IndexerMock) UpdateTPS(tpsBenchmark statistics.TPSBenchmark)

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 ShardCoordinatorMock

type ShardCoordinatorMock struct {
}

func (ShardCoordinatorMock) CommunicationIdentifier

func (scm ShardCoordinatorMock) CommunicationIdentifier(destShardID uint32) string

func (ShardCoordinatorMock) ComputeId

func (scm ShardCoordinatorMock) ComputeId(address state.AddressContainer) uint32

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

func (ShardCoordinatorMock) SameShard

func (scm ShardCoordinatorMock) SameShard(firstAddress, secondAddress state.AddressContainer) bool

func (ShardCoordinatorMock) SelfId

func (scm ShardCoordinatorMock) SelfId() uint32

func (ShardCoordinatorMock) SetSelfId

func (scm ShardCoordinatorMock) SetSelfId(shardId uint32) error

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

Jump to

Keyboard shortcuts

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