Documentation ¶
Index ¶
- type ChainStorerMock
- func (bc *ChainStorerMock) AddStorer(key dataRetriever.UnitType, s storage.Storer)
- func (bc *ChainStorerMock) Destroy() error
- func (bc *ChainStorerMock) Get(unitType dataRetriever.UnitType, key []byte) ([]byte, error)
- func (bc *ChainStorerMock) GetAll(unitType dataRetriever.UnitType, keys [][]byte) (map[string][]byte, error)
- func (bc *ChainStorerMock) GetStorer(unitType dataRetriever.UnitType) storage.Storer
- func (bc *ChainStorerMock) Has(unitType dataRetriever.UnitType, key []byte) (bool, error)
- func (bc *ChainStorerMock) Put(unitType dataRetriever.UnitType, key []byte, value []byte) error
- type HasherMock
- type IndexerMock
- type MarshalizerMock
- type ShardCoordinatorMock
- func (scm ShardCoordinatorMock) CommunicationIdentifier(destShardID uint32) string
- func (scm ShardCoordinatorMock) ComputeId(address state.AddressContainer) uint32
- func (scm ShardCoordinatorMock) NumberOfShards() uint32
- func (scm ShardCoordinatorMock) SameShard(firstAddress, secondAddress state.AddressContainer) bool
- func (scm ShardCoordinatorMock) SelfId() uint32
- func (scm ShardCoordinatorMock) SetSelfId(shardId uint32) error
- type ShardStatisticsMock
- func (ss *ShardStatisticsMock) AverageBlockTxCount() uint32
- func (ss *ShardStatisticsMock) AverageTPS() *big.Int
- func (ss *ShardStatisticsMock) CurrentBlockNonce() uint64
- func (ss *ShardStatisticsMock) LastBlockTxCount() uint32
- func (ss *ShardStatisticsMock) LiveTPS() float64
- func (ss *ShardStatisticsMock) PeakTPS() float64
- func (ss *ShardStatisticsMock) ShardID() uint32
- func (ss *ShardStatisticsMock) TotalProcessedTxCount() *big.Int
- type TpsBenchmarkMock
- func (s *TpsBenchmarkMock) ActiveNodes() uint32
- func (s *TpsBenchmarkMock) AverageBlockTxCount() *big.Int
- func (s *TpsBenchmarkMock) BlockNumber() uint64
- func (s *TpsBenchmarkMock) LastBlockTxCount() uint32
- func (s *TpsBenchmarkMock) LiveTPS() float64
- func (s *TpsBenchmarkMock) NrOfShards() uint32
- func (s *TpsBenchmarkMock) PeakTPS() float64
- func (s *TpsBenchmarkMock) RoundNumber() uint64
- func (s *TpsBenchmarkMock) RoundTime() uint64
- func (s *TpsBenchmarkMock) ShardStatistic(shardID uint32) statistics.ShardStatistic
- func (s *TpsBenchmarkMock) ShardStatistics() map[uint32]statistics.ShardStatistic
- func (s *TpsBenchmarkMock) TotalProcessedTxCount() *big.Int
- func (s *TpsBenchmarkMock) Update(mb data.HeaderHandler)
- func (s *TpsBenchmarkMock) UpdateWithShardStats(mb *block.MetaBlock)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
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 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
type IndexerMock ¶ added in v1.0.3
IndexerMock is a mock implementation fot the Indexer interface
func (*IndexerMock) SaveBlock ¶ added in v1.0.3
func (im *IndexerMock) SaveBlock(body data.BodyHandler, header data.HeaderHandler, txPool map[string]*transaction.Transaction)
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) 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) 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) 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) 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)