mock

package
v1.10.8 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2025 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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

ErrMockMarshalizer -

Functions

This section is empty.

Types

type ContextMock added in v1.9.0

type ContextMock struct {
	DoneFunc     func() <-chan struct{}
	DeadlineFunc func() (time.Time, bool)
	ErrFunc      func() error
	ValueFunc    func(key interface{}) interface{}
}

ContextMock -

func (*ContextMock) Deadline added in v1.9.0

func (c *ContextMock) Deadline() (time.Time, bool)

Deadline -

func (*ContextMock) Done added in v1.9.0

func (c *ContextMock) Done() <-chan struct{}

Done -

func (*ContextMock) Err added in v1.9.0

func (c *ContextMock) Err() error

Err -

func (*ContextMock) Value added in v1.9.0

func (c *ContextMock) Value(key interface{}) interface{}

Value -

type IndexerMock

type IndexerMock struct{}

IndexerMock is a mock implementation fot the Indexer interface

func (*IndexerMock) IsInterfaceNil

func (im *IndexerMock) IsInterfaceNil() bool

IsInterfaceNil -

func (*IndexerMock) SaveRoundsInfo

func (im *IndexerMock) SaveRoundsInfo(_ []*outport.RoundInfo)

SaveRoundsInfo -

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)
	CheckPublicKeyValidMock     func(b []byte) error
	SuiteMock                   func() crypto.Suite
}

KeyGenMock mocks a key generation implementation

func (*KeyGenMock) CheckPublicKeyValid

func (keyGen *KeyGenMock) CheckPublicKeyValid(b []byte) error

CheckPublicKeyValid verifies the validity of the public key

func (*KeyGenMock) GeneratePair

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

GeneratePair generates a pair of private and public keys

func (*KeyGenMock) IsInterfaceNil

func (keyGen *KeyGenMock) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

func (*KeyGenMock) PrivateKeyFromByteArray

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

PrivateKeyFromByteArray generates the private key from its byte array representation

func (*KeyGenMock) PublicKeyFromByteArray

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

PublicKeyFromByteArray generates a public key from its byte array representation

func (*KeyGenMock) Suite

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

Suite -

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 MessageSignerMock added in v1.6.0

type MessageSignerMock struct {
}

MessageSignerMock implements P2PSigningHandler interface but it does nothing as it is disabled

func (*MessageSignerMock) Deserialize added in v1.6.0

func (ms *MessageSignerMock) Deserialize(messagesBytes []byte) ([]p2p.MessageP2P, error)

Deserialize will unmarshal into a list of p2p messages

func (*MessageSignerMock) IsInterfaceNil added in v1.6.0

func (ms *MessageSignerMock) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

func (*MessageSignerMock) Serialize added in v1.6.0

func (ms *MessageSignerMock) Serialize(messages []p2p.MessageP2P) ([]byte, error)

Serialize will serialize the list of p2p messages

func (*MessageSignerMock) Verify added in v1.6.0

func (ms *MessageSignerMock) Verify(_ p2p.MessageP2P) error

Verify does nothing

type MessageSigningHandlerStub added in v1.6.0

type MessageSigningHandlerStub struct {
	VerifyCalled      func(message p2p.MessageP2P) error
	SerializeCalled   func(messages []p2p.MessageP2P) ([]byte, error)
	DeserializeCalled func(messagesBytes []byte) ([]p2p.MessageP2P, error)
}

MessageSigningHandlerStub -

func (*MessageSigningHandlerStub) Deserialize added in v1.6.0

func (stub *MessageSigningHandlerStub) Deserialize(messagesBytes []byte) ([]p2p.MessageP2P, error)

Deserialize -

func (*MessageSigningHandlerStub) IsInterfaceNil added in v1.6.0

func (stub *MessageSigningHandlerStub) IsInterfaceNil() bool

IsInterfaceNil -

func (*MessageSigningHandlerStub) Serialize added in v1.6.0

func (stub *MessageSigningHandlerStub) Serialize(messages []p2p.MessageP2P) ([]byte, error)

Serialize -

func (*MessageSigningHandlerStub) Verify added in v1.6.0

func (stub *MessageSigningHandlerStub) Verify(message p2p.MessageP2P) error

Verify -

type MultipleShardsCoordinatorMock

type MultipleShardsCoordinatorMock struct {
	NoShards        uint32
	CurrentShard    uint32
	ComputeIdCalled func(address []byte) uint32
	SelfIDCalled    func() 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 -

func (*MultipleShardsCoordinatorMock) SetNoShards

func (scm *MultipleShardsCoordinatorMock) SetNoShards(noShards uint32)

SetNoShards -

func (*MultipleShardsCoordinatorMock) SetSelfId

func (scm *MultipleShardsCoordinatorMock) SetSelfId(_ uint32) error

SetSelfId -

type NodeRedundancyHandlerStub

type NodeRedundancyHandlerStub struct {
	IsRedundancyNodeCalled         func() bool
	IsMainMachineActiveCalled      func() bool
	AdjustInactivityIfNeededCalled func(selfPubKey string, consensusPubKeys []string, roundIndex int64)
	ResetInactivityIfNeededCalled  func(selfPubKey string, consensusMsgPubKey string, consensusMsgPeerID core.PeerID)
	ObserverPrivateKeyCalled       func() crypto.PrivateKey
}

NodeRedundancyHandlerStub -

func (*NodeRedundancyHandlerStub) AdjustInactivityIfNeeded

func (nrhs *NodeRedundancyHandlerStub) AdjustInactivityIfNeeded(selfPubKey string, consensusPubKeys []string, roundIndex int64)

AdjustInactivityIfNeeded -

func (*NodeRedundancyHandlerStub) IsInterfaceNil

func (nrhs *NodeRedundancyHandlerStub) IsInterfaceNil() bool

IsInterfaceNil -

func (*NodeRedundancyHandlerStub) IsMainMachineActive

func (nrhs *NodeRedundancyHandlerStub) IsMainMachineActive() bool

IsMainMachineActive -

func (*NodeRedundancyHandlerStub) IsRedundancyNode

func (nrhs *NodeRedundancyHandlerStub) IsRedundancyNode() bool

IsRedundancyNode -

func (*NodeRedundancyHandlerStub) ObserverPrivateKey

func (nrhs *NodeRedundancyHandlerStub) ObserverPrivateKey() crypto.PrivateKey

ObserverPrivateKey -

func (*NodeRedundancyHandlerStub) ResetInactivityIfNeeded

func (nrhs *NodeRedundancyHandlerStub) ResetInactivityIfNeeded(selfPubKey string, consensusMsgPubKey string, consensusMsgPeerID core.PeerID)

ResetInactivityIfNeeded -

type P2PAntifloodHandlerStub

type P2PAntifloodHandlerStub struct {
	CanProcessMessageCalled         func(message p2p.MessageP2P, fromConnectedPeer core.PeerID) error
	CanProcessMessagesOnTopicCalled func(peer core.PeerID, topic string, numMessages uint32, totalSize uint64, sequence []byte) error
	BlacklistPeerCalled             func(peer core.PeerID, reason string, duration time.Duration)
}

P2PAntifloodHandlerStub -

func (*P2PAntifloodHandlerStub) BlacklistPeer

func (p2pahs *P2PAntifloodHandlerStub) BlacklistPeer(peer core.PeerID, reason string, duration time.Duration)

BlacklistPeer -

func (*P2PAntifloodHandlerStub) CanProcessMessage

func (p2pahs *P2PAntifloodHandlerStub) CanProcessMessage(message p2p.MessageP2P, fromConnectedPeer core.PeerID) error

CanProcessMessage -

func (*P2PAntifloodHandlerStub) CanProcessMessagesOnTopic

func (p2pahs *P2PAntifloodHandlerStub) CanProcessMessagesOnTopic(peer core.PeerID, topic string, numMessages uint32, totalSize uint64, sequence []byte) error

CanProcessMessagesOnTopic -

func (*P2PAntifloodHandlerStub) IsInterfaceNil

func (p2pahs *P2PAntifloodHandlerStub) IsInterfaceNil() bool

IsInterfaceNil -

func (*P2PAntifloodHandlerStub) ResetForTopic

func (p2pahs *P2PAntifloodHandlerStub) ResetForTopic(_ string)

ResetForTopic -

func (*P2PAntifloodHandlerStub) SetMaxMessagesForTopic

func (p2pahs *P2PAntifloodHandlerStub) SetMaxMessagesForTopic(_ string, _ uint32)

SetMaxMessagesForTopic -

type PeerBlackListCacherStub added in v1.6.0

type PeerBlackListCacherStub struct {
	UpsertCalled func(pid core.PeerID, span time.Duration) error
	HasCalled    func(pid core.PeerID) bool
	SweepCalled  func()
}

PeerBlackListCacherStub -

func (*PeerBlackListCacherStub) Has added in v1.6.0

func (stub *PeerBlackListCacherStub) Has(pid core.PeerID) bool

Has -

func (*PeerBlackListCacherStub) IsInterfaceNil added in v1.6.0

func (stub *PeerBlackListCacherStub) IsInterfaceNil() bool

IsInterfaceNil -

func (*PeerBlackListCacherStub) Sweep added in v1.6.0

func (stub *PeerBlackListCacherStub) Sweep()

Sweep -

func (*PeerBlackListCacherStub) Upsert added in v1.6.0

func (stub *PeerBlackListCacherStub) Upsert(pid core.PeerID, span time.Duration) error

Upsert -

type PeerBlacklistHandlerStub added in v1.6.0

type PeerBlacklistHandlerStub struct {
	BlacklistPeerCalled          func(peer core.PeerID, duration time.Duration)
	IsPeerBlacklistedCalled      func(peer core.PeerID) bool
	StartSweepingTimeCacheCalled func()
	CloseCalled                  func() error
}

PeerBlacklistHandlerStub -

func (*PeerBlacklistHandlerStub) BlacklistPeer added in v1.6.0

func (stub *PeerBlacklistHandlerStub) BlacklistPeer(peer core.PeerID, duration time.Duration)

BlacklistPeer -

func (*PeerBlacklistHandlerStub) Close added in v1.6.0

func (stub *PeerBlacklistHandlerStub) Close() error

Close -

func (*PeerBlacklistHandlerStub) IsInterfaceNil added in v1.6.0

func (stub *PeerBlacklistHandlerStub) IsInterfaceNil() bool

IsInterfaceNil -

func (*PeerBlacklistHandlerStub) IsPeerBlacklisted added in v1.6.0

func (stub *PeerBlacklistHandlerStub) IsPeerBlacklisted(peer core.PeerID) bool

IsPeerBlacklisted -

func (*PeerBlacklistHandlerStub) StartSweepingTimeCache added in v1.6.0

func (stub *PeerBlacklistHandlerStub) StartSweepingTimeCache()

StartSweepingTimeCache -

type PeerSignatureHandler

type PeerSignatureHandler struct {
	Signer crypto.SingleSigner
	KeyGen crypto.KeyGenerator
}

PeerSignatureHandler -

func (*PeerSignatureHandler) GetPeerSignature

func (p *PeerSignatureHandler) GetPeerSignature(privateKey crypto.PrivateKey, msg []byte) ([]byte, error)

GetPeerSignature -

func (*PeerSignatureHandler) IsInterfaceNil

func (p *PeerSignatureHandler) IsInterfaceNil() bool

IsInterfaceNil -

func (*PeerSignatureHandler) VerifyPeerSignature

func (p *PeerSignatureHandler) VerifyPeerSignature(pk []byte, pid core.PeerID, sig []byte) error

VerifyPeerSignature -

type PrivateKeyMock

type PrivateKeyMock struct {
	GeneratePublicMock func() crypto.PublicKey
	ToByteArrayMock    func() ([]byte, error)
	SuiteMock          func() crypto.Suite
	ScalarMock         func() crypto.Scalar
}

PrivateKeyMock mocks a private key implementation

func (*PrivateKeyMock) GeneratePublic

func (privKey *PrivateKeyMock) GeneratePublic() crypto.PublicKey

GeneratePublic mocks generating a public key from the private key

func (*PrivateKeyMock) IsInterfaceNil

func (privKey *PrivateKeyMock) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

func (*PrivateKeyMock) Scalar

func (privKey *PrivateKeyMock) Scalar() crypto.Scalar

Scalar -

func (*PrivateKeyMock) Suite

func (privKey *PrivateKeyMock) Suite() crypto.Suite

Suite -

func (*PrivateKeyMock) ToByteArray

func (privKey *PrivateKeyMock) ToByteArray() ([]byte, error)

ToByteArray mocks converting the private key to a byte array

type PublicKeyMock

type PublicKeyMock struct {
	ToByteArrayMock func() ([]byte, error)
	SuiteMock       func() crypto.Suite
	PointMock       func() crypto.Point
}

PublicKeyMock mocks a public key implementation

func (*PublicKeyMock) IsInterfaceNil

func (pubKey *PublicKeyMock) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

func (*PublicKeyMock) Point

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

Point -

func (*PublicKeyMock) Suite

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

Suite -

func (*PublicKeyMock) ToByteArray

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

ToByteArray mocks converting a public key to a byte array

type ShardCoordinatorMock

type ShardCoordinatorMock struct {
	ShardID 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 SingleSignerMock

type SingleSignerMock struct {
	SignStub   func(private crypto.PrivateKey, msg []byte) ([]byte, error)
	VerifyStub func(public crypto.PublicKey, msg []byte, sig []byte) error
}

SingleSignerMock -

func (*SingleSignerMock) IsInterfaceNil

func (s *SingleSignerMock) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

func (*SingleSignerMock) Sign

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

Sign -

func (*SingleSignerMock) Verify

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

Verify -

type SubroundHandlerMock

type SubroundHandlerMock struct {
	DoWorkCalled           func(roundHandler consensus.RoundHandler) bool
	PreviousCalled         func() int
	NextCalled             func() int
	CurrentCalled          func() int
	StartTimeCalled        func() int64
	EndTimeCalled          func() int64
	NameCalled             func() string
	JobCalled              func() bool
	CheckCalled            func() bool
	ConsensusChannelCalled func() chan bool
}

SubroundHandlerMock -

func (*SubroundHandlerMock) ConsensusChannel

func (srm *SubroundHandlerMock) ConsensusChannel() chan bool

ConsensusChannel -

func (*SubroundHandlerMock) Current

func (srm *SubroundHandlerMock) Current() int

Current -

func (*SubroundHandlerMock) DoWork

func (srm *SubroundHandlerMock) DoWork(_ context.Context, roundHandler consensus.RoundHandler) bool

DoWork -

func (*SubroundHandlerMock) EndTime

func (srm *SubroundHandlerMock) EndTime() int64

EndTime -

func (*SubroundHandlerMock) IsInterfaceNil

func (srm *SubroundHandlerMock) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

func (*SubroundHandlerMock) Name

func (srm *SubroundHandlerMock) Name() string

Name -

func (*SubroundHandlerMock) Next

func (srm *SubroundHandlerMock) Next() int

Next -

func (*SubroundHandlerMock) Previous

func (srm *SubroundHandlerMock) Previous() int

Previous -

func (*SubroundHandlerMock) StartTime

func (srm *SubroundHandlerMock) StartTime() int64

StartTime -

type WatchdogMock

type WatchdogMock struct {
	SetCalled  func(callback func(alarmID string), duration time.Duration, alarmID string)
	StopCalled func(alarmID string)
}

WatchdogMock -

func (*WatchdogMock) IsInterfaceNil

func (w *WatchdogMock) IsInterfaceNil() bool

IsInterfaceNil -

func (*WatchdogMock) Reset

func (w *WatchdogMock) Reset(alarmID string)

Reset -

func (*WatchdogMock) Set

func (w *WatchdogMock) Set(callback func(alarmID string), duration time.Duration, alarmID string)

Set -

func (*WatchdogMock) SetDefault

func (w *WatchdogMock) SetDefault(duration time.Duration, alarmID string)

SetDefault -

func (*WatchdogMock) Stop

func (w *WatchdogMock) Stop(alarmID string)

Stop -

Jump to

Keyboard shortcuts

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