mock

package
v1.0.79 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2020 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CacherStub

type CacherStub struct {
	ClearCalled           func()
	PutCalled             func(key []byte, value interface{}) (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{}) (ok, evicted bool)
	RemoveCalled          func(key []byte)
	RemoveOldestCalled    func()
	KeysCalled            func() [][]byte
	LenCalled             func() int
	MaxSizeCalled         func() int
	RegisterHandlerCalled func(func(key []byte))
}

func (*CacherStub) Clear

func (cs *CacherStub) Clear()

func (*CacherStub) Get

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

func (*CacherStub) Has

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

func (*CacherStub) HasOrAdd

func (cs *CacherStub) HasOrAdd(key []byte, value interface{}) (ok, evicted bool)

func (*CacherStub) IsInterfaceNil

func (cs *CacherStub) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

func (*CacherStub) Keys

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

func (*CacherStub) Len

func (cs *CacherStub) Len() int

func (*CacherStub) MaxSize

func (cs *CacherStub) MaxSize() int

func (*CacherStub) Peek

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

func (*CacherStub) Put

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

func (*CacherStub) RegisterHandler

func (cs *CacherStub) RegisterHandler(handler func(key []byte))

func (*CacherStub) Remove

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

func (*CacherStub) RemoveOldest

func (cs *CacherStub) RemoveOldest()

type ChainStorerStub

type ChainStorerStub struct {
	AddStorerCalled func(key dataRetriever.UnitType, s storage.Storer)
	GetStorerCalled func(unitType dataRetriever.UnitType) storage.Storer
	HasCalled       func(unitType dataRetriever.UnitType, key []byte) 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
	CloseAllCalled  func() error
}

ChainStorerStub is a mock implementation of the ChianStorer interface

func (*ChainStorerStub) AddStorer

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

AddStorer will add a new storer to the chain map

func (*ChainStorerStub) CloseAll

func (bc *ChainStorerStub) CloseAll() error

func (*ChainStorerStub) Destroy

func (bc *ChainStorerStub) Destroy() error

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

func (*ChainStorerStub) Get

func (bc *ChainStorerStub) 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 (*ChainStorerStub) GetAll

func (bc *ChainStorerStub) 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 (*ChainStorerStub) GetStorer

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

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

func (*ChainStorerStub) Has

func (bc *ChainStorerStub) Has(unitType dataRetriever.UnitType, key []byte) 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 (*ChainStorerStub) IsInterfaceNil

func (bc *ChainStorerStub) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

func (*ChainStorerStub) Put

func (bc *ChainStorerStub) 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 EpochStartNotifierStub

type EpochStartNotifierStub struct {
	NotifyAllCalled func(hdr data.HeaderHandler)
}

func (*EpochStartNotifierStub) IsInterfaceNil

func (esnm *EpochStartNotifierStub) IsInterfaceNil() bool

func (*EpochStartNotifierStub) NotifyAll

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

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 return the required size in bytes

type HeaderValidatorStub

type HeaderValidatorStub struct {
	IsHeaderConstructionValidCalled func(currHdr, prevHdr data.HeaderHandler) error
}

func (*HeaderValidatorStub) IsHeaderConstructionValid

func (hvs *HeaderValidatorStub) IsHeaderConstructionValid(currHdr, prevHdr data.HeaderHandler) error

func (*HeaderValidatorStub) IsInterfaceNil

func (hvs *HeaderValidatorStub) IsInterfaceNil() bool

IsInterfaceNil returns if underlying object is true

type HeadersCacherStub

type HeadersCacherStub struct {
	AddCalled                           func(headerHash []byte, header data.HeaderHandler)
	RemoveHeaderByHashCalled            func(headerHash []byte)
	RemoveHeaderByNonceAndShardIdCalled func(hdrNonce uint64, shardId uint32)
	GetHeaderByNonceAndShardIdCalled    func(hdrNonce uint64, shardId uint32) ([]data.HeaderHandler, [][]byte, error)
	GetHeaderByHashCalled               func(hash []byte) (data.HeaderHandler, error)
	ClearCalled                         func()
	RegisterHandlerCalled               func(handler func(header data.HeaderHandler, shardHeaderHash []byte))
	NoncesCalled                        func(shardId uint32) []uint64
	LenCalled                           func() int
	MaxSizeCalled                       func() int
}

func (*HeadersCacherStub) AddHeader

func (hcs *HeadersCacherStub) AddHeader(headerHash []byte, header data.HeaderHandler)

func (*HeadersCacherStub) Clear

func (hcs *HeadersCacherStub) Clear()

func (*HeadersCacherStub) GetHeaderByHash

func (hcs *HeadersCacherStub) GetHeaderByHash(hash []byte) (data.HeaderHandler, error)

func (*HeadersCacherStub) GetHeadersByNonceAndShardId

func (hcs *HeadersCacherStub) GetHeadersByNonceAndShardId(hdrNonce uint64, shardId uint32) ([]data.HeaderHandler, [][]byte, error)

func (*HeadersCacherStub) IsInterfaceNil

func (hcs *HeadersCacherStub) IsInterfaceNil() bool

func (*HeadersCacherStub) Len

func (hcs *HeadersCacherStub) Len() int

func (*HeadersCacherStub) MaxSize

func (hcs *HeadersCacherStub) MaxSize() int

func (*HeadersCacherStub) Nonces

func (hcs *HeadersCacherStub) Nonces(shardId uint32) []uint64

func (*HeadersCacherStub) RegisterHandler

func (hcs *HeadersCacherStub) RegisterHandler(handler func(header data.HeaderHandler, shardHeaderHash []byte))

func (*HeadersCacherStub) RemoveHeaderByHash

func (hcs *HeadersCacherStub) RemoveHeaderByHash(headerHash []byte)

func (*HeadersCacherStub) RemoveHeaderByNonceAndShardId

func (hcs *HeadersCacherStub) RemoveHeaderByNonceAndShardId(hdrNonce uint64, shardId uint32)

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 PoolsHolderStub

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

func (*PoolsHolderStub) CurrentBlockTxs

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

func (*PoolsHolderStub) Headers

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

func (*PoolsHolderStub) IsInterfaceNil

func (phs *PoolsHolderStub) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

func (*PoolsHolderStub) MiniBlocks

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

func (*PoolsHolderStub) PeerChangesBlocks

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

func (*PoolsHolderStub) RewardTransactions

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

func (*PoolsHolderStub) Transactions

func (*PoolsHolderStub) TrieNodes

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

func (*PoolsHolderStub) UnsignedTransactions

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

type RequestHandlerStub

type RequestHandlerStub struct {
	RequestShardHeaderCalled        func(shardId uint32, hash []byte)
	RequestMetaHeaderCalled         func(hash []byte)
	RequestMetaHeaderByNonceCalled  func(nonce uint64)
	RequestShardHeaderByNonceCalled func(shardId uint32, nonce uint64)
	RequestTransactionHandlerCalled func(destShardID uint32, txHashes [][]byte)
	RequestScrHandlerCalled         func(destShardID uint32, txHashes [][]byte)
	RequestRewardTxHandlerCalled    func(destShardID uint32, txHashes [][]byte)
	RequestMiniBlockHandlerCalled   func(destShardID uint32, miniblockHash []byte)
}

func (*RequestHandlerStub) IsInterfaceNil

func (rhs *RequestHandlerStub) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

func (*RequestHandlerStub) RequestMetaHeader

func (rhs *RequestHandlerStub) RequestMetaHeader(hash []byte)

func (*RequestHandlerStub) RequestMetaHeaderByNonce

func (rhs *RequestHandlerStub) RequestMetaHeaderByNonce(nonce uint64)

func (*RequestHandlerStub) RequestMiniBlock added in v1.0.67

func (rhs *RequestHandlerStub) RequestMiniBlock(shardId uint32, miniblockHash []byte)

func (*RequestHandlerStub) RequestRewardTransactions

func (rhs *RequestHandlerStub) RequestRewardTransactions(destShardID uint32, txHashes [][]byte)

func (*RequestHandlerStub) RequestShardHeader

func (rhs *RequestHandlerStub) RequestShardHeader(shardId uint32, hash []byte)

func (*RequestHandlerStub) RequestShardHeaderByNonce

func (rhs *RequestHandlerStub) RequestShardHeaderByNonce(shardId uint32, nonce uint64)

func (*RequestHandlerStub) RequestTransaction

func (rhs *RequestHandlerStub) RequestTransaction(destShardID uint32, txHashes [][]byte)

func (*RequestHandlerStub) RequestUnsignedTransactions

func (rhs *RequestHandlerStub) RequestUnsignedTransactions(destShardID uint32, txHashes [][]byte)

type RounderStub

type RounderStub struct {
	RoundIndex int64

	IndexCalled         func() int64
	TimeDurationCalled  func() time.Duration
	TimeStampCalled     func() time.Time
	UpdateRoundCalled   func(time.Time, time.Time)
	RemainingTimeCalled func(startTime time.Time, maxTime time.Duration) time.Duration
}

func (*RounderStub) Index

func (rndm *RounderStub) Index() int64

func (*RounderStub) IsInterfaceNil

func (rndm *RounderStub) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

func (*RounderStub) RemainingTime

func (rndm *RounderStub) RemainingTime(startTime time.Time, maxTime time.Duration) time.Duration

func (*RounderStub) TimeDuration

func (rndm *RounderStub) TimeDuration() time.Duration

func (*RounderStub) TimeStamp

func (rndm *RounderStub) TimeStamp() time.Time

func (*RounderStub) UpdateRound

func (rndm *RounderStub) UpdateRound(genesisRoundTimeStamp time.Time, timeStamp time.Time)

type ShardIdHasMapStub

type ShardIdHasMapStub struct {
	LoadCalled   func(shardId uint32) ([]byte, bool)
	StoreCalled  func(shardId uint32, hash []byte)
	RangeCalled  func(f func(shardId uint32, hash []byte) bool)
	DeleteCalled func(shardId uint32)
}

func (*ShardIdHasMapStub) Delete

func (sihsm *ShardIdHasMapStub) Delete(shardId uint32)

func (*ShardIdHasMapStub) IsInterfaceNil

func (sihsm *ShardIdHasMapStub) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

func (*ShardIdHasMapStub) Load

func (sihsm *ShardIdHasMapStub) Load(shardId uint32) ([]byte, bool)

func (*ShardIdHasMapStub) Range

func (sihsm *ShardIdHasMapStub) Range(f func(shardId uint32, hash []byte) bool)

func (*ShardIdHasMapStub) Store

func (sihsm *ShardIdHasMapStub) Store(shardId uint32, hash []byte)

type StorerStub

type StorerStub struct {
	PutCalled         func(key, data []byte) error
	GetCalled         func(key []byte) ([]byte, error)
	HasCalled         func(key []byte) error
	RemoveCalled      func(key []byte) error
	ClearCacheCalled  func()
	DestroyUnitCalled func() error
}

func (*StorerStub) ClearCache

func (ss *StorerStub) ClearCache()

func (*StorerStub) Close

func (ss *StorerStub) Close() error

func (*StorerStub) DestroyUnit

func (ss *StorerStub) DestroyUnit() error

func (*StorerStub) Get

func (ss *StorerStub) Get(key []byte) ([]byte, error)

func (*StorerStub) Has

func (ss *StorerStub) Has(key []byte) error

func (*StorerStub) IsInterfaceNil

func (ss *StorerStub) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

func (*StorerStub) Put

func (ss *StorerStub) Put(key, data []byte) error

func (*StorerStub) Remove

func (ss *StorerStub) Remove(key []byte) error

type SyncTimerStub

type SyncTimerStub struct {
	StartSyncCalled            func()
	ClockOffsetCalled          func() time.Duration
	FormattedCurrentTimeCalled func() string
	CurrentTimeCalled          func() time.Time
}

SyncTimerStub is a mock implementation of SyncTimer interface

func (*SyncTimerStub) ClockOffset

func (s *SyncTimerStub) ClockOffset() time.Duration

ClockOffset is a mock implementation for ClockOffset

func (*SyncTimerStub) CurrentTime

func (s *SyncTimerStub) CurrentTime() time.Time

CurrentTime is a mock implementation for CurrentTime

func (*SyncTimerStub) FormattedCurrentTime

func (s *SyncTimerStub) FormattedCurrentTime() string

FormattedCurrentTime is a mock implementation for FormattedCurrentTime

func (*SyncTimerStub) IsInterfaceNil

func (stm *SyncTimerStub) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

func (*SyncTimerStub) StartSync

func (s *SyncTimerStub) StartSync()

StartSync is a mock implementation for StartSync

type Uint64ByteSliceConverterMock

type Uint64ByteSliceConverterMock struct {
	ToByteSliceCalled func(uint64) []byte
	ToUint64Called    func([]byte) (uint64, error)
}

Uint64ByteSliceConverterMock converts byte slice to/from uint64

func (*Uint64ByteSliceConverterMock) IsInterfaceNil

func (u *Uint64ByteSliceConverterMock) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

func (*Uint64ByteSliceConverterMock) ToByteSlice

func (u *Uint64ByteSliceConverterMock) ToByteSlice(p uint64) []byte

ToByteSlice is a mock implementation for Uint64ByteSliceConverter

func (*Uint64ByteSliceConverterMock) ToUint64

func (u *Uint64ByteSliceConverterMock) ToUint64(p []byte) (uint64, error)

ToUint64 is a mock implementation for Uint64ByteSliceConverter

type Uint64SyncMapCacherStub

type Uint64SyncMapCacherStub struct {
	ClearCalled           func()
	GetCalled             func(nonce uint64) (dataRetriever.ShardIdHashMap, bool)
	MergeCalled           func(nonce uint64, src dataRetriever.ShardIdHashMap)
	RemoveCalled          func(nonce uint64, shardId uint32)
	RegisterHandlerCalled func(handler func(nonce uint64, shardId uint32, value []byte))
	HasCalled             func(nonce uint64, shardId uint32) bool
}

func (*Uint64SyncMapCacherStub) Clear

func (usmcs *Uint64SyncMapCacherStub) Clear()

func (*Uint64SyncMapCacherStub) Get

func (*Uint64SyncMapCacherStub) Has

func (usmcs *Uint64SyncMapCacherStub) Has(nonce uint64, shardId uint32) bool

func (*Uint64SyncMapCacherStub) IsInterfaceNil

func (usmcs *Uint64SyncMapCacherStub) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

func (*Uint64SyncMapCacherStub) Merge

func (*Uint64SyncMapCacherStub) RegisterHandler

func (usmcs *Uint64SyncMapCacherStub) RegisterHandler(handler func(nonce uint64, shardId uint32, value []byte))

func (*Uint64SyncMapCacherStub) Remove

func (usmcs *Uint64SyncMapCacherStub) Remove(nonce uint64, shardId uint32)

Jump to

Keyboard shortcuts

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