p2ptest

package
v1.0.9 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2022 License: Unlicense Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientFactoryMock

type ClientFactoryMock struct {
	// CreateClientFunc mocks the CreateClient method.
	CreateClientFunc func(ip string, port uint16, target string) (p2p.Client, error)
	// contains filtered or unexported fields
}

ClientFactoryMock is a mock implementation of ClientFactory.

func TestSomethingThatUsesClientFactory(t *testing.T) {

	// make and configure a mocked ClientFactory
	mockedClientFactory := &ClientFactoryMock{
		CreateClientFunc: func(ip string, port uint16, target string) (Client, error) {
			panic("mock out the CreateClient method")
		},
	}

	// use mockedClientFactory in code that requires ClientFactory
	// and then make assertions.

}

func (*ClientFactoryMock) CreateClient

func (mock *ClientFactoryMock) CreateClient(ip string, port uint16, target string) (p2p.Client, error)

CreateClient calls CreateClientFunc.

func (*ClientFactoryMock) CreateClientCalls

func (mock *ClientFactoryMock) CreateClientCalls() []struct {
	IP     string
	Port   uint16
	Target string
}

CreateClientCalls gets all the calls that were made to CreateClient. Check the length with:

len(mockedClientFactory.CreateClientCalls())

type ClientMock

type ClientMock struct {
	// SendFunc mocks the Send method.
	SendFunc func(topic string, req gp2p.Data) (gp2p.Data, error)
	// contains filtered or unexported fields
}

ClientMock is a mock implementation of Client.

func TestSomethingThatUsesClient(t *testing.T) {

	// make and configure a mocked Client
	mockedClient := &ClientMock{
		SendFunc: func(topic string, req p2p.Data) (p2p.Data, error) {
			panic("mock out the Send method")
		},
	}

	// use mockedClient in code that requires Client
	// and then make assertions.

}

func (*ClientMock) Send

func (mock *ClientMock) Send(topic string, req gp2p.Data) (gp2p.Data, error)

Send calls SendFunc.

func (*ClientMock) SendCalls

func (mock *ClientMock) SendCalls() []struct {
	Topic string
	Req   gp2p.Data
}

SendCalls gets all the calls that were made to Send. Check the length with:

len(mockedClient.SendCalls())

type ServerMock

type ServerMock struct {
	// ServeFunc mocks the Serve method.
	ServeFunc func() error

	// SetHandleFunc mocks the SetHandle method.
	SetHandleFunc func(topic string, handler gp2p.Handler)
	// contains filtered or unexported fields
}

ServerMock is a mock implementation of Server.

func TestSomethingThatUsesServer(t *testing.T) {

	// make and configure a mocked Server
	mockedServer := &ServerMock{
		ServeFunc: func() error {
			panic("mock out the Serve method")
		},
		SetHandleFunc: func(topic string, handler p2p.Handler)  {
			panic("mock out the SetHandle method")
		},
	}

	// use mockedServer in code that requires Server
	// and then make assertions.

}

func (*ServerMock) Serve

func (mock *ServerMock) Serve() error

Serve calls ServeFunc.

func (*ServerMock) ServeCalls

func (mock *ServerMock) ServeCalls() []struct {
}

ServeCalls gets all the calls that were made to Serve. Check the length with:

len(mockedServer.ServeCalls())

func (*ServerMock) SetHandle

func (mock *ServerMock) SetHandle(topic string, handler gp2p.Handler)

SetHandle calls SetHandleFunc.

func (*ServerMock) SetHandleCalls

func (mock *ServerMock) SetHandleCalls() []struct {
	Topic   string
	Handler gp2p.Handler
}

SetHandleCalls gets all the calls that were made to SetHandle. Check the length with:

len(mockedServer.SetHandleCalls())

Jump to

Keyboard shortcuts

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