mock

package
v1.1.6 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2020 License: GPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrMockMarshalizer = errors.New("MarshalizerMock generic error")

ErrMockMarshalizer -

Functions

func NewPersisterMock

func NewPersisterMock() *persisterMock

NewPersisterMock -

Types

type AccountsStub

type AccountsStub struct {
	GetExistingAccountCalled func(addressContainer []byte) (state.AccountHandler, error)
	LoadAccountCalled        func(container []byte) (state.AccountHandler, error)
	SaveAccountCalled        func(account state.AccountHandler) error
	RemoveAccountCalled      func(addressContainer []byte) error
	CommitCalled             func() ([]byte, error)
	JournalLenCalled         func() int
	RevertToSnapshotCalled   func(snapshot int) error
	RootHashCalled           func() ([]byte, error)
	RecreateTrieCalled       func(rootHash []byte) error
	PruneTrieCalled          func(rootHash []byte, identifier data.TriePruningIdentifier)
	CancelPruneCalled        func(rootHash []byte, identifier data.TriePruningIdentifier)
	SnapshotStateCalled      func(rootHash []byte)
	SetStateCheckpointCalled func(rootHash []byte)
	IsPruningEnabledCalled   func() bool
	GetAllLeavesCalled       func(rootHash []byte) (map[string][]byte, error)
	RecreateAllTriesCalled   func(rootHash []byte) (map[string]data.Trie, error)
	GetNumCheckpointsCalled  func() uint32
}

AccountsStub -

func (*AccountsStub) CancelPrune

func (as *AccountsStub) CancelPrune(rootHash []byte, identifier data.TriePruningIdentifier)

CancelPrune -

func (*AccountsStub) Commit

func (as *AccountsStub) Commit() ([]byte, error)

Commit -

func (*AccountsStub) GetAllLeaves

func (as *AccountsStub) GetAllLeaves(rootHash []byte) (map[string][]byte, error)

GetAllLeaves -

func (*AccountsStub) GetExistingAccount

func (as *AccountsStub) GetExistingAccount(addressContainer []byte) (state.AccountHandler, error)

GetExistingAccount -

func (*AccountsStub) GetNumCheckpoints

func (as *AccountsStub) GetNumCheckpoints() uint32

GetNumCheckpoints -

func (*AccountsStub) IsInterfaceNil

func (as *AccountsStub) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

func (*AccountsStub) IsPruningEnabled

func (as *AccountsStub) IsPruningEnabled() bool

IsPruningEnabled -

func (*AccountsStub) JournalLen

func (as *AccountsStub) JournalLen() int

JournalLen -

func (*AccountsStub) LoadAccount

func (as *AccountsStub) LoadAccount(address []byte) (state.AccountHandler, error)

LoadAccount -

func (*AccountsStub) PruneTrie

func (as *AccountsStub) PruneTrie(rootHash []byte, identifier data.TriePruningIdentifier)

PruneTrie -

func (*AccountsStub) RecreateAllTries

func (as *AccountsStub) RecreateAllTries(rootHash []byte) (map[string]data.Trie, error)

RecreateAllTries -

func (*AccountsStub) RecreateTrie

func (as *AccountsStub) RecreateTrie(rootHash []byte) error

RecreateTrie -

func (*AccountsStub) RemoveAccount

func (as *AccountsStub) RemoveAccount(addressContainer []byte) error

RemoveAccount -

func (*AccountsStub) RevertToSnapshot

func (as *AccountsStub) RevertToSnapshot(snapshot int) error

RevertToSnapshot -

func (*AccountsStub) RootHash

func (as *AccountsStub) RootHash() ([]byte, error)

RootHash -

func (*AccountsStub) SaveAccount

func (as *AccountsStub) SaveAccount(account state.AccountHandler) error

SaveAccount -

func (*AccountsStub) SetStateCheckpoint

func (as *AccountsStub) SetStateCheckpoint(rootHash []byte)

SetStateCheckpoint -

func (*AccountsStub) SnapshotState

func (as *AccountsStub) SnapshotState(rootHash []byte)

SnapshotState -

type DataReplayerStub

type DataReplayerStub struct {
	RangeCalled func(handler func(persistedData storer2ElasticData.RoundPersistedData) bool) error
}

DataReplayerStub -

func (*DataReplayerStub) IsInterfaceNil

func (d *DataReplayerStub) IsInterfaceNil() bool

IsInterfaceNil -

func (*DataReplayerStub) Range

func (d *DataReplayerStub) Range(handler func(persistedData storer2ElasticData.RoundPersistedData) bool) error

Range -

type DatabaseReaderStub

type DatabaseReaderStub struct {
	GetDatabaseInfoCalled       func() ([]*databasereader.DatabaseInfo, error)
	GetStaticDatabaseInfoCalled func() ([]*databasereader.DatabaseInfo, error)
	GetHeadersCalled            func(dbInfo *databasereader.DatabaseInfo) ([]data.HeaderHandler, error)
	LoadPersisterCalled         func(dbInfo *databasereader.DatabaseInfo, unit string) (storage.Persister, error)
	LoadStaticPersisterCalled   func(dbInfo *databasereader.DatabaseInfo, unit string) (storage.Persister, error)
}

DatabaseReaderStub -

func (*DatabaseReaderStub) GetDatabaseInfo

func (d *DatabaseReaderStub) GetDatabaseInfo() ([]*databasereader.DatabaseInfo, error)

GetDatabaseInfo -

func (*DatabaseReaderStub) GetHeaders

GetHeaders -

func (*DatabaseReaderStub) GetStaticDatabaseInfo

func (d *DatabaseReaderStub) GetStaticDatabaseInfo() ([]*databasereader.DatabaseInfo, error)

GetStaticDatabaseInfo -

func (*DatabaseReaderStub) IsInterfaceNil

func (d *DatabaseReaderStub) IsInterfaceNil() bool

IsInterfaceNil -

func (*DatabaseReaderStub) LoadPersister

func (d *DatabaseReaderStub) LoadPersister(dbInfo *databasereader.DatabaseInfo, unit string) (storage.Persister, error)

LoadPersister -

func (*DatabaseReaderStub) LoadStaticPersister

func (d *DatabaseReaderStub) LoadStaticPersister(dbInfo *databasereader.DatabaseInfo, unit string) (storage.Persister, error)

LoadStaticPersister -

type DirectoryReaderStub

type DirectoryReaderStub struct {
	ListFilesAsStringCalled       func(directoryPath string) ([]string, error)
	ListDirectoriesAsStringCalled func(directoryPath string) ([]string, error)
	ListAllAsStringCalled         func(directoryPath string) ([]string, error)
}

DirectoryReaderStub -

func (*DirectoryReaderStub) IsInterfaceNil

func (d *DirectoryReaderStub) IsInterfaceNil() bool

IsInterfaceNil -

func (*DirectoryReaderStub) ListAllAsString

func (d *DirectoryReaderStub) ListAllAsString(directoryPath string) ([]string, error)

ListAllAsString -

func (*DirectoryReaderStub) ListDirectoriesAsString

func (d *DirectoryReaderStub) ListDirectoriesAsString(directoryPath string) ([]string, error)

ListDirectoriesAsString -

func (*DirectoryReaderStub) ListFilesAsString

func (d *DirectoryReaderStub) ListFilesAsString(directoryPath string) ([]string, error)

ListFilesAsString -

type ElasticIndexerStub

type ElasticIndexerStub struct {
	SetTxLogsProcessorCalled func(txLogsProc process.TransactionLogProcessorDatabase)
	SaveBlockCalled          func(body data.BodyHandler, header data.HeaderHandler,
		txPool map[string]data.TransactionHandler, signersIndexes []uint64, notarizedHeadersHashes []string, headerHash []byte)
	SaveRoundsInfosCalled       func(roundsInfos []workItems.RoundInfo)
	UpdateTPSCalled             func(tpsBenchmark statistics.TPSBenchmark)
	SaveValidatorsPubKeysCalled func(validatorsPubKeys map[uint32][][]byte, epoch uint32)
	SaveValidatorsRatingCalled  func(indexID string, infoRating []workItems.ValidatorRatingInfo)
}

ElasticIndexerStub -

func (*ElasticIndexerStub) Close added in v1.1.6

func (e *ElasticIndexerStub) Close() error

Close -

func (*ElasticIndexerStub) IsInterfaceNil

func (e *ElasticIndexerStub) IsInterfaceNil() bool

IsInterfaceNil -

func (*ElasticIndexerStub) IsNilIndexer

func (e *ElasticIndexerStub) IsNilIndexer() bool

IsNilIndexer -

func (*ElasticIndexerStub) RevertIndexedBlock added in v1.1.6

func (e *ElasticIndexerStub) RevertIndexedBlock(_ data.HeaderHandler, _ data.BodyHandler)

RevertIndexedBlock -

func (*ElasticIndexerStub) SaveAccounts added in v1.1.6

func (e *ElasticIndexerStub) SaveAccounts(_ []state.UserAccountHandler)

SaveAccounts -

func (*ElasticIndexerStub) SaveBlock

func (e *ElasticIndexerStub) SaveBlock(body data.BodyHandler, header data.HeaderHandler,
	txPool map[string]data.TransactionHandler, signersIndexes []uint64, notarizedHeadersHashes []string, headerHash []byte)

SaveBlock -

func (*ElasticIndexerStub) SaveRoundsInfo added in v1.1.6

func (e *ElasticIndexerStub) SaveRoundsInfo(roundsInfos []workItems.RoundInfo)

SaveRoundsInfo -

func (*ElasticIndexerStub) SaveValidatorsPubKeys

func (e *ElasticIndexerStub) SaveValidatorsPubKeys(validatorsPubKeys map[uint32][][]byte, epoch uint32)

SaveValidatorsPubKeys -

func (*ElasticIndexerStub) SaveValidatorsRating

func (e *ElasticIndexerStub) SaveValidatorsRating(indexID string, infoRating []workItems.ValidatorRatingInfo)

SaveValidatorsRating -

func (*ElasticIndexerStub) SetTxLogsProcessor

func (e *ElasticIndexerStub) SetTxLogsProcessor(txLogsProc process.TransactionLogProcessorDatabase)

SetTxLogsProcessor -

func (*ElasticIndexerStub) UpdateTPS

func (e *ElasticIndexerStub) UpdateTPS(tpsBenchmark statistics.TPSBenchmark)

UpdateTPS -

type GenesisNodesSetupHandlerStub

type GenesisNodesSetupHandlerStub struct {
	InitialNodesInfoForShardCalled       func(shardId uint32) ([]sharding.GenesisNodeInfoHandler, []sharding.GenesisNodeInfoHandler, error)
	InitialNodesInfoCalled               func() (map[uint32][]sharding.GenesisNodeInfoHandler, map[uint32][]sharding.GenesisNodeInfoHandler)
	GetStartTimeCalled                   func() int64
	GetRoundDurationCalled               func() uint64
	GetChainIdCalled                     func() string
	GetMinTransactionVersionCalled       func() uint32
	GetShardConsensusGroupSizeCalled     func() uint32
	GetMetaConsensusGroupSizeCalled      func() uint32
	MinNumberOfShardNodesCalled          func() uint32
	MinNumberOfMetaNodesCalled           func() uint32
	GetHysteresisCalled                  func() float32
	GetAdaptivityCalled                  func() bool
	NumberOfShardsCalled                 func() uint32
	MinNumberOfNodesCalled               func() uint32
	MinNumberOfNodesWithHysteresisCalled func() uint32
}

GenesisNodesSetupHandlerStub -

func (*GenesisNodesSetupHandlerStub) GetAdaptivity

func (g *GenesisNodesSetupHandlerStub) GetAdaptivity() bool

GetAdaptivity -

func (*GenesisNodesSetupHandlerStub) GetChainId

func (g *GenesisNodesSetupHandlerStub) GetChainId() string

GetChainId -

func (*GenesisNodesSetupHandlerStub) GetHysteresis

func (g *GenesisNodesSetupHandlerStub) GetHysteresis() float32

GetHysteresis -

func (*GenesisNodesSetupHandlerStub) GetMetaConsensusGroupSize

func (g *GenesisNodesSetupHandlerStub) GetMetaConsensusGroupSize() uint32

GetMetaConsensusGroupSize -

func (*GenesisNodesSetupHandlerStub) GetMinTransactionVersion

func (g *GenesisNodesSetupHandlerStub) GetMinTransactionVersion() uint32

GetMinTransactionVersion -

func (*GenesisNodesSetupHandlerStub) GetRoundDuration

func (g *GenesisNodesSetupHandlerStub) GetRoundDuration() uint64

GetRoundDuration -

func (*GenesisNodesSetupHandlerStub) GetShardConsensusGroupSize

func (g *GenesisNodesSetupHandlerStub) GetShardConsensusGroupSize() uint32

GetShardConsensusGroupSize -

func (*GenesisNodesSetupHandlerStub) GetStartTime

func (g *GenesisNodesSetupHandlerStub) GetStartTime() int64

GetStartTime -

func (*GenesisNodesSetupHandlerStub) InitialNodesInfo

InitialNodesInfo -

func (*GenesisNodesSetupHandlerStub) InitialNodesInfoForShard

InitialNodesInfoForShard -

func (*GenesisNodesSetupHandlerStub) IsInterfaceNil

func (g *GenesisNodesSetupHandlerStub) IsInterfaceNil() bool

IsInterfaceNil -

func (*GenesisNodesSetupHandlerStub) MinNumberOfMetaNodes

func (g *GenesisNodesSetupHandlerStub) MinNumberOfMetaNodes() uint32

MinNumberOfMetaNodes -

func (*GenesisNodesSetupHandlerStub) MinNumberOfNodes

func (g *GenesisNodesSetupHandlerStub) MinNumberOfNodes() uint32

MinNumberOfNodes -

func (*GenesisNodesSetupHandlerStub) MinNumberOfNodesWithHysteresis added in v1.1.3

func (g *GenesisNodesSetupHandlerStub) MinNumberOfNodesWithHysteresis() uint32

MinNumberOfNodesWithHysteresis -

func (*GenesisNodesSetupHandlerStub) MinNumberOfShardNodes

func (g *GenesisNodesSetupHandlerStub) MinNumberOfShardNodes() uint32

MinNumberOfShardNodes -

func (*GenesisNodesSetupHandlerStub) NumberOfShards

func (g *GenesisNodesSetupHandlerStub) NumberOfShards() uint32

NumberOfShards -

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 HeaderMarshalizerStub

type HeaderMarshalizerStub struct {
	UnmarshalShardHeaderCalled func(headerBytes []byte) (*block.Header, error)
	UnmarshalMetaBlockCalled   func(headerBytes []byte) (*block.MetaBlock, error)
}

HeaderMarshalizerStub -

func (*HeaderMarshalizerStub) IsInterfaceNil

func (h *HeaderMarshalizerStub) IsInterfaceNil() bool

IsInterfaceNil -

func (*HeaderMarshalizerStub) UnmarshalMetaBlock

func (h *HeaderMarshalizerStub) UnmarshalMetaBlock(headerBytes []byte) (*block.MetaBlock, error)

UnmarshalMetaBlock -

func (*HeaderMarshalizerStub) UnmarshalShardHeader

func (h *HeaderMarshalizerStub) UnmarshalShardHeader(headerBytes []byte) (*block.Header, error)

UnmarshalShardHeader -

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 NodeInfoMock

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

NodeInfoMock -

func NewNodeInfo

func NewNodeInfo(address []byte, pubKey []byte, shardId uint32, initialRating uint32) *NodeInfoMock

NewNodeInfo -

func (*NodeInfoMock) AddressBytes

func (n *NodeInfoMock) AddressBytes() []byte

AddressBytes -

func (*NodeInfoMock) AssignedShard

func (n *NodeInfoMock) AssignedShard() uint32

AssignedShard -

func (*NodeInfoMock) GetInitialRating

func (n *NodeInfoMock) GetInitialRating() uint32

GetInitialRating -

func (*NodeInfoMock) IsInterfaceNil

func (n *NodeInfoMock) IsInterfaceNil() bool

IsInterfaceNil -

func (*NodeInfoMock) PubKeyBytes

func (n *NodeInfoMock) PubKeyBytes() []byte

PubKeyBytes -

type PersisterFactoryStub

type PersisterFactoryStub struct {
	CreateCalled         func(path string) (storage.Persister, error)
	CreateDisabledCalled func() storage.Persister
}

PersisterFactoryStub -

func (*PersisterFactoryStub) Create

func (pfs *PersisterFactoryStub) Create(path string) (storage.Persister, error)

Create -

func (*PersisterFactoryStub) CreateDisabled

func (pfs *PersisterFactoryStub) CreateDisabled() storage.Persister

CreateDisabled -

func (*PersisterFactoryStub) IsInterfaceNil

func (pfs *PersisterFactoryStub) IsInterfaceNil() bool

IsInterfaceNil -

type PubkeyConverterMock

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

PubkeyConverterMock -

func NewPubkeyConverterMock

func NewPubkeyConverterMock(addressLen int) *PubkeyConverterMock

NewPubkeyConverterMock -

func (*PubkeyConverterMock) Decode

func (pcm *PubkeyConverterMock) Decode(humanReadable string) ([]byte, error)

Decode -

func (*PubkeyConverterMock) Encode

func (pcm *PubkeyConverterMock) Encode(pkBytes []byte) string

Encode -

func (*PubkeyConverterMock) IsInterfaceNil

func (pcm *PubkeyConverterMock) IsInterfaceNil() bool

IsInterfaceNil -

func (*PubkeyConverterMock) Len

func (pcm *PubkeyConverterMock) Len() int

Len -

type RatingsProcessorStub

type RatingsProcessorStub struct {
	IndexRatingsForEpochStartMetaBlockCalled func(metaBlock *block.MetaBlock) error
}

RatingsProcessorStub -

func (*RatingsProcessorStub) IndexRatingsForEpochStartMetaBlock

func (r *RatingsProcessorStub) IndexRatingsForEpochStartMetaBlock(metaBlock *block.MetaBlock) error

IndexRatingsForEpochStartMetaBlock -

func (*RatingsProcessorStub) IsInterfaceNil

func (r *RatingsProcessorStub) IsInterfaceNil() bool

IsInterfaceNil -

type ShardCoordinatorMock

type ShardCoordinatorMock struct {
	ShardID     uint32
	NumOfShards 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 TPSBenchmarkUpdaterStub

type TPSBenchmarkUpdaterStub struct {
	IndexTPSForMetaBlockCalled func(metaBlock *block.MetaBlock)
}

TPSBenchmarkUpdaterStub -

func (*TPSBenchmarkUpdaterStub) IndexTPSForMetaBlock

func (t *TPSBenchmarkUpdaterStub) IndexTPSForMetaBlock(metaBlock *block.MetaBlock)

IndexTPSForMetaBlock -

func (*TPSBenchmarkUpdaterStub) IsInterfaceNil

func (t *TPSBenchmarkUpdaterStub) IsInterfaceNil() bool

IsInterfaceNil -

type Uint64ByteSliceConverterMock

type Uint64ByteSliceConverterMock struct {
}

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

Jump to

Keyboard shortcuts

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