mock

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2019 License: GPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewNonceHashConverterMock

func NewNonceHashConverterMock() *nonceHashConverterMock

func NewOneShardCoordinatorMock

func NewOneShardCoordinatorMock() *oneShardCoordinatorMock

Types

type AccountsStub

type AccountsStub struct {
	AddJournalEntryCalled       func(je state.JournalEntry)
	CommitCalled                func() ([]byte, error)
	GetAccountWithJournalCalled func(addressContainer state.AddressContainer) (state.AccountHandler, error)
	GetExistingAccountCalled    func(addressContainer state.AddressContainer) (state.AccountHandler, error)
	HasAccountStateCalled       func(addressContainer state.AddressContainer) (bool, error)
	JournalLenCalled            func() int
	PutCodeCalled               func(accountHandler state.AccountHandler, code []byte) error
	RemoveAccountCalled         func(addressContainer state.AddressContainer) error
	RemoveCodeCalled            func(codeHash []byte) error
	RetrieveDataTrieCalled      func(acountWrapper state.AccountHandler) error
	RevertToSnapshotCalled      func(snapshot int) error
	SaveAccountStateCalled      func(acountWrapper state.AccountHandler) error
	SaveDataTrieCalled          func(acountWrapper state.AccountHandler) error
	RootHashCalled              func() ([]byte, error)
	RecreateTrieCalled          func(rootHash []byte) error
}

func NewAccountsStub added in v1.0.3

func NewAccountsStub() *AccountsStub

func (*AccountsStub) AddJournalEntry added in v1.0.3

func (aam *AccountsStub) AddJournalEntry(je state.JournalEntry)

func (*AccountsStub) Commit

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

func (*AccountsStub) GetAccountWithJournal added in v1.0.3

func (aam *AccountsStub) GetAccountWithJournal(addressContainer state.AddressContainer) (state.AccountHandler, error)

func (*AccountsStub) GetExistingAccount

func (aam *AccountsStub) GetExistingAccount(addressContainer state.AddressContainer) (state.AccountHandler, error)

func (*AccountsStub) HasAccount added in v1.0.3

func (aam *AccountsStub) HasAccount(addressContainer state.AddressContainer) (bool, error)

func (*AccountsStub) JournalLen

func (aam *AccountsStub) JournalLen() int

func (*AccountsStub) LoadDataTrie added in v1.0.3

func (aam *AccountsStub) LoadDataTrie(accountHandler state.AccountHandler) error

func (*AccountsStub) PutCode added in v1.0.3

func (aam *AccountsStub) PutCode(accountHandler state.AccountHandler, code []byte) error

func (*AccountsStub) RecreateTrie

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

func (*AccountsStub) RemoveAccount

func (aam *AccountsStub) RemoveAccount(addressContainer state.AddressContainer) error

func (*AccountsStub) RemoveCode added in v1.0.3

func (aam *AccountsStub) RemoveCode(codeHash []byte) error

func (*AccountsStub) RevertToSnapshot

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

func (*AccountsStub) RootHash

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

func (*AccountsStub) SaveDataTrie added in v1.0.3

func (aam *AccountsStub) SaveDataTrie(journalizedAccountHandler state.AccountHandler) error

func (*AccountsStub) SaveJournalizedAccount added in v1.0.3

func (aam *AccountsStub) SaveJournalizedAccount(journalizedAccountHandler state.AccountHandler) error

type AddressConverterFake

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

func NewAddressConverterFake

func NewAddressConverterFake(addressLen int, prefix string) *AddressConverterFake

func (*AddressConverterFake) AddressLen

func (acf *AddressConverterFake) AddressLen() int

func (*AddressConverterFake) ConvertToHex

func (acf *AddressConverterFake) ConvertToHex(addressContainer state.AddressContainer) (string, error)

func (*AddressConverterFake) CreateAddressFromHex

func (acf *AddressConverterFake) CreateAddressFromHex(hexAddress string) (state.AddressContainer, error)

func (*AddressConverterFake) CreateAddressFromPublicKeyBytes

func (acf *AddressConverterFake) CreateAddressFromPublicKeyBytes(pubKey []byte) (state.AddressContainer, error)

func (*AddressConverterFake) PrepareAddressBytes

func (acf *AddressConverterFake) PrepareAddressBytes(addressBytes []byte) ([]byte, error)

type AddressConverterStub

type AddressConverterStub struct {
	CreateAddressFromPublicKeyBytesHandler func(pubKey []byte) (state.AddressContainer, error)
	ConvertToHexHandler                    func(addressContainer state.AddressContainer) (string, error)
	CreateAddressFromHexHandler            func(hexAddress string) (state.AddressContainer, error)
	PrepareAddressBytesHandler             func(addressBytes []byte) ([]byte, error)
	AddressLenHandler                      func() int
}

func (AddressConverterStub) AddressLen

func (ac AddressConverterStub) AddressLen() int

func (AddressConverterStub) ConvertToHex

func (ac AddressConverterStub) ConvertToHex(addressContainer state.AddressContainer) (string, error)

func (AddressConverterStub) CreateAddressFromHex

func (ac AddressConverterStub) CreateAddressFromHex(hexAddress string) (state.AddressContainer, error)

func (AddressConverterStub) CreateAddressFromPublicKeyBytes

func (ac AddressConverterStub) CreateAddressFromPublicKeyBytes(pubKey []byte) (state.AddressContainer, error)

func (AddressConverterStub) PrepareAddressBytes

func (ac AddressConverterStub) PrepareAddressBytes(addressBytes []byte) ([]byte, error)

type BlockChainMock

type BlockChainMock struct {
	GetGenesisHeaderCalled          func() data.HeaderHandler
	SetGenesisHeaderCalled          func(handler data.HeaderHandler) error
	GetGenesisHeaderHashCalled      func() []byte
	SetGenesisHeaderHashCalled      func([]byte)
	GetCurrentBlockHeaderCalled     func() data.HeaderHandler
	SetCurrentBlockHeaderCalled     func(data.HeaderHandler) error
	GetCurrentBlockHeaderHashCalled func() []byte
	SetCurrentBlockHeaderHashCalled func([]byte)
	GetCurrentBlockBodyCalled       func() data.BodyHandler
	SetCurrentBlockBodyCalled       func(data.BodyHandler) error
	GetLocalHeightCalled            func() int64
	SetLocalHeightCalled            func(int64)
	GetNetworkHeightCalled          func() int64
	SetNetworkHeightCalled          func(int64)
	HasBadBlockCalled               func([]byte) bool
	PutBadBlockCalled               func([]byte)
}

BlockChainMock is a mock implementation of the blockchain interface

func (*BlockChainMock) GetCurrentBlockBody

func (bc *BlockChainMock) GetCurrentBlockBody() data.BodyHandler

GetCurrentBlockBody returns the tx block body pointer

func (*BlockChainMock) GetCurrentBlockHeader

func (bc *BlockChainMock) GetCurrentBlockHeader() data.HeaderHandler

GetCurrentBlockHeader returns current block header pointer

func (*BlockChainMock) GetCurrentBlockHeaderHash

func (bc *BlockChainMock) GetCurrentBlockHeaderHash() []byte

GetCurrentBlockHeaderHash returns the current block header hash

func (*BlockChainMock) GetGenesisHeader

func (bc *BlockChainMock) GetGenesisHeader() data.HeaderHandler

GetGenesisHeader returns the genesis block header pointer

func (*BlockChainMock) GetGenesisHeaderHash

func (bc *BlockChainMock) GetGenesisHeaderHash() []byte

GetGenesisHeaderHash returns the genesis block header hash

func (*BlockChainMock) GetLocalHeight added in v1.0.3

func (bc *BlockChainMock) GetLocalHeight() int64

GetLocalHeight returns the height of the local chain

func (*BlockChainMock) GetNetworkHeight added in v1.0.3

func (bc *BlockChainMock) GetNetworkHeight() int64

GetNetworkHeight sets the percieved height of the network chain

func (*BlockChainMock) HasBadBlock added in v1.0.3

func (bc *BlockChainMock) HasBadBlock(blockHash []byte) bool

HasBadBlock returns true if the provided hash is blacklisted as a bad block, or false otherwise

func (*BlockChainMock) PutBadBlock added in v1.0.3

func (bc *BlockChainMock) PutBadBlock(blockHash []byte)

PutBadBlock adds the given serialized block to the bad block cache, blacklisting it

func (*BlockChainMock) SetCurrentBlockBody

func (bc *BlockChainMock) SetCurrentBlockBody(body data.BodyHandler) error

SetCurrentBlockBody sets the tx block body pointer

func (*BlockChainMock) SetCurrentBlockHeader

func (bc *BlockChainMock) SetCurrentBlockHeader(header data.HeaderHandler) error

SetCurrentBlockHeader sets current block header pointer

func (*BlockChainMock) SetCurrentBlockHeaderHash

func (bc *BlockChainMock) SetCurrentBlockHeaderHash(hash []byte)

SetCurrentBlockHeaderHash returns the current block header hash

func (*BlockChainMock) SetGenesisHeader

func (bc *BlockChainMock) SetGenesisHeader(genesisBlock data.HeaderHandler) error

SetGenesisHeader sets the genesis block header pointer

func (*BlockChainMock) SetGenesisHeaderHash

func (bc *BlockChainMock) SetGenesisHeaderHash(hash []byte)

SetGenesisHeaderHash sets the genesis block header hash

func (*BlockChainMock) SetLocalHeight added in v1.0.3

func (bc *BlockChainMock) SetLocalHeight(height int64)

SetLocalHeight sets the height of the local chain

func (*BlockChainMock) SetNetworkHeight added in v1.0.3

func (bc *BlockChainMock) SetNetworkHeight(height int64)

SetNetworkHeight sets the percieved height of the network chain

type BlockProcessorStub

type BlockProcessorStub struct {
	ProcessBlockCalled               func(blockChain data.ChainHandler, header data.HeaderHandler, body data.BodyHandler, haveTime func() time.Duration) error
	CommitBlockCalled                func(blockChain data.ChainHandler, header data.HeaderHandler, body data.BodyHandler) error
	RevertAccountStateCalled         func()
	CreateGenesisBlockCalled         func(balances map[string]*big.Int) (data.HeaderHandler, error)
	CreateBlockBodyCalled            func(round uint32, haveTime func() bool) (data.BodyHandler, error)
	RestoreBlockIntoPoolsCalled      func(header data.HeaderHandler, body data.BodyHandler) error
	SetOnRequestTransactionCalled    func(f func(destShardID uint32, txHash []byte))
	CreateBlockHeaderCalled          func(body data.BodyHandler, round uint32, haveTime func() bool) (data.HeaderHandler, error)
	MarshalizedDataToBroadcastCalled func(header data.HeaderHandler, body data.BodyHandler) (map[uint32][]byte, map[uint32][][]byte, error)
	DecodeBlockBodyCalled            func(dta []byte) data.BodyHandler
	DecodeBlockHeaderCalled          func(dta []byte) data.HeaderHandler
	SetLastNotarizedHdrCalled        func(shardId uint32, processedHdr data.HeaderHandler)
}

BlockProcessorStub mocks the implementation for a blockProcessor

func (*BlockProcessorStub) CommitBlock

func (blProcMock *BlockProcessorStub) CommitBlock(blockChain data.ChainHandler, header data.HeaderHandler, body data.BodyHandler) error

CommitBlock mocks the commit of a block

func (*BlockProcessorStub) CreateBlockBody added in v1.0.3

func (blProcMock *BlockProcessorStub) CreateBlockBody(round uint32, haveTime func() bool) (data.BodyHandler, error)

CreateTxBlockBody mocks the creation of a transaction block body

func (BlockProcessorStub) CreateBlockHeader added in v1.0.3

func (blProcMock BlockProcessorStub) CreateBlockHeader(body data.BodyHandler, round uint32, haveTime func() bool) (data.HeaderHandler, error)

func (*BlockProcessorStub) CreateGenesisBlock

func (blProcMock *BlockProcessorStub) CreateGenesisBlock(balances map[string]*big.Int) (data.HeaderHandler, error)

CreateGenesisBlock mocks the creation of a genesis block body

func (BlockProcessorStub) DecodeBlockBody

func (blProcMock BlockProcessorStub) DecodeBlockBody(dta []byte) data.BodyHandler

func (BlockProcessorStub) DecodeBlockHeader

func (blProcMock BlockProcessorStub) DecodeBlockHeader(dta []byte) data.HeaderHandler

func (BlockProcessorStub) MarshalizedDataToBroadcast

func (blProcMock BlockProcessorStub) MarshalizedDataToBroadcast(header data.HeaderHandler, body data.BodyHandler) (map[uint32][]byte, map[uint32][][]byte, error)

func (*BlockProcessorStub) ProcessBlock

func (blProcMock *BlockProcessorStub) ProcessBlock(blockChain data.ChainHandler, header data.HeaderHandler, body data.BodyHandler, haveTime func() time.Duration) error

ProcessBlock mocks pocessing a block

func (*BlockProcessorStub) RestoreBlockIntoPools

func (blProcMock *BlockProcessorStub) RestoreBlockIntoPools(header data.HeaderHandler, body data.BodyHandler) error

func (*BlockProcessorStub) RevertAccountState

func (blProcMock *BlockProcessorStub) RevertAccountState()

RevertAccountState mocks revert of the accounts state

func (BlockProcessorStub) SetLastNotarizedHdr added in v1.0.3

func (blProcMock BlockProcessorStub) SetLastNotarizedHdr(shardId uint32, processedHdr data.HeaderHandler)

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

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

func (*CacherStub) Len

func (cs *CacherStub) Len() 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 ChainHandlerStub

type ChainHandlerStub struct {
	GetGenesisHeaderCalled     func() data.HeaderHandler
	GetGenesisHeaderHashCalled func() []byte
	SetGenesisHeaderCalled     func(gb data.HeaderHandler) error
	SetGenesisHeaderHashCalled func(hash []byte)
}

func (*ChainHandlerStub) GetCurrentBlockBody

func (chs *ChainHandlerStub) GetCurrentBlockBody() data.BodyHandler

func (*ChainHandlerStub) GetCurrentBlockHeader

func (chs *ChainHandlerStub) GetCurrentBlockHeader() data.HeaderHandler

func (*ChainHandlerStub) GetCurrentBlockHeaderHash

func (chs *ChainHandlerStub) GetCurrentBlockHeaderHash() []byte

func (*ChainHandlerStub) GetGenesisHeader

func (chs *ChainHandlerStub) GetGenesisHeader() data.HeaderHandler

func (*ChainHandlerStub) GetGenesisHeaderHash

func (chs *ChainHandlerStub) GetGenesisHeaderHash() []byte

func (*ChainHandlerStub) GetLocalHeight added in v1.0.3

func (chs *ChainHandlerStub) GetLocalHeight() int64

func (*ChainHandlerStub) GetNetworkHeight added in v1.0.3

func (chs *ChainHandlerStub) GetNetworkHeight() int64

func (*ChainHandlerStub) HasBadBlock added in v1.0.3

func (chs *ChainHandlerStub) HasBadBlock(blockHash []byte) bool

func (*ChainHandlerStub) PutBadBlock added in v1.0.3

func (chs *ChainHandlerStub) PutBadBlock(blockHash []byte)

func (*ChainHandlerStub) SetCurrentBlockBody

func (chs *ChainHandlerStub) SetCurrentBlockBody(body data.BodyHandler) error

func (*ChainHandlerStub) SetCurrentBlockHeader

func (chs *ChainHandlerStub) SetCurrentBlockHeader(bh data.HeaderHandler) error

func (*ChainHandlerStub) SetCurrentBlockHeaderHash

func (chs *ChainHandlerStub) SetCurrentBlockHeaderHash(hash []byte)

func (*ChainHandlerStub) SetGenesisHeader

func (chs *ChainHandlerStub) SetGenesisHeader(gb data.HeaderHandler) error

func (*ChainHandlerStub) SetGenesisHeaderHash

func (chs *ChainHandlerStub) SetGenesisHeaderHash(hash []byte)

func (*ChainHandlerStub) SetLocalHeight added in v1.0.3

func (chs *ChainHandlerStub) SetLocalHeight(height int64)

func (*ChainHandlerStub) SetNetworkHeight added in v1.0.3

func (chs *ChainHandlerStub) SetNetworkHeight(height int64)

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

type ForkDetectorMock struct {
	AddHeaderCalled                 func(header data.HeaderHandler, hash []byte, state process.BlockHeaderState) error
	RemoveHeadersCalled             func(nonce uint64, hash []byte)
	CheckForkCalled                 func() (bool, uint64)
	GetHighestFinalBlockNonceCalled func() uint64
	ProbableHighestNonceCalled      func() uint64
}

ForkDetectorMock is a mock implementation for the ForkDetector interface

func (*ForkDetectorMock) AddHeader

func (f *ForkDetectorMock) AddHeader(header data.HeaderHandler, hash []byte, state process.BlockHeaderState) error

AddHeader is a mock implementation for AddHeader

func (*ForkDetectorMock) CheckFork

func (f *ForkDetectorMock) CheckFork() (bool, uint64)

CheckFork is a mock implementation for CheckFork

func (*ForkDetectorMock) GetHighestFinalBlockNonce

func (f *ForkDetectorMock) GetHighestFinalBlockNonce() uint64

GetHighestFinalBlockNonce is a mock implementation for GetHighestFinalBlockNonce

func (*ForkDetectorMock) ProbableHighestNonce

func (f *ForkDetectorMock) ProbableHighestNonce() uint64

ProbableHighestNonce is a mock implementation for GetProbableHighestNonce

func (*ForkDetectorMock) RemoveHeaders added in v1.0.3

func (f *ForkDetectorMock) RemoveHeaders(nonce uint64, hash []byte)

RemoveHeaders is a mock implementation for RemoveHeaders

type GeneratorSuite

type GeneratorSuite struct {
	SuiteMock
	CreateKeyStub func(cipher.Stream) crypto.Scalar
}

func (*GeneratorSuite) CreateKey

func (gs *GeneratorSuite) CreateKey(c cipher.Stream) crypto.Scalar

type HasherFake

type HasherFake struct {
}

HasherFake that will be used for testing

func (HasherFake) Compute

func (sha HasherFake) Compute(s string) []byte

Compute will output the SHA's equivalent of the input string

func (HasherFake) EmptyHash

func (sha HasherFake) EmptyHash() []byte

EmptyHash will return the equivalent of empty string SHA's

func (HasherFake) Size

func (HasherFake) Size() int

Size return the required size in bytes

type HasherMock

type HasherMock struct {
	ComputeCalled   func(s string) []byte
	EmptyHashCalled func() []byte
}

func (HasherMock) Compute

func (hash HasherMock) Compute(s string) []byte

func (HasherMock) EmptyHash

func (hash HasherMock) EmptyHash() []byte

func (HasherMock) Size

func (HasherMock) Size() int

type InterceptorsContainerStub

type InterceptorsContainerStub struct {
}

func (*InterceptorsContainerStub) Add

func (*InterceptorsContainerStub) AddMultiple

func (ics *InterceptorsContainerStub) AddMultiple(keys []string, interceptors []process.Interceptor) error

func (*InterceptorsContainerStub) Get

func (*InterceptorsContainerStub) Len

func (ics *InterceptorsContainerStub) Len() int

func (*InterceptorsContainerStub) Remove

func (ics *InterceptorsContainerStub) Remove(key string)

func (*InterceptorsContainerStub) Replace

func (ics *InterceptorsContainerStub) Replace(key string, val process.Interceptor) error

type KeyGenMock

type KeyGenMock struct {
	GeneratePairMock            func() (crypto.PrivateKey, crypto.PublicKey)
	PrivateKeyFromByteArrayMock func(b []byte) (crypto.PrivateKey, error)
	PublicKeyFromByteArrayMock  func(b []byte) (crypto.PublicKey, error)
	SuiteMock                   func() crypto.Suite
}

func (*KeyGenMock) GeneratePair

func (keyGen *KeyGenMock) GeneratePair() (crypto.PrivateKey, crypto.PublicKey)

func (*KeyGenMock) PrivateKeyFromByteArray

func (keyGen *KeyGenMock) PrivateKeyFromByteArray(b []byte) (crypto.PrivateKey, error)

func (*KeyGenMock) PublicKeyFromByteArray

func (keyGen *KeyGenMock) PublicKeyFromByteArray(b []byte) (crypto.PublicKey, error)

func (*KeyGenMock) Suite

func (keyGen *KeyGenMock) Suite() crypto.Suite

type MarshalizerFake

type MarshalizerFake struct {
	Fail bool
}

MarshalizerFake that will be used for testing

func (*MarshalizerFake) Marshal

func (mm *MarshalizerFake) Marshal(obj interface{}) ([]byte, error)

Marshal converts the input object in a slice of bytes

func (*MarshalizerFake) Unmarshal

func (mm *MarshalizerFake) Unmarshal(obj interface{}, buff []byte) error

Unmarshal applies the serialized values over an instantiated object

type MarshalizerMock

type MarshalizerMock struct {
	MarshalHandler   func(obj interface{}) ([]byte, error)
	UnmarshalHandler func(obj interface{}, buff []byte) error
}

func (MarshalizerMock) Marshal

func (j MarshalizerMock) Marshal(obj interface{}) ([]byte, error)

func (MarshalizerMock) Unmarshal

func (j MarshalizerMock) Unmarshal(obj interface{}, buff []byte) error

type MessengerStub

type MessengerStub struct {
	CloseCalled                      func() error
	CreateTopicCalled                func(name string, createChannelForTopic bool) error
	HasTopicCalled                   func(name string) bool
	HasTopicValidatorCalled          func(name string) bool
	BroadcastOnChannelCalled         func(channel string, topic string, buff []byte)
	BroadcastCalled                  func(topic string, buff []byte)
	RegisterMessageProcessorCalled   func(topic string, handler p2p.MessageProcessor) error
	BootstrapCalled                  func() error
	PeerAddressCalled                func(pid p2p.PeerID) string
	BroadcastOnChannelBlockingCalled func(channel string, topic string, buff []byte)
}

func (*MessengerStub) Bootstrap

func (ms *MessengerStub) Bootstrap() error

func (*MessengerStub) Broadcast

func (ms *MessengerStub) Broadcast(topic string, buff []byte)

func (*MessengerStub) BroadcastOnChannel

func (ms *MessengerStub) BroadcastOnChannel(channel string, topic string, buff []byte)

func (*MessengerStub) BroadcastOnChannelBlocking

func (ms *MessengerStub) BroadcastOnChannelBlocking(channel string, topic string, buff []byte)

func (*MessengerStub) Close

func (ms *MessengerStub) Close() error

func (*MessengerStub) CreateTopic

func (ms *MessengerStub) CreateTopic(name string, createChannelForTopic bool) error

func (*MessengerStub) HasTopic

func (ms *MessengerStub) HasTopic(name string) bool

func (*MessengerStub) HasTopicValidator

func (ms *MessengerStub) HasTopicValidator(name string) bool

func (*MessengerStub) PeerAddress

func (ms *MessengerStub) PeerAddress(pid p2p.PeerID) string

func (*MessengerStub) RegisterMessageProcessor

func (ms *MessengerStub) RegisterMessageProcessor(topic string, handler p2p.MessageProcessor) error

type MetaPoolsHolderStub added in v1.0.3

type MetaPoolsHolderStub struct {
	MetaChainBlocksCalled    func() storage.Cacher
	MiniBlockHashesCalled    func() dataRetriever.ShardedDataCacherNotifier
	ShardHeadersCalled       func() storage.Cacher
	ShardHeadersNoncesCalled func() dataRetriever.Uint64Cacher
	MetaBlockNoncesCalled    func() dataRetriever.Uint64Cacher
}

func (*MetaPoolsHolderStub) MetaBlockNonces added in v1.0.3

func (mphs *MetaPoolsHolderStub) MetaBlockNonces() dataRetriever.Uint64Cacher

func (*MetaPoolsHolderStub) MetaChainBlocks added in v1.0.3

func (mphs *MetaPoolsHolderStub) MetaChainBlocks() storage.Cacher

func (*MetaPoolsHolderStub) MiniBlockHashes added in v1.0.3

func (*MetaPoolsHolderStub) ShardHeaders added in v1.0.3

func (mphs *MetaPoolsHolderStub) ShardHeaders() storage.Cacher

func (*MetaPoolsHolderStub) ShardHeadersNonces added in v1.0.3

func (mphs *MetaPoolsHolderStub) ShardHeadersNonces() dataRetriever.Uint64Cacher

type MultisignMock

type MultisignMock struct {
}

func (*MultisignMock) AggregateCommitments

func (mm *MultisignMock) AggregateCommitments(bitmap []byte) error

func (*MultisignMock) AggregateSigs

func (mm *MultisignMock) AggregateSigs(bitmap []byte) ([]byte, error)

func (*MultisignMock) Commitment

func (mm *MultisignMock) Commitment(index uint16) ([]byte, error)

func (*MultisignMock) CommitmentHash

func (mm *MultisignMock) CommitmentHash(index uint16) ([]byte, error)

func (*MultisignMock) Create

func (mm *MultisignMock) Create(pubKeys []string, index uint16) (crypto.MultiSigner, error)

func (*MultisignMock) CreateCommitment

func (mm *MultisignMock) CreateCommitment() (commSecret []byte, commitment []byte)

func (*MultisignMock) CreateSignatureShare

func (mm *MultisignMock) CreateSignatureShare(msg []byte, bitmap []byte) ([]byte, error)

func (*MultisignMock) Reset

func (mm *MultisignMock) Reset(pubKeys []string, index uint16) error

func (*MultisignMock) SetAggregatedSig

func (mm *MultisignMock) SetAggregatedSig([]byte) error

func (*MultisignMock) SignatureShare

func (mm *MultisignMock) SignatureShare(index uint16) ([]byte, error)

func (*MultisignMock) StoreCommitment

func (mm *MultisignMock) StoreCommitment(index uint16, value []byte) error

func (*MultisignMock) StoreCommitmentHash

func (mm *MultisignMock) StoreCommitmentHash(index uint16, commHash []byte) error

func (*MultisignMock) StoreSignatureShare

func (mm *MultisignMock) StoreSignatureShare(index uint16, sig []byte) error

func (*MultisignMock) Verify

func (mm *MultisignMock) Verify(msg []byte, bitmap []byte) error

func (*MultisignMock) VerifySignatureShare

func (mm *MultisignMock) VerifySignatureShare(index uint16, sig []byte, msg []byte, bitmap []byte) error

type P2PMessageStub

type P2PMessageStub struct {
	FromField      []byte
	DataField      []byte
	SeqNoField     []byte
	TopicIDsField  []string
	SignatureField []byte
	KeyField       []byte
	PeerField      p2p.PeerID
}

func (*P2PMessageStub) Data

func (msg *P2PMessageStub) Data() []byte

func (*P2PMessageStub) From

func (msg *P2PMessageStub) From() []byte

func (*P2PMessageStub) Key

func (msg *P2PMessageStub) Key() []byte

func (*P2PMessageStub) Peer

func (msg *P2PMessageStub) Peer() p2p.PeerID

func (*P2PMessageStub) SeqNo

func (msg *P2PMessageStub) SeqNo() []byte

func (*P2PMessageStub) Signature

func (msg *P2PMessageStub) Signature() []byte

func (*P2PMessageStub) TopicIDs added in v1.0.3

func (msg *P2PMessageStub) TopicIDs() []string

type PoolsHolderStub

type PoolsHolderStub struct {
	HeadersCalled              func() storage.Cacher
	HeadersNoncesCalled        func() dataRetriever.Uint64Cacher
	PeerChangesBlocksCalled    func() storage.Cacher
	TransactionsCalled         func() dataRetriever.ShardedDataCacherNotifier
	SmartContractResultsCalled func() dataRetriever.ShardedDataCacherNotifier
	MiniBlocksCalled           func() storage.Cacher
	MetaBlocksCalled           func() storage.Cacher
	MetaHeadersNoncesCalled    func() dataRetriever.Uint64Cacher
}

func (*PoolsHolderStub) Headers

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

func (*PoolsHolderStub) HeadersNonces added in v1.0.3

func (phs *PoolsHolderStub) HeadersNonces() dataRetriever.Uint64Cacher

func (*PoolsHolderStub) MetaBlocks added in v1.0.3

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

func (*PoolsHolderStub) MetaHeadersNonces added in v1.0.3

func (phs *PoolsHolderStub) MetaHeadersNonces() dataRetriever.Uint64Cacher

func (*PoolsHolderStub) MiniBlocks

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

func (*PoolsHolderStub) PeerChangesBlocks

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

func (*PoolsHolderStub) SmartContractResults added in v1.0.3

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

func (*PoolsHolderStub) Transactions

type PrivateKeyStub

type PrivateKeyStub struct {
	ToByteArrayHandler    func() ([]byte, error)
	GeneratePublicHandler func() crypto.PublicKey
	SuiteHandler          func() crypto.Suite
	ScalarHandler         func() crypto.Scalar
}

func (*PrivateKeyStub) GeneratePublic

func (sk *PrivateKeyStub) GeneratePublic() crypto.PublicKey

func (*PrivateKeyStub) Scalar

func (sk *PrivateKeyStub) Scalar() crypto.Scalar

func (*PrivateKeyStub) Suite

func (sk *PrivateKeyStub) Suite() crypto.Suite

func (*PrivateKeyStub) ToByteArray

func (sk *PrivateKeyStub) ToByteArray() ([]byte, error)

type ProposerResolverStub added in v1.0.3

type ProposerResolverStub struct {
	ResolveProposerCalled func(shardId uint32, roundIndex uint32, prevRandomSeed []byte) ([]byte, error)
}

func (*ProposerResolverStub) ResolveProposer added in v1.0.3

func (prs *ProposerResolverStub) ResolveProposer(shardId uint32, roundIndex uint32, prevRandomSeed []byte) ([]byte, error)

type PublicKeyMock

type PublicKeyMock struct {
	ToByteArrayHandler func() ([]byte, error)
	SuiteCalled        func() crypto.Suite
	PointCalled        func() crypto.Point
}

func (*PublicKeyMock) Point

func (sspk *PublicKeyMock) Point() crypto.Point

func (*PublicKeyMock) Suite

func (sspk *PublicKeyMock) Suite() crypto.Suite

func (*PublicKeyMock) ToByteArray

func (sspk *PublicKeyMock) ToByteArray() ([]byte, error)

type ResolversFinderStub

type ResolversFinderStub struct {
	GetCalled                func(key string) (dataRetriever.Resolver, error)
	AddCalled                func(key string, val dataRetriever.Resolver) error
	ReplaceCalled            func(key string, val dataRetriever.Resolver) error
	RemoveCalled             func(key string)
	LenCalled                func() int
	IntraShardResolverCalled func(baseTopic string) (dataRetriever.Resolver, error)
	MetaChainResolverCalled  func(baseTopic string) (dataRetriever.Resolver, error)
	CrossShardResolverCalled func(baseTopic string, crossShard uint32) (dataRetriever.Resolver, error)
}

func (*ResolversFinderStub) Add

func (*ResolversFinderStub) AddMultiple

func (rfs *ResolversFinderStub) AddMultiple(keys []string, resolvers []dataRetriever.Resolver) error

func (*ResolversFinderStub) CrossShardResolver

func (rfs *ResolversFinderStub) CrossShardResolver(baseTopic string, crossShard uint32) (dataRetriever.Resolver, error)

func (*ResolversFinderStub) Get

func (*ResolversFinderStub) IntraShardResolver

func (rfs *ResolversFinderStub) IntraShardResolver(baseTopic string) (dataRetriever.Resolver, error)

func (*ResolversFinderStub) Len

func (rfs *ResolversFinderStub) Len() int

func (*ResolversFinderStub) MetaChainResolver

func (rfs *ResolversFinderStub) MetaChainResolver(baseTopic string) (dataRetriever.Resolver, error)

func (*ResolversFinderStub) Remove

func (rfs *ResolversFinderStub) Remove(key string)

func (*ResolversFinderStub) Replace

func (rfs *ResolversFinderStub) Replace(key string, val dataRetriever.Resolver) error

type RounderMock

type RounderMock struct {
	IndexCalled         func() int32
	TimeDurationCalled  func() time.Duration
	TimeStampCalled     func() time.Time
	UpdateRoundCalled   func(time.Time, time.Time)
	RemainingTimeCalled func(startTime time.Time, maxTime time.Duration) time.Duration
	// contains filtered or unexported fields
}

func (*RounderMock) Index

func (rndm *RounderMock) Index() int32

func (*RounderMock) RemainingTime

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

func (*RounderMock) TimeDuration

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

func (*RounderMock) TimeStamp

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

func (*RounderMock) UpdateRound

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

type ShardCoordinatorMock

type ShardCoordinatorMock struct {
	SelfShardId uint32
}

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

func (scm ShardCoordinatorMock) SetSelfShardId(shardId uint32) error

type ShardedDataStub

type ShardedDataStub struct {
	RegisterHandlerCalled         func(func(key []byte))
	ShardDataStoreCalled          func(cacheId string) (c storage.Cacher)
	AddDataCalled                 func(key []byte, data interface{}, 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)
	CreateShardStoreCalled        func(destCacheId string)
}

func (*ShardedDataStub) AddData

func (sd *ShardedDataStub) AddData(key []byte, data interface{}, cacheId string)

func (*ShardedDataStub) Clear

func (sd *ShardedDataStub) Clear()

func (*ShardedDataStub) ClearShardStore

func (sd *ShardedDataStub) ClearShardStore(cacheId string)

func (*ShardedDataStub) CreateShardStore

func (sd *ShardedDataStub) CreateShardStore(cacheId string)

func (*ShardedDataStub) MergeShardStores

func (sd *ShardedDataStub) MergeShardStores(sourceCacheId, destCacheId string)

func (*ShardedDataStub) MoveData added in v1.0.3

func (sd *ShardedDataStub) MoveData(sourceCacheId, destCacheId string, key [][]byte)

func (*ShardedDataStub) RegisterHandler

func (sd *ShardedDataStub) RegisterHandler(handler func(key []byte))

func (*ShardedDataStub) RemoveData

func (sd *ShardedDataStub) RemoveData(key []byte, cacheId string)

func (*ShardedDataStub) RemoveDataFromAllShards

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

func (*ShardedDataStub) RemoveSetOfDataFromPool

func (sd *ShardedDataStub) RemoveSetOfDataFromPool(keys [][]byte, cacheId string)

func (*ShardedDataStub) SearchFirstData

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

func (*ShardedDataStub) ShardDataStore

func (sd *ShardedDataStub) ShardDataStore(cacheId string) (c storage.Cacher)

type SinglesignFailMock

type SinglesignFailMock struct {
}

func (*SinglesignFailMock) Sign

func (s *SinglesignFailMock) Sign(private crypto.PrivateKey, msg []byte) ([]byte, error)

Sign Signs a message with using a single signature schnorr scheme

func (*SinglesignFailMock) Verify

func (s *SinglesignFailMock) Verify(public crypto.PublicKey, msg []byte, sig []byte) error

Verify verifies a signature using a single signature schnorr scheme

type SinglesignMock

type SinglesignMock struct {
}

func (*SinglesignMock) Sign

func (s *SinglesignMock) Sign(private crypto.PrivateKey, msg []byte) ([]byte, error)

Sign Signs a message with using a single signature schnorr scheme

func (*SinglesignMock) Verify

func (s *SinglesignMock) Verify(public crypto.PublicKey, msg []byte, sig []byte) error

Verify verifies a signature using a single signature schnorr scheme

type SinglesignStub

type SinglesignStub struct {
	SignCalled   func(private crypto.PrivateKey, msg []byte) ([]byte, error)
	VerifyCalled func(public crypto.PublicKey, msg []byte, sig []byte) error
}

func (*SinglesignStub) Sign

func (s *SinglesignStub) Sign(private crypto.PrivateKey, msg []byte) ([]byte, error)

Sign Signs a message with using a single signature schnorr scheme

func (*SinglesignStub) Verify

func (s *SinglesignStub) Verify(public crypto.PublicKey, msg []byte, sig []byte) error

Verify verifies a signature using a single signature schnorr scheme

type StorerStub

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

func (*StorerStub) ClearCache

func (ss *StorerStub) ClearCache()

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) (bool, error)

func (*StorerStub) HasOrAdd added in v1.0.3

func (ss *StorerStub) HasOrAdd(key []byte, value []byte) (bool, error)

func (*StorerStub) Put

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

func (*StorerStub) Remove

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

type Streamer

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

func NewStreamer

func NewStreamer() *Streamer

func (*Streamer) XORKeyStream

func (stream *Streamer) XORKeyStream(dst, src []byte)

type SuiteMock

type SuiteMock struct {
	StringStub             func() string
	ScalarLenStub          func() int
	CreateScalarStub       func() crypto.Scalar
	PointLenStub           func() int
	CreatePointStub        func() crypto.Point
	RandomStreamStub       func() cipher.Stream
	GetUnderlyingSuiteStub func() interface{}
}

func (*SuiteMock) CreatePoint

func (s *SuiteMock) CreatePoint() crypto.Point

func (*SuiteMock) CreateScalar

func (s *SuiteMock) CreateScalar() crypto.Scalar

func (*SuiteMock) GetUnderlyingSuite

func (s *SuiteMock) GetUnderlyingSuite() interface{}

func (*SuiteMock) PointLen

func (s *SuiteMock) PointLen() int

func (*SuiteMock) RandomStream

func (s *SuiteMock) RandomStream() cipher.Stream

func (*SuiteMock) ScalarLen

func (s *SuiteMock) ScalarLen() int

func (*SuiteMock) String

func (s *SuiteMock) String() string

type SyncStub

type SyncStub struct {
}

func (*SyncStub) ClockOffset

func (ss *SyncStub) ClockOffset() time.Duration

func (*SyncStub) CurrentTime

func (ss *SyncStub) CurrentTime() time.Time

func (*SyncStub) FormattedCurrentTime

func (ss *SyncStub) FormattedCurrentTime() string

func (*SyncStub) StartSync

func (ss *SyncStub) StartSync()

type Uint64CacherStub

type Uint64CacherStub struct {
	ClearCalled           func()
	PutCalled             func(uint64, []byte) bool
	GetCalled             func(uint64) ([]byte, bool)
	HasCalled             func(uint64) bool
	PeekCalled            func(uint64) ([]byte, bool)
	HasOrAddCalled        func(uint64, []byte) (bool, bool)
	RemoveCalled          func(uint64)
	RemoveOldestCalled    func()
	KeysCalled            func() []uint64
	LenCalled             func() int
	RegisterHandlerCalled func(handler func(nonce uint64))
}

func (*Uint64CacherStub) Clear

func (ucs *Uint64CacherStub) Clear()

func (*Uint64CacherStub) Get

func (ucs *Uint64CacherStub) Get(nonce uint64) ([]byte, bool)

func (*Uint64CacherStub) Has

func (ucs *Uint64CacherStub) Has(nonce uint64) bool

func (*Uint64CacherStub) HasOrAdd

func (ucs *Uint64CacherStub) HasOrAdd(nonce uint64, value []byte) (bool, bool)

func (*Uint64CacherStub) Keys

func (ucs *Uint64CacherStub) Keys() []uint64

func (*Uint64CacherStub) Len

func (ucs *Uint64CacherStub) Len() int

func (*Uint64CacherStub) Peek

func (ucs *Uint64CacherStub) Peek(nonce uint64) ([]byte, bool)

func (*Uint64CacherStub) Put

func (ucs *Uint64CacherStub) Put(nonce uint64, value []byte) bool

func (*Uint64CacherStub) RegisterHandler

func (ucs *Uint64CacherStub) RegisterHandler(handler func(nonce uint64))

func (*Uint64CacherStub) Remove

func (ucs *Uint64CacherStub) Remove(nonce uint64)

func (*Uint64CacherStub) RemoveOldest

func (ucs *Uint64CacherStub) RemoveOldest()

Jump to

Keyboard shortcuts

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