testscommon

package
v1.1.58 Latest Latest
Warning

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

Go to latest
Published: May 19, 2021 License: GPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddTimestampSuffix added in v1.0.147

func AddTimestampSuffix(tag string) string

AddTimestampSuffix -

func CreatePoolsHolder

func CreatePoolsHolder(numShards uint32, selfShard uint32) dataRetriever.PoolsHolder

CreatePoolsHolder -

func CreatePoolsHolderWithTxPool

func CreatePoolsHolderWithTxPool(txPool dataRetriever.ShardedDataCacherNotifier) dataRetriever.PoolsHolder

CreatePoolsHolderWithTxPool -

func CreateTxPool

func CreateTxPool(numShards uint32, selfShard uint32) (dataRetriever.ShardedDataCacherNotifier, error)

CreateTxPool -

func GetGeneralConfig

func GetGeneralConfig() config.Config

GetGeneralConfig returns the common configuration used for testing

Types

type CacherMock

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

CacherMock -

func NewCacherMock

func NewCacherMock() *CacherMock

NewCacherMock -

func (*CacherMock) Clear

func (cacher *CacherMock) Clear()

Clear -

func (*CacherMock) Get

func (cacher *CacherMock) Get(key []byte) (value interface{}, ok bool)

Get -

func (*CacherMock) Has

func (cacher *CacherMock) Has(key []byte) bool

Has -

func (*CacherMock) HasOrAdd

func (cacher *CacherMock) HasOrAdd(key []byte, value interface{}, _ int) (has, added bool)

HasOrAdd -

func (*CacherMock) IsInterfaceNil

func (cacher *CacherMock) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

func (*CacherMock) Keys

func (cacher *CacherMock) Keys() [][]byte

Keys -

func (*CacherMock) Len

func (cacher *CacherMock) Len() int

Len -

func (*CacherMock) MaxSize

func (cacher *CacherMock) MaxSize() int

MaxSize -

func (*CacherMock) Peek

func (cacher *CacherMock) Peek(key []byte) (value interface{}, ok bool)

Peek -

func (*CacherMock) Put

func (cacher *CacherMock) Put(key []byte, value interface{}, _ int) (evicted bool)

Put -

func (*CacherMock) RegisterHandler

func (cacher *CacherMock) RegisterHandler(handler func(key []byte, value interface{}), _ string)

RegisterHandler -

func (*CacherMock) Remove

func (cacher *CacherMock) Remove(key []byte)

Remove -

func (*CacherMock) SizeInBytesContained added in v1.1.45

func (cacher *CacherMock) SizeInBytesContained() uint64

SizeInBytesContained -

func (*CacherMock) UnRegisterHandler

func (cacher *CacherMock) UnRegisterHandler(string)

UnRegisterHandler -

type CacherStub

type CacherStub struct {
	ClearCalled             func()
	PutCalled               func(key []byte, value interface{}, sizeInBytes int) (evicted bool)
	GetCalled               func(key []byte) (value interface{}, ok bool)
	HasCalled               func(key []byte) bool
	PeekCalled              func(key []byte) (value interface{}, ok bool)
	HasOrAddCalled          func(key []byte, value interface{}, sizeInBytes int) (has, added bool)
	RemoveCalled            func(key []byte)
	RemoveOldestCalled      func()
	KeysCalled              func() [][]byte
	LenCalled               func() int
	MaxSizeCalled           func() int
	RegisterHandlerCalled   func(func(key []byte, value interface{}))
	UnRegisterHandlerCalled func(id string)
}

CacherStub -

func NewCacherStub

func NewCacherStub() *CacherStub

NewCacherStub -

func (*CacherStub) Clear

func (cacher *CacherStub) Clear()

Clear -

func (*CacherStub) Get

func (cacher *CacherStub) Get(key []byte) (value interface{}, ok bool)

Get -

func (*CacherStub) Has

func (cacher *CacherStub) Has(key []byte) bool

Has -

func (*CacherStub) HasOrAdd

func (cacher *CacherStub) HasOrAdd(key []byte, value interface{}, sizeInBytes int) (has, added bool)

HasOrAdd -

func (*CacherStub) IsInterfaceNil

func (cacher *CacherStub) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

func (*CacherStub) Keys

func (cacher *CacherStub) Keys() [][]byte

Keys -

func (*CacherStub) Len

func (cacher *CacherStub) Len() int

Len -

func (*CacherStub) MaxSize

func (cacher *CacherStub) MaxSize() int

MaxSize -

func (*CacherStub) Peek

func (cacher *CacherStub) Peek(key []byte) (value interface{}, ok bool)

Peek -

func (*CacherStub) Put

func (cacher *CacherStub) Put(key []byte, value interface{}, sizeInBytes int) (evicted bool)

Put -

func (*CacherStub) RegisterHandler

func (cacher *CacherStub) RegisterHandler(handler func(key []byte, value interface{}), _ string)

RegisterHandler -

func (*CacherStub) Remove

func (cacher *CacherStub) Remove(key []byte)

Remove -

func (*CacherStub) SizeInBytesContained added in v1.1.45

func (cacher *CacherStub) SizeInBytesContained() uint64

SizeInBytesContained -

func (*CacherStub) UnRegisterHandler

func (cacher *CacherStub) UnRegisterHandler(id string)

UnRegisterHandler -

type FallBackHeaderValidatorStub added in v1.1.3

type FallBackHeaderValidatorStub struct {
	ShouldApplyFallbackValidationCalled func(headerHandler data.HeaderHandler) bool
}

FallBackHeaderValidatorStub -

func (*FallBackHeaderValidatorStub) IsInterfaceNil added in v1.1.3

func (fhvs *FallBackHeaderValidatorStub) IsInterfaceNil() bool

IsInterfaceNil -

func (*FallBackHeaderValidatorStub) ShouldApplyFallbackValidation added in v1.1.3

func (fhvs *FallBackHeaderValidatorStub) ShouldApplyFallbackValidation(headerHandler data.HeaderHandler) bool

ShouldApplyFallbackValidation -

type HistoryRepositoryStub added in v1.1.1

type HistoryRepositoryStub struct {
	RecordBlockCalled                  func(blockHeaderHash []byte, blockHeader data.HeaderHandler, blockBody data.BodyHandler, scrsPool map[string]data.TransactionHandler, receipts map[string]data.TransactionHandler) error
	OnNotarizedBlocksCalled            func(shardID uint32, headers []data.HeaderHandler, headersHashes [][]byte)
	GetMiniblockMetadataByTxHashCalled func(hash []byte) (*dblookupext.MiniblockMetadata, error)
	GetEpochByHashCalled               func(hash []byte) (uint32, error)
	GetEventsHashesByTxHashCalled      func(hash []byte, epoch uint32) (*dblookupext.ResultsHashesByTxHash, error)
	IsEnabledCalled                    func() bool
}

HistoryRepositoryStub -

func (*HistoryRepositoryStub) GetEpochByHash added in v1.1.1

func (hp *HistoryRepositoryStub) GetEpochByHash(hash []byte) (uint32, error)

GetEpochByHash -

func (*HistoryRepositoryStub) GetMiniblockMetadataByTxHash added in v1.1.1

func (hp *HistoryRepositoryStub) GetMiniblockMetadataByTxHash(hash []byte) (*dblookupext.MiniblockMetadata, error)

GetMiniblockMetadataByTxHash -

func (*HistoryRepositoryStub) GetResultsHashesByTxHash added in v1.1.12

func (hp *HistoryRepositoryStub) GetResultsHashesByTxHash(hash []byte, epoch uint32) (*dblookupext.ResultsHashesByTxHash, error)

GetResultsHashesByTxHash -

func (*HistoryRepositoryStub) IsEnabled added in v1.1.1

func (hp *HistoryRepositoryStub) IsEnabled() bool

IsEnabled -

func (*HistoryRepositoryStub) IsInterfaceNil added in v1.1.1

func (hp *HistoryRepositoryStub) IsInterfaceNil() bool

IsInterfaceNil -

func (*HistoryRepositoryStub) OnNotarizedBlocks added in v1.1.1

func (hp *HistoryRepositoryStub) OnNotarizedBlocks(shardID uint32, headers []data.HeaderHandler, headersHashes [][]byte)

OnNotarizedBlocks -

func (*HistoryRepositoryStub) RecordBlock added in v1.1.1

func (hp *HistoryRepositoryStub) RecordBlock(
	blockHeaderHash []byte,
	blockHeader data.HeaderHandler,
	blockBody data.BodyHandler,
	scrsPool map[string]data.TransactionHandler,
	receipts map[string]data.TransactionHandler,
) error

RecordBlock -

type PeerHonestyHandlerStub

type PeerHonestyHandlerStub struct {
	ChangeScoreCalled func(pk string, topic string, units int)
}

PeerHonestyHandlerStub -

func (*PeerHonestyHandlerStub) ChangeScore

func (phhs *PeerHonestyHandlerStub) ChangeScore(pk string, topic string, units int)

ChangeScore -

func (*PeerHonestyHandlerStub) IsInterfaceNil

func (phhs *PeerHonestyHandlerStub) IsInterfaceNil() bool

IsInterfaceNil -

type PoolsHolderMock

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

PoolsHolderMock -

func NewPoolsHolderMock

func NewPoolsHolderMock() *PoolsHolderMock

NewPoolsHolderMock -

func (*PoolsHolderMock) CurrentBlockTxs

func (holder *PoolsHolderMock) CurrentBlockTxs() dataRetriever.TransactionCacher

CurrentBlockTxs -

func (*PoolsHolderMock) Headers

func (holder *PoolsHolderMock) Headers() dataRetriever.HeadersPool

Headers -

func (*PoolsHolderMock) IsInterfaceNil

func (holder *PoolsHolderMock) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

func (*PoolsHolderMock) MiniBlocks

func (holder *PoolsHolderMock) MiniBlocks() storage.Cacher

MiniBlocks -

func (*PoolsHolderMock) PeerChangesBlocks

func (holder *PoolsHolderMock) PeerChangesBlocks() storage.Cacher

PeerChangesBlocks -

func (*PoolsHolderMock) RewardTransactions

func (holder *PoolsHolderMock) RewardTransactions() dataRetriever.ShardedDataCacherNotifier

RewardTransactions -

func (*PoolsHolderMock) SetTransactions

func (holder *PoolsHolderMock) SetTransactions(pool dataRetriever.ShardedDataCacherNotifier)

SetTransactions -

func (*PoolsHolderMock) SetUnsignedTransactions

func (holder *PoolsHolderMock) SetUnsignedTransactions(pool dataRetriever.ShardedDataCacherNotifier)

SetUnsignedTransactions -

func (*PoolsHolderMock) SmartContracts added in v1.1.12

func (holder *PoolsHolderMock) SmartContracts() storage.Cacher

SmartContracts -

func (*PoolsHolderMock) Transactions

Transactions -

func (*PoolsHolderMock) TrieNodes

func (holder *PoolsHolderMock) TrieNodes() storage.Cacher

TrieNodes -

func (*PoolsHolderMock) UnsignedTransactions

func (holder *PoolsHolderMock) UnsignedTransactions() dataRetriever.ShardedDataCacherNotifier

UnsignedTransactions -

type PoolsHolderStub

type PoolsHolderStub struct {
	HeadersCalled              func() dataRetriever.HeadersPool
	TransactionsCalled         func() dataRetriever.ShardedDataCacherNotifier
	UnsignedTransactionsCalled func() dataRetriever.ShardedDataCacherNotifier
	RewardTransactionsCalled   func() dataRetriever.ShardedDataCacherNotifier
	MiniBlocksCalled           func() storage.Cacher
	MetaBlocksCalled           func() storage.Cacher
	CurrBlockTxsCalled         func() dataRetriever.TransactionCacher
	TrieNodesCalled            func() storage.Cacher
	PeerChangesBlocksCalled    func() storage.Cacher
	SmartContractsCalled       func() storage.Cacher
}

PoolsHolderStub -

func NewPoolsHolderStub

func NewPoolsHolderStub() *PoolsHolderStub

NewPoolsHolderStub -

func (*PoolsHolderStub) CurrentBlockTxs

func (holder *PoolsHolderStub) CurrentBlockTxs() dataRetriever.TransactionCacher

CurrentBlockTxs -

func (*PoolsHolderStub) Headers

func (holder *PoolsHolderStub) Headers() dataRetriever.HeadersPool

Headers -

func (*PoolsHolderStub) IsInterfaceNil

func (holder *PoolsHolderStub) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

func (*PoolsHolderStub) MetaBlocks

func (holder *PoolsHolderStub) MetaBlocks() storage.Cacher

MetaBlocks -

func (*PoolsHolderStub) MiniBlocks

func (holder *PoolsHolderStub) MiniBlocks() storage.Cacher

MiniBlocks -

func (*PoolsHolderStub) PeerChangesBlocks

func (holder *PoolsHolderStub) PeerChangesBlocks() storage.Cacher

PeerChangesBlocks -

func (*PoolsHolderStub) RewardTransactions

func (holder *PoolsHolderStub) RewardTransactions() dataRetriever.ShardedDataCacherNotifier

RewardTransactions -

func (*PoolsHolderStub) SmartContracts added in v1.1.12

func (holder *PoolsHolderStub) SmartContracts() storage.Cacher

SmartContracts -

func (*PoolsHolderStub) Transactions

Transactions -

func (*PoolsHolderStub) TrieNodes

func (holder *PoolsHolderStub) TrieNodes() storage.Cacher

TrieNodes -

func (*PoolsHolderStub) UnsignedTransactions

func (holder *PoolsHolderStub) UnsignedTransactions() dataRetriever.ShardedDataCacherNotifier

UnsignedTransactions -

type ProtoMarshalizerMock

type ProtoMarshalizerMock struct {
}

ProtoMarshalizerMock implements marshaling with protobuf

func (*ProtoMarshalizerMock) IsInterfaceNil

func (pmm *ProtoMarshalizerMock) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

func (*ProtoMarshalizerMock) Marshal

func (pmm *ProtoMarshalizerMock) Marshal(obj interface{}) ([]byte, error)

Marshal does the actual serialization of an object The object to be serialized must implement the gogoProtoObj interface

func (*ProtoMarshalizerMock) Unmarshal

func (pmm *ProtoMarshalizerMock) Unmarshal(obj interface{}, buff []byte) error

Unmarshal does the actual deserialization of an object The object to be deserialized must implement the gogoProtoObj interface

type ShardStatisticsMock added in v1.0.147

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

ShardStatisticsMock will hold the tps statistics for each shard

func (*ShardStatisticsMock) AverageBlockTxCount added in v1.0.147

func (ss *ShardStatisticsMock) AverageBlockTxCount() uint32

AverageBlockTxCount returns an average transaction count for

func (*ShardStatisticsMock) AverageTPS added in v1.0.147

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

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

func (*ShardStatisticsMock) CurrentBlockNonce added in v1.0.147

func (ss *ShardStatisticsMock) CurrentBlockNonce() uint64

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

func (*ShardStatisticsMock) IsInterfaceNil added in v1.0.147

func (ss *ShardStatisticsMock) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

func (*ShardStatisticsMock) LastBlockTxCount added in v1.0.147

func (ss *ShardStatisticsMock) LastBlockTxCount() uint32

LastBlockTxCount returns the number of transactions included in the last block

func (*ShardStatisticsMock) LiveTPS added in v1.0.147

func (ss *ShardStatisticsMock) LiveTPS() float64

LiveTPS returns tps for the last block

func (*ShardStatisticsMock) PeakTPS added in v1.0.147

func (ss *ShardStatisticsMock) PeakTPS() float64

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

func (*ShardStatisticsMock) ShardID added in v1.0.147

func (ss *ShardStatisticsMock) ShardID() uint32

ShardID returns the shard id of the current statistic object

func (*ShardStatisticsMock) TotalProcessedTxCount added in v1.0.147

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

TotalProcessedTxCount returns the total number of processed transactions for this shard

type ShardedDataStub

type ShardedDataStub struct {
	RegisterOnAddedCalled                  func(func(key []byte, value interface{}))
	ShardDataStoreCalled                   func(cacheID string) storage.Cacher
	AddDataCalled                          func(key []byte, data interface{}, sizeInBytes int, cacheID string)
	SearchFirstDataCalled                  func(key []byte) (value interface{}, ok bool)
	RemoveDataCalled                       func(key []byte, cacheID string)
	RemoveDataFromAllShardsCalled          func(key []byte)
	MergeShardStoresCalled                 func(sourceCacheID, destCacheID string)
	MoveDataCalled                         func(sourceCacheID, destCacheID string, key [][]byte)
	ClearCalled                            func()
	ClearShardStoreCalled                  func(cacheID string)
	RemoveSetOfDataFromPoolCalled          func(keys [][]byte, destCacheID string)
	ImmunizeSetOfDataAgainstEvictionCalled func(keys [][]byte, cacheID string)
	CreateShardStoreCalled                 func(destCacheID string)
	GetCountsCalled                        func() counting.CountsWithSize
}

ShardedDataStub -

func NewShardedDataStub

func NewShardedDataStub() *ShardedDataStub

NewShardedDataStub -

func (*ShardedDataStub) AddData

func (shardedData *ShardedDataStub) AddData(key []byte, data interface{}, sizeInBytes int, cacheID string)

AddData -

func (*ShardedDataStub) Clear

func (shardedData *ShardedDataStub) Clear()

Clear -

func (*ShardedDataStub) ClearShardStore

func (shardedData *ShardedDataStub) ClearShardStore(cacheID string)

ClearShardStore -

func (*ShardedDataStub) GetCounts

func (sd *ShardedDataStub) GetCounts() counting.CountsWithSize

GetCounts -

func (*ShardedDataStub) ImmunizeSetOfDataAgainstEviction

func (shardedData *ShardedDataStub) ImmunizeSetOfDataAgainstEviction(keys [][]byte, cacheID string)

ImmunizeSetOfDataAgainstEviction -

func (*ShardedDataStub) IsInterfaceNil

func (shardedData *ShardedDataStub) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

func (*ShardedDataStub) MergeShardStores

func (shardedData *ShardedDataStub) MergeShardStores(sourceCacheID, destCacheID string)

MergeShardStores -

func (*ShardedDataStub) RegisterOnAdded added in v1.0.137

func (shardedData *ShardedDataStub) RegisterOnAdded(handler func(key []byte, value interface{}))

RegisterOnAdded -

func (*ShardedDataStub) RemoveData

func (shardedData *ShardedDataStub) RemoveData(key []byte, cacheID string)

RemoveData -

func (*ShardedDataStub) RemoveDataFromAllShards

func (shardedData *ShardedDataStub) RemoveDataFromAllShards(key []byte)

RemoveDataFromAllShards -

func (*ShardedDataStub) RemoveSetOfDataFromPool

func (shardedData *ShardedDataStub) RemoveSetOfDataFromPool(keys [][]byte, cacheID string)

RemoveSetOfDataFromPool -

func (*ShardedDataStub) SearchFirstData

func (shardedData *ShardedDataStub) SearchFirstData(key []byte) (value interface{}, ok bool)

SearchFirstData -

func (*ShardedDataStub) ShardDataStore

func (shardedData *ShardedDataStub) ShardDataStore(cacheID string) storage.Cacher

ShardDataStore -

type TpsBenchmarkMock added in v1.0.147

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

TpsBenchmarkMock will calculate statistics for the network activity

func (*TpsBenchmarkMock) ActiveNodes added in v1.0.147

func (s *TpsBenchmarkMock) ActiveNodes() uint32

ActiveNodes returns the number of active nodes

func (*TpsBenchmarkMock) AverageBlockTxCount added in v1.0.147

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

AverageBlockTxCount returns an average of the tx/block

func (*TpsBenchmarkMock) BlockNumber added in v1.0.147

func (s *TpsBenchmarkMock) BlockNumber() uint64

BlockNumber returns the last processed block number

func (*TpsBenchmarkMock) IsInterfaceNil added in v1.0.147

func (s *TpsBenchmarkMock) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

func (*TpsBenchmarkMock) LastBlockTxCount added in v1.0.147

func (s *TpsBenchmarkMock) LastBlockTxCount() uint32

LastBlockTxCount returns the number of transactions processed in the last block

func (*TpsBenchmarkMock) LiveTPS added in v1.0.147

func (s *TpsBenchmarkMock) LiveTPS() float64

LiveTPS returns tps for the last block

func (*TpsBenchmarkMock) NrOfShards added in v1.0.147

func (s *TpsBenchmarkMock) NrOfShards() uint32

NrOfShards returns the number of shards

func (*TpsBenchmarkMock) PeakTPS added in v1.0.147

func (s *TpsBenchmarkMock) PeakTPS() float64

PeakTPS returns tps for the last block

func (*TpsBenchmarkMock) RoundNumber added in v1.0.147

func (s *TpsBenchmarkMock) RoundNumber() uint64

RoundNumber returns the round index for this benchmark object

func (*TpsBenchmarkMock) RoundTime added in v1.0.147

func (s *TpsBenchmarkMock) RoundTime() uint64

RoundTime returns the round duration in seconds

func (*TpsBenchmarkMock) ShardStatistic added in v1.0.147

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

ShardStatistic returns the current statistical state for a given shard

func (*TpsBenchmarkMock) ShardStatistics added in v1.0.147

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

ShardStatistics returns the current statistical state for a given shard

func (*TpsBenchmarkMock) TotalProcessedTxCount added in v1.0.147

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

TotalProcessedTxCount returns the total number of processed transactions

func (*TpsBenchmarkMock) Update added in v1.0.147

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

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

UpdateWithShardStats -

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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