mock

package
v1.999.10 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2022 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewNonceHashConverterMock

func NewNonceHashConverterMock() *nonceHashConverterMock

NewNonceHashConverterMock -

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

func (cacher *CacherMock) Close() error

Close -

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

func (cacher *CacherMock) SizeInBytesContained() uint64

SizeInBytesContained -

func (*CacherMock) UnRegisterHandler

func (cacher *CacherMock) UnRegisterHandler(string)

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

type HasherMock127

type HasherMock127 struct {
}

HasherMock127 -

func (HasherMock127) Compute

func (HasherMock127) Compute(s string) []byte

Compute -

func (HasherMock127) EmptyHash

func (HasherMock127) EmptyHash() []byte

EmptyHash -

func (*HasherMock127) IsInterfaceNil

func (hash *HasherMock127) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

func (HasherMock127) Size

func (HasherMock127) Size() int

Size -

type KeccakMock

type KeccakMock struct {
}

KeccakMock is a sha3-Keccak implementation of the hasher interface.

func (KeccakMock) Compute

func (k KeccakMock) Compute(s string) []byte

Compute takes a string, and returns the sha3-Keccak hash of that string

func (KeccakMock) EmptyHash

func (k KeccakMock) EmptyHash() []byte

EmptyHash returns the sha3-Keccak hash of the empty string

func (*KeccakMock) IsInterfaceNil

func (k *KeccakMock) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

func (KeccakMock) Size

func (KeccakMock) Size() int

Size returns the size, in number of bytes, of a sha3-Keccak hash

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

func (*MarshalizerMock) Version

func (*MarshalizerMock) Version() string

Version is deprecated and will be removed

type MarshalizerStub

type MarshalizerStub struct {
	MarshalCalled   func(obj interface{}) ([]byte, error)
	UnmarshalCalled func(obj interface{}, buff []byte) error
}

MarshalizerStub -

func (*MarshalizerStub) IsInterfaceNil

func (ms *MarshalizerStub) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

func (*MarshalizerStub) Marshal

func (ms *MarshalizerStub) Marshal(obj interface{}) ([]byte, error)

Marshal -

func (*MarshalizerStub) Unmarshal

func (ms *MarshalizerStub) Unmarshal(obj interface{}, buff []byte) error

Unmarshal -

type MemDbMock

type MemDbMock struct {
	PutCalled func(key, val []byte) error
	// contains filtered or unexported fields
}

MemDbMock represents the memory database storage. It holds a map of key value pairs and a mutex to handle concurrent accesses to the map

func NewMemDbMock

func NewMemDbMock() *MemDbMock

NewMemDbMock creates a new memorydb object

func (*MemDbMock) Close

func (s *MemDbMock) Close() error

Close closes the files/resources associated to the storage medium

func (*MemDbMock) Destroy

func (s *MemDbMock) Destroy() error

Destroy removes the storage medium stored data

func (*MemDbMock) DestroyClosed

func (s *MemDbMock) DestroyClosed() error

DestroyClosed removes the already closed storage medium stored data

func (*MemDbMock) Get

func (s *MemDbMock) Get(key []byte) ([]byte, error)

Get gets the value associated to the key, or reports an error

func (*MemDbMock) Has

func (s *MemDbMock) Has(key []byte) error

Has returns true if the given key is present in the persistence medium, false otherwise

func (*MemDbMock) Init

func (s *MemDbMock) Init() error

Init initializes the storage medium and prepares it for usage

func (*MemDbMock) IsInterfaceNil

func (s *MemDbMock) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

func (*MemDbMock) Put

func (s *MemDbMock) Put(key, val []byte) error

Put adds the value to the (key, val) storage medium

func (*MemDbMock) RangeKeys

func (s *MemDbMock) RangeKeys(handler func(key []byte, value []byte) bool)

RangeKeys will iterate over all contained (key, value) pairs calling the handler for each pair

func (*MemDbMock) Remove

func (s *MemDbMock) Remove(key []byte) error

Remove removes the data associated to the given key

type MultipleShardsCoordinatorMock

type MultipleShardsCoordinatorMock struct {
	ComputeIdCalled func(address []byte) uint32
	NoShards        uint32
	CurrentShard    uint32
}

MultipleShardsCoordinatorMock -

func NewMultiShardsCoordinatorMock

func NewMultiShardsCoordinatorMock(nrShard uint32) *MultipleShardsCoordinatorMock

NewMultiShardsCoordinatorMock -

func (*MultipleShardsCoordinatorMock) CommunicationIdentifier

func (scm *MultipleShardsCoordinatorMock) CommunicationIdentifier(destShardID uint32) string

CommunicationIdentifier returns the identifier between current shard ID and destination shard ID identifier is generated such as the first shard from identifier is always smaller than the last

func (*MultipleShardsCoordinatorMock) ComputeId

func (scm *MultipleShardsCoordinatorMock) ComputeId(address []byte) uint32

ComputeId -

func (*MultipleShardsCoordinatorMock) IsInterfaceNil

func (scm *MultipleShardsCoordinatorMock) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

func (*MultipleShardsCoordinatorMock) NumberOfShards

func (scm *MultipleShardsCoordinatorMock) NumberOfShards() uint32

NumberOfShards -

func (*MultipleShardsCoordinatorMock) SameShard

func (scm *MultipleShardsCoordinatorMock) SameShard(_, _ []byte) bool

SameShard -

func (*MultipleShardsCoordinatorMock) SelfId

func (scm *MultipleShardsCoordinatorMock) SelfId() uint32

SelfId -

type ProtobufMarshalizerMock

type ProtobufMarshalizerMock struct {
}

ProtobufMarshalizerMock implements marshaling with protobuf

func (*ProtobufMarshalizerMock) IsInterfaceNil

func (x *ProtobufMarshalizerMock) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

func (*ProtobufMarshalizerMock) Marshal

func (x *ProtobufMarshalizerMock) Marshal(obj interface{}) ([]byte, error)

Marshal does the actual serialization of an object through protobuf

func (*ProtobufMarshalizerMock) Unmarshal

func (x *ProtobufMarshalizerMock) Unmarshal(obj interface{}, buff []byte) error

Unmarshal does the actual deserialization of an object through protobuf

type PubkeyConverterStub

type PubkeyConverterStub struct {
	LenCalled    func() int
	DecodeCalled func(humanReadable string) ([]byte, error)
	EncodeCalled func(pkBytes []byte) string
}

PubkeyConverterStub -

func (*PubkeyConverterStub) Decode

func (pcs *PubkeyConverterStub) Decode(humanReadable string) ([]byte, error)

Decode -

func (*PubkeyConverterStub) Encode

func (pcs *PubkeyConverterStub) Encode(pkBytes []byte) string

Encode -

func (*PubkeyConverterStub) IsInterfaceNil

func (pcs *PubkeyConverterStub) IsInterfaceNil() bool

IsInterfaceNil -

func (*PubkeyConverterStub) Len

func (pcs *PubkeyConverterStub) Len() int

Len -

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)
	RequestMiniBlocksHandlerCalled     func(destShardID uint32, miniblocksHashes [][]byte)
	RequestTrieNodesCalled             func(destShardID uint32, hashes [][]byte, topic string)
	RequestStartOfEpochMetaBlockCalled func(epoch uint32)
}

RequestHandlerStub -

func (*RequestHandlerStub) IsInterfaceNil

func (rhs *RequestHandlerStub) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

func (*RequestHandlerStub) RequestInterval

func (rhs *RequestHandlerStub) RequestInterval() time.Duration

RequestInterval -

func (*RequestHandlerStub) RequestMetaHeader

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

RequestMetaHeader -

func (*RequestHandlerStub) RequestMetaHeaderByNonce

func (rhs *RequestHandlerStub) RequestMetaHeaderByNonce(nonce uint64)

RequestMetaHeaderByNonce -

func (*RequestHandlerStub) RequestMiniBlock

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

RequestMiniBlock -

func (*RequestHandlerStub) RequestMiniBlocks

func (rhs *RequestHandlerStub) RequestMiniBlocks(destShardID uint32, miniblocksHashes [][]byte)

RequestMiniBlocks -

func (*RequestHandlerStub) RequestRewardTransactions

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

RequestRewardTransactions -

func (*RequestHandlerStub) RequestShardHeader

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

RequestShardHeader -

func (*RequestHandlerStub) RequestShardHeaderByNonce

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

RequestShardHeaderByNonce -

func (*RequestHandlerStub) RequestStartOfEpochMetaBlock

func (rhs *RequestHandlerStub) RequestStartOfEpochMetaBlock(epoch uint32)

RequestStartOfEpochMetaBlock -

func (*RequestHandlerStub) RequestTransaction

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

RequestTransaction -

func (*RequestHandlerStub) RequestTrieNodes

func (rhs *RequestHandlerStub) RequestTrieNodes(destShardID uint32, hashes [][]byte, topic string)

RequestTrieNodes -

func (*RequestHandlerStub) RequestUnsignedTransactions

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

RequestUnsignedTransactions -

func (*RequestHandlerStub) SetEpoch

func (rhs *RequestHandlerStub) SetEpoch(_ uint32)

SetEpoch -

type ShardCoordinatorMock

type ShardCoordinatorMock struct {
	SelfID     uint32
	NrOfShards uint32
}

ShardCoordinatorMock -

func (ShardCoordinatorMock) CommunicationIdentifier

func (scm ShardCoordinatorMock) CommunicationIdentifier(destShardID uint32) string

CommunicationIdentifier -

func (ShardCoordinatorMock) ComputeId

func (scm ShardCoordinatorMock) ComputeId(_ []byte) uint32

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(_, _ []byte) bool

SameShard -

func (ShardCoordinatorMock) SelfId

func (scm ShardCoordinatorMock) SelfId() uint32

SelfId -

func (ShardCoordinatorMock) SetSelfId

func (scm ShardCoordinatorMock) SetSelfId(_ uint32) error

SetSelfId -

type StorerStub

type StorerStub struct {
	PutCalled              func(key, data []byte) error
	GetCalled              func(key []byte) ([]byte, error)
	GetFromEpochCalled     func(key []byte, epoch uint32) ([]byte, error)
	GetBulkFromEpochCalled func(keys [][]byte, epoch uint32) (map[string][]byte, error)
	HasCalled              func(key []byte) error
	HasInEpochCalled       func(key []byte, epoch uint32) error
	SearchFirstCalled      func(key []byte) ([]byte, error)
	RemoveCalled           func(key []byte) error
	ClearCacheCalled       func()
	DestroyUnitCalled      func() error
	RangeKeysCalled        func(handler func(key []byte, val []byte) bool)
	PutInEpochCalled       func(key, data []byte, epoch uint32) error
	GetOldestEpochCalled   func() (uint32, error)
	CloseCalled            func() error
}

StorerStub -

func (*StorerStub) ClearCache

func (ss *StorerStub) ClearCache()

ClearCache -

func (*StorerStub) Close

func (ss *StorerStub) Close() error

Close -

func (*StorerStub) DestroyUnit

func (ss *StorerStub) DestroyUnit() error

DestroyUnit -

func (*StorerStub) Get

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

Get -

func (*StorerStub) GetBulkFromEpoch

func (ss *StorerStub) GetBulkFromEpoch(keys [][]byte, epoch uint32) (map[string][]byte, error)

GetBulkFromEpoch -

func (*StorerStub) GetFromEpoch

func (ss *StorerStub) GetFromEpoch(key []byte, epoch uint32) ([]byte, error)

GetFromEpoch -

func (*StorerStub) GetOldestEpoch

func (ss *StorerStub) GetOldestEpoch() (uint32, error)

GetOldestEpoch -

func (*StorerStub) Has

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

Has -

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

Put -

func (*StorerStub) PutInEpoch

func (ss *StorerStub) PutInEpoch(key, data []byte, epoch uint32) error

PutInEpoch -

func (*StorerStub) RangeKeys

func (ss *StorerStub) RangeKeys(handler func(key []byte, val []byte) bool)

RangeKeys -

func (*StorerStub) Remove

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

Remove -

func (*StorerStub) SearchFirst

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

SearchFirst -

type UpdaterStub

type UpdaterStub struct {
	UpdateCalled func(key, value []byte) error
}

UpdaterStub -

func (*UpdaterStub) IsInterfaceNil

func (updater *UpdaterStub) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

func (*UpdaterStub) Update

func (updater *UpdaterStub) Update(key, value []byte) error

Update -

Jump to

Keyboard shortcuts

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