mock

package
v1.8.6 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FakeNetwork

type FakeNetwork struct {
	Hosts map[string]*FakeSocket
	// contains filtered or unexported fields
}

func CreateFakeNetwork

func CreateFakeNetwork() *FakeNetwork

func (*FakeNetwork) Dial

func (n *FakeNetwork) Dial(addr string) (Socket, error)

func (*FakeNetwork) Listen

func (n *FakeNetwork) Listen(addr string) (Socket, error)

type FakeSocket

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

func (*FakeSocket) Receive

func (socket *FakeSocket) Receive(ctx context.Context) (p2p.Message, error)

func (*FakeSocket) Send

func (socket *FakeSocket) Send(msg p2p.Message) error

type MockMessenger

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

func CreateMessenger

func CreateMessenger(network Network, node p2p.Node) *MockMessenger

func (*MockMessenger) ListenForever

func (m *MockMessenger) ListenForever(msgChan chan p2p.Message, ctx context.Context) error

func (*MockMessenger) Send

func (m *MockMessenger) Send(msg p2p.Message, ctx context.Context) error

type Network

type Network interface {
	Listen(addr string) (Socket, error)
	Dial(addr string) (Socket, error)
}

type Socket

type Socket interface {
	Send(msg p2p.Message) error
	Receive(context.Context) (p2p.Message, error)
}

Jump to

Keyboard shortcuts

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