testscommon

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2024 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrMockMarshaller = errors.New("MarshallerMock generic error")

ErrMockMarshaller -

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

ErrNilObjectToMarshal -

Functions

func NewHttpTestEchoHandler

func NewHttpTestEchoHandler() *httptest.Server

NewHttpTestEchoHandler -

Types

type ConnectionsHandlerStub added in v0.0.1

type ConnectionsHandlerStub struct {
	BootstrapCalled                     func() error
	PeersCalled                         func() []core.PeerID
	AddressesCalled                     func() []string
	ConnectToPeerCalled                 func(address string) error
	IsConnectedCalled                   func(peerID core.PeerID) bool
	ConnectedPeersCalled                func() []core.PeerID
	ConnectedAddressesCalled            func() []string
	PeerAddressesCalled                 func(pid core.PeerID) []string
	ConnectedPeersOnTopicCalled         func(topic string) []core.PeerID
	SetPeerShardResolverCalled          func(peerShardResolver p2p.PeerShardResolver) error
	GetConnectedPeersInfoCalled         func() *p2p.ConnectedPeersInfo
	WaitForConnectionsCalled            func(maxWaitingTime time.Duration, minNumOfPeers uint32)
	IsConnectedToTheNetworkCalled       func() bool
	ThresholdMinConnectedPeersCalled    func() int
	SetThresholdMinConnectedPeersCalled func(minConnectedPeers int) error
	SetPeerDenialEvaluatorCalled        func(handler p2p.PeerDenialEvaluator) error
	CloseCalled                         func() error
}

ConnectionsHandlerStub -

func (*ConnectionsHandlerStub) Addresses added in v0.0.1

func (stub *ConnectionsHandlerStub) Addresses() []string

Addresses -

func (*ConnectionsHandlerStub) Bootstrap added in v0.0.1

func (stub *ConnectionsHandlerStub) Bootstrap() error

Bootstrap -

func (*ConnectionsHandlerStub) Close added in v0.0.1

func (stub *ConnectionsHandlerStub) Close() error

Close -

func (*ConnectionsHandlerStub) ConnectToPeer added in v0.0.1

func (stub *ConnectionsHandlerStub) ConnectToPeer(address string) error

ConnectToPeer -

func (*ConnectionsHandlerStub) ConnectedAddresses added in v0.0.1

func (stub *ConnectionsHandlerStub) ConnectedAddresses() []string

ConnectedAddresses -

func (*ConnectionsHandlerStub) ConnectedPeers added in v0.0.1

func (stub *ConnectionsHandlerStub) ConnectedPeers() []core.PeerID

ConnectedPeers -

func (*ConnectionsHandlerStub) ConnectedPeersOnTopic added in v0.0.1

func (stub *ConnectionsHandlerStub) ConnectedPeersOnTopic(topic string) []core.PeerID

ConnectedPeersOnTopic -

func (*ConnectionsHandlerStub) GetConnectedPeersInfo added in v0.0.1

func (stub *ConnectionsHandlerStub) GetConnectedPeersInfo() *p2p.ConnectedPeersInfo

GetConnectedPeersInfo -

func (*ConnectionsHandlerStub) IsConnected added in v0.0.1

func (stub *ConnectionsHandlerStub) IsConnected(peerID core.PeerID) bool

IsConnected -

func (*ConnectionsHandlerStub) IsConnectedToTheNetwork added in v0.0.1

func (stub *ConnectionsHandlerStub) IsConnectedToTheNetwork() bool

IsConnectedToTheNetwork -

func (*ConnectionsHandlerStub) IsInterfaceNil added in v0.0.1

func (stub *ConnectionsHandlerStub) IsInterfaceNil() bool

IsInterfaceNil -

func (*ConnectionsHandlerStub) PeerAddresses added in v0.0.1

func (stub *ConnectionsHandlerStub) PeerAddresses(pid core.PeerID) []string

PeerAddresses -

func (*ConnectionsHandlerStub) Peers added in v0.0.1

func (stub *ConnectionsHandlerStub) Peers() []core.PeerID

Peers -

func (*ConnectionsHandlerStub) SetPeerDenialEvaluator added in v0.0.1

func (stub *ConnectionsHandlerStub) SetPeerDenialEvaluator(handler p2p.PeerDenialEvaluator) error

SetPeerDenialEvaluator -

func (*ConnectionsHandlerStub) SetPeerShardResolver added in v0.0.1

func (stub *ConnectionsHandlerStub) SetPeerShardResolver(peerShardResolver p2p.PeerShardResolver) error

SetPeerShardResolver -

func (*ConnectionsHandlerStub) SetThresholdMinConnectedPeers added in v0.0.1

func (stub *ConnectionsHandlerStub) SetThresholdMinConnectedPeers(minConnectedPeers int) error

SetThresholdMinConnectedPeers -

func (*ConnectionsHandlerStub) ThresholdMinConnectedPeers added in v0.0.1

func (stub *ConnectionsHandlerStub) ThresholdMinConnectedPeers() int

ThresholdMinConnectedPeers -

func (*ConnectionsHandlerStub) WaitForConnections added in v0.0.1

func (stub *ConnectionsHandlerStub) WaitForConnections(maxWaitingTime time.Duration, minNumOfPeers uint32)

WaitForConnections -

type HttpServerStub

type HttpServerStub struct {
	ListenAndServeCalled func() error
	ShutdownCalled       func(ctx context.Context) error
}

HttpServerStub -

func (*HttpServerStub) ListenAndServe

func (h *HttpServerStub) ListenAndServe() error

ListenAndServe -

func (*HttpServerStub) Shutdown

func (h *HttpServerStub) Shutdown(ctx context.Context) error

Shutdown -

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 LoggerStub

type LoggerStub struct {
	TraceCalled      func(message string, args ...interface{})
	DebugCalled      func(message string, args ...interface{})
	InfoCalled       func(message string, args ...interface{})
	WarnCalled       func(message string, args ...interface{})
	ErrorCalled      func(message string, args ...interface{})
	LogIfErrorCalled func(err error, args ...interface{})
	GetLevelCalled   func() logger.LogLevel
}

LoggerStub -

func (*LoggerStub) Debug

func (stub *LoggerStub) Debug(message string, args ...interface{})

Debug -

func (*LoggerStub) Error

func (stub *LoggerStub) Error(message string, args ...interface{})

Error -

func (*LoggerStub) GetLevel added in v0.0.1

func (stub *LoggerStub) GetLevel() logger.LogLevel

GetLevel -

func (*LoggerStub) Info

func (stub *LoggerStub) Info(message string, args ...interface{})

Info -

func (*LoggerStub) IsInterfaceNil

func (stub *LoggerStub) IsInterfaceNil() bool

IsInterfaceNil -

func (*LoggerStub) LogIfError

func (stub *LoggerStub) LogIfError(err error, args ...interface{})

LogIfError -

func (*LoggerStub) Trace

func (stub *LoggerStub) Trace(message string, args ...interface{})

Trace -

func (*LoggerStub) Warn

func (stub *LoggerStub) Warn(message string, args ...interface{})

Warn -

type MarshallerMock

type MarshallerMock struct {
	Fail bool
}

MarshallerMock that will be used for testing

func (*MarshallerMock) IsInterfaceNil

func (mm *MarshallerMock) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

func (*MarshallerMock) Marshal

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

Marshal converts the input object in a slice of bytes

func (*MarshallerMock) Unmarshal

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

Unmarshal applies the serialized values over an instantiated object

type MarshallerStub added in v0.0.1

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

MarshallerStub -

func (*MarshallerStub) IsInterfaceNil added in v0.0.1

func (ms *MarshallerStub) IsInterfaceNil() bool

IsInterfaceNil -

func (*MarshallerStub) Marshal added in v0.0.1

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

Marshal -

func (*MarshallerStub) Unmarshal added in v0.0.1

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

Unmarshal -

type PayloadHandlerStub

type PayloadHandlerStub struct {
	ProcessPayloadCalled func(payload []byte, topic string, version uint32) error
	CloseCalled          func() error
}

PayloadHandlerStub -

func (*PayloadHandlerStub) Close

func (ph *PayloadHandlerStub) Close() error

Close -

func (*PayloadHandlerStub) IsInterfaceNil

func (ph *PayloadHandlerStub) IsInterfaceNil() bool

IsInterfaceNil -

func (*PayloadHandlerStub) ProcessPayload

func (ph *PayloadHandlerStub) ProcessPayload(payload []byte, topic string, version uint32) error

ProcessPayload -

type ProtoMarshallerMock added in v0.0.1

type ProtoMarshallerMock struct {
}

ProtoMarshallerMock implements marshaling with protobuf

func (*ProtoMarshallerMock) IsInterfaceNil added in v0.0.1

func (pmm *ProtoMarshallerMock) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

func (*ProtoMarshallerMock) Marshal added in v0.0.1

func (pmm *ProtoMarshallerMock) Marshal(obj interface{}) ([]byte, error)

Marshal does the actual serialization of an object The object to be serialized must implement the gogoProtoObj interface

func (*ProtoMarshallerMock) Unmarshal added in v0.0.1

func (pmm *ProtoMarshallerMock) Unmarshal(obj interface{}, buff []byte) error

Unmarshal does the actual deserialization of an object The object to be deserialized must implement the gogoProtoObj interface

type WebsocketConnectionStub

type WebsocketConnectionStub struct {
	OpenConnectionCalled func(url string) error
	ReadMessageCalled    func() (messageType int, payload []byte, err error)
	WriteMessageCalled   func(messageType int, data []byte) error
	IsOpenCalled         func() bool
	GetIDCalled          func() string
	CloseCalled          func() error
}

WebsocketConnectionStub -

func (*WebsocketConnectionStub) Close

func (w *WebsocketConnectionStub) Close() error

Close -

func (*WebsocketConnectionStub) GetID

func (w *WebsocketConnectionStub) GetID() string

GetID -

func (*WebsocketConnectionStub) IsInterfaceNil

func (w *WebsocketConnectionStub) IsInterfaceNil() bool

IsInterfaceNil -

func (*WebsocketConnectionStub) IsOpen

func (w *WebsocketConnectionStub) IsOpen() bool

IsOpen --

func (*WebsocketConnectionStub) OpenConnection

func (w *WebsocketConnectionStub) OpenConnection(url string) error

OpenConnection -

func (*WebsocketConnectionStub) ReadMessage

func (w *WebsocketConnectionStub) ReadMessage() (messageType int, payload []byte, err error)

ReadMessage -

func (*WebsocketConnectionStub) WriteMessage

func (w *WebsocketConnectionStub) WriteMessage(messageType int, data []byte) error

WriteMessage -

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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