mock

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2023 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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

ErrMockMarshalizer -

View Source
var ErrNilObjectToMarshal = errors.New("nil object to serialize from")

ErrNilObjectToMarshal -

Functions

This section is empty.

Types

type AlarmSchedulerStub

type AlarmSchedulerStub struct {
	AddCalled    func(func(alarmID string), time.Duration, string)
	CancelCalled func(string)
	CloseCalled  func()
	ResetCalled  func(string)
}

AlarmSchedulerStub -

func (*AlarmSchedulerStub) Add

func (a *AlarmSchedulerStub) Add(callback func(alarmID string), duration time.Duration, alarmID string)

Add -

func (*AlarmSchedulerStub) Cancel

func (a *AlarmSchedulerStub) Cancel(alarmID string)

Cancel -

func (*AlarmSchedulerStub) Close

func (a *AlarmSchedulerStub) Close()

Close -

func (*AlarmSchedulerStub) IsInterfaceNil

func (a *AlarmSchedulerStub) IsInterfaceNil() bool

IsInterfaceNil -

func (*AlarmSchedulerStub) Reset

func (a *AlarmSchedulerStub) Reset(alarmID string)

Reset -

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 ConnectedAddressesMock

type ConnectedAddressesMock struct {
}

ConnectedAddressesMock represents a mock implementation of the ConnectedAddresses

func (*ConnectedAddressesMock) ConnectedAddresses

func (cam *ConnectedAddressesMock) ConnectedAddresses() []string

ConnectedAddresses returns an empty slice of string

type EpochSubscriberHandlerStub

type EpochSubscriberHandlerStub struct {
	EpochConfirmedCalled func(epoch uint32, timestamp uint64)
}

EpochSubscriberHandlerStub -

func (*EpochSubscriberHandlerStub) EpochConfirmed

func (eshs *EpochSubscriberHandlerStub) EpochConfirmed(epoch uint32, timestamp uint64)

EpochConfirmed -

func (*EpochSubscriberHandlerStub) IsInterfaceNil

func (eshs *EpochSubscriberHandlerStub) IsInterfaceNil() bool

IsInterfaceNil -

type GasScheduleSubscribeHandlerStub

type GasScheduleSubscribeHandlerStub struct {
	GasScheduleChangeCalled func(gasSchedule map[string]map[string]uint64)
}

GasScheduleSubscribeHandlerStub -

func (*GasScheduleSubscribeHandlerStub) GasScheduleChange

func (g *GasScheduleSubscribeHandlerStub) GasScheduleChange(gasSchedule map[string]map[string]uint64)

GasScheduleChange -

func (*GasScheduleSubscribeHandlerStub) IsInterfaceNil

func (g *GasScheduleSubscribeHandlerStub) IsInterfaceNil() bool

IsInterfaceNil -

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

type HasherStub

type HasherStub struct {
	ComputeCalled   func(s string) []byte
	EmptyHashCalled func() []byte
	SizeCalled      func() int
}

HasherStub -

func (*HasherStub) Compute

func (hash *HasherStub) Compute(s string) []byte

Compute -

func (*HasherStub) EmptyHash

func (hash *HasherStub) EmptyHash() []byte

EmptyHash -

func (*HasherStub) IsInterfaceNil

func (hash *HasherStub) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

func (*HasherStub) Size

func (hash *HasherStub) Size() int

Size -

type HeaderHandlerStub

type HeaderHandlerStub struct {
	EpochField                             uint32
	TimestampField                         uint64
	GetMiniBlockHeadersWithDstCalled       func(destId uint32) map[string]uint32
	GetOrderedCrossMiniblocksWithDstCalled func(destId uint32) []*data.MiniBlockInfo
	GetPubKeysBitmapCalled                 func() []byte
	GetSignatureCalled                     func() []byte
	GetRootHashCalled                      func() []byte
	GetRandSeedCalled                      func() []byte
	GetPrevRandSeedCalled                  func() []byte
	GetPrevHashCalled                      func() []byte
	CloneCalled                            func() data.HeaderHandler
	GetChainIDCalled                       func() []byte
	CheckChainIDCalled                     func(reference []byte) error
	GetReservedCalled                      func() []byte
	IsStartOfEpochBlockCalled              func() bool
}

HeaderHandlerStub -

func (*HeaderHandlerStub) Clone

func (hhs *HeaderHandlerStub) Clone() data.HeaderHandler

Clone -

func (*HeaderHandlerStub) GetAccumulatedFees

func (hhs *HeaderHandlerStub) GetAccumulatedFees() *big.Int

GetAccumulatedFees -

func (*HeaderHandlerStub) GetChainID

func (hhs *HeaderHandlerStub) GetChainID() []byte

GetChainID -

func (*HeaderHandlerStub) GetDeveloperFees

func (hhs *HeaderHandlerStub) GetDeveloperFees() *big.Int

GetDeveloperFees -

func (*HeaderHandlerStub) GetEpoch

func (hhs *HeaderHandlerStub) GetEpoch() uint32

GetEpoch -

func (*HeaderHandlerStub) GetEpochStartMetaHash

func (hhs *HeaderHandlerStub) GetEpochStartMetaHash() []byte

GetEpochStartMetaHash -

func (*HeaderHandlerStub) GetLeaderSignature

func (hhs *HeaderHandlerStub) GetLeaderSignature() []byte

GetLeaderSignature -

func (*HeaderHandlerStub) GetMiniBlockHeadersHashes

func (hhs *HeaderHandlerStub) GetMiniBlockHeadersHashes() [][]byte

GetMiniBlockHeadersHashes -

func (*HeaderHandlerStub) GetMiniBlockHeadersWithDst

func (hhs *HeaderHandlerStub) GetMiniBlockHeadersWithDst(destId uint32) map[string]uint32

GetMiniBlockHeadersWithDst -

func (*HeaderHandlerStub) GetNonce

func (hhs *HeaderHandlerStub) GetNonce() uint64

GetNonce -

func (*HeaderHandlerStub) GetOrderedCrossMiniblocksWithDst

func (hhs *HeaderHandlerStub) GetOrderedCrossMiniblocksWithDst(destId uint32) []*data.MiniBlockInfo

GetOrderedCrossMiniblocksWithDst -

func (*HeaderHandlerStub) GetPrevHash

func (hhs *HeaderHandlerStub) GetPrevHash() []byte

GetPrevHash -

func (*HeaderHandlerStub) GetPrevRandSeed

func (hhs *HeaderHandlerStub) GetPrevRandSeed() []byte

GetPrevRandSeed -

func (*HeaderHandlerStub) GetPubKeysBitmap

func (hhs *HeaderHandlerStub) GetPubKeysBitmap() []byte

GetPubKeysBitmap -

func (*HeaderHandlerStub) GetRandSeed

func (hhs *HeaderHandlerStub) GetRandSeed() []byte

GetRandSeed -

func (*HeaderHandlerStub) GetReceiptsHash

func (hhs *HeaderHandlerStub) GetReceiptsHash() []byte

GetReceiptsHash -

func (*HeaderHandlerStub) GetReserved

func (hhs *HeaderHandlerStub) GetReserved() []byte

GetReserved -

func (*HeaderHandlerStub) GetRootHash

func (hhs *HeaderHandlerStub) GetRootHash() []byte

GetRootHash -

func (*HeaderHandlerStub) GetRound

func (hhs *HeaderHandlerStub) GetRound() uint64

GetRound -

func (*HeaderHandlerStub) GetShardID

func (hhs *HeaderHandlerStub) GetShardID() uint32

GetShardID -

func (*HeaderHandlerStub) GetSignature

func (hhs *HeaderHandlerStub) GetSignature() []byte

GetSignature -

func (*HeaderHandlerStub) GetSoftwareVersion

func (hhs *HeaderHandlerStub) GetSoftwareVersion() []byte

GetSoftwareVersion -

func (*HeaderHandlerStub) GetTimeStamp

func (hhs *HeaderHandlerStub) GetTimeStamp() uint64

GetTimeStamp -

func (*HeaderHandlerStub) GetTxCount

func (hhs *HeaderHandlerStub) GetTxCount() uint32

GetTxCount -

func (*HeaderHandlerStub) GetValidatorStatsRootHash

func (hhs *HeaderHandlerStub) GetValidatorStatsRootHash() []byte

GetValidatorStatsRootHash -

func (*HeaderHandlerStub) IsInterfaceNil

func (hhs *HeaderHandlerStub) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

func (*HeaderHandlerStub) IsStartOfEpochBlock

func (hhs *HeaderHandlerStub) IsStartOfEpochBlock() bool

IsStartOfEpochBlock -

func (*HeaderHandlerStub) SetAccumulatedFees

func (hhs *HeaderHandlerStub) SetAccumulatedFees(_ *big.Int)

SetAccumulatedFees -

func (*HeaderHandlerStub) SetChainID

func (hhs *HeaderHandlerStub) SetChainID(_ []byte)

SetChainID -

func (*HeaderHandlerStub) SetDeveloperFees

func (hhs *HeaderHandlerStub) SetDeveloperFees(_ *big.Int)

SetDeveloperFees -

func (*HeaderHandlerStub) SetEpoch

func (hhs *HeaderHandlerStub) SetEpoch(_ uint32)

SetEpoch -

func (*HeaderHandlerStub) SetLeaderSignature

func (hhs *HeaderHandlerStub) SetLeaderSignature(_ []byte)

SetLeaderSignature -

func (*HeaderHandlerStub) SetNonce

func (hhs *HeaderHandlerStub) SetNonce(_ uint64)

SetNonce -

func (*HeaderHandlerStub) SetPrevHash

func (hhs *HeaderHandlerStub) SetPrevHash(_ []byte)

SetPrevHash -

func (*HeaderHandlerStub) SetPrevRandSeed

func (hhs *HeaderHandlerStub) SetPrevRandSeed(_ []byte)

SetPrevRandSeed -

func (*HeaderHandlerStub) SetPubKeysBitmap

func (hhs *HeaderHandlerStub) SetPubKeysBitmap(_ []byte)

SetPubKeysBitmap -

func (*HeaderHandlerStub) SetRandSeed

func (hhs *HeaderHandlerStub) SetRandSeed(_ []byte)

SetRandSeed -

func (*HeaderHandlerStub) SetRootHash

func (hhs *HeaderHandlerStub) SetRootHash(_ []byte)

SetRootHash -

func (*HeaderHandlerStub) SetRound

func (hhs *HeaderHandlerStub) SetRound(_ uint64)

SetRound -

func (*HeaderHandlerStub) SetShardID

func (hhs *HeaderHandlerStub) SetShardID(_ uint32)

SetShardID -

func (*HeaderHandlerStub) SetSignature

func (hhs *HeaderHandlerStub) SetSignature(_ []byte)

SetSignature -

func (*HeaderHandlerStub) SetSoftwareVersion

func (hhs *HeaderHandlerStub) SetSoftwareVersion(_ []byte)

SetSoftwareVersion -

func (*HeaderHandlerStub) SetTimeStamp

func (hhs *HeaderHandlerStub) SetTimeStamp(_ uint64)

SetTimeStamp -

func (*HeaderHandlerStub) SetTxCount

func (hhs *HeaderHandlerStub) SetTxCount(_ uint32)

SetTxCount -

func (*HeaderHandlerStub) SetValidatorStatsRootHash

func (hhs *HeaderHandlerStub) SetValidatorStatsRootHash(_ []byte)

SetValidatorStatsRootHash -

type IntRandomizerStub

type IntRandomizerStub struct {
	IntnCalled func(n int) int
}

IntRandomizerStub -

func (*IntRandomizerStub) Intn

func (irs *IntRandomizerStub) Intn(n int) int

Intn -

func (*IntRandomizerStub) IsInterfaceNil

func (irs *IntRandomizerStub) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

type LoggerMock

type LoggerMock struct {
}

LoggerMock -

func (LoggerMock) Debug

func (c LoggerMock) Debug(message string, args ...interface{})

Debug will print a debug log

func (LoggerMock) Error

func (c LoggerMock) Error(message string, args ...interface{})

Error will print an error log

func (LoggerMock) Info

func (c LoggerMock) Info(message string, args ...interface{})

Info will print an info log

func (LoggerMock) IsInterfaceNil

func (c LoggerMock) IsInterfaceNil() bool

IsInterfaceNil returns false as the struct doesn't use pointer receivers

func (LoggerMock) LogIfError

func (c LoggerMock) LogIfError(err error, args ...interface{})

LogIfError will print an error if it is not nil

func (LoggerMock) Trace

func (c LoggerMock) Trace(message string, args ...interface{})

Trace will print a trace log

func (LoggerMock) Warn

func (c LoggerMock) Warn(message string, args ...interface{})

Warn will print a warn log

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

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 PathManagerStub

type PathManagerStub struct {
	PathForEpochCalled  func(shardId string, epoch uint32, identifier string) string
	PathForStaticCalled func(shardId string, identifier string) string
	DatabasePathCalled  func() string
}

PathManagerStub -

func (*PathManagerStub) DatabasePath

func (p *PathManagerStub) DatabasePath() string

DatabasePath -

func (*PathManagerStub) IsInterfaceNil

func (p *PathManagerStub) IsInterfaceNil() bool

IsInterfaceNil -

func (*PathManagerStub) PathForEpoch

func (p *PathManagerStub) PathForEpoch(shardId string, epoch uint32, identifier string) string

PathForEpoch -

func (*PathManagerStub) PathForStatic

func (p *PathManagerStub) PathForStatic(shardId string, identifier string) string

PathForStatic -

type StableTagProviderStub

type StableTagProviderStub struct {
	FetchTagVersionCalled func() (string, error)
}

StableTagProviderStub --

func (*StableTagProviderStub) FetchTagVersion

func (s *StableTagProviderStub) FetchTagVersion() (string, error)

FetchTagVersion --

func (*StableTagProviderStub) IsInterfaceNil

func (s *StableTagProviderStub) IsInterfaceNil() bool

IsInterfaceNil --

type StatusHandlerMock

type StatusHandlerMock struct {
}

StatusHandlerMock -

func (*StatusHandlerMock) AddUint64

func (s *StatusHandlerMock) AddUint64(_ string, _ uint64)

AddUint64 -

func (*StatusHandlerMock) Close

func (s *StatusHandlerMock) Close()

Close -

func (*StatusHandlerMock) Decrement

func (s *StatusHandlerMock) Decrement(_ string)

Decrement -

func (*StatusHandlerMock) Increment

func (s *StatusHandlerMock) Increment(_ string)

Increment -

func (*StatusHandlerMock) IsInterfaceNil

func (s *StatusHandlerMock) IsInterfaceNil() bool

IsInterfaceNil -

func (*StatusHandlerMock) SetInt64Value

func (s *StatusHandlerMock) SetInt64Value(_ string, _ int64)

SetInt64Value -

func (*StatusHandlerMock) SetStringValue

func (s *StatusHandlerMock) SetStringValue(_ string, _ string)

SetStringValue -

func (*StatusHandlerMock) SetUInt64Value

func (s *StatusHandlerMock) SetUInt64Value(_ string, _ uint64)

SetUInt64Value -

Jump to

Keyboard shortcuts

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