testutils

package
v0.0.0-...-1310602 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetPrivkeys

func GetPrivkeys(t *testing.T, n int) []*btcec.PrivateKey

GetPrivkeys provides n private keys for testing.

func GetPubkeys

func GetPubkeys(t *testing.T, n int) []*btcec.PublicKey

GetPubkeys provides n public keys for testing.

func MockBlindedRoute

func MockBlindedRoute(m *mock.Mock, features []lndwire.FeatureBit,
	path *sphinx.BlindedPath, err error)

MockBlindedRoute primes our mock to return the error provided when send custom message is called with any CustomMessage.

func MockConnect

func MockConnect(m *mock.Mock, peer route.Vertex, host string, perm bool,
	err error)

MockConnect primes our mock to return error specified on a call to Connect.

func MockDeriveSharedKey

func MockDeriveSharedKey(m *mock.Mock, ephemeral *btcec.PublicKey,
	locator *keychain.KeyLocator, key [32]byte, err error)

MockDeriveSharedKey primes our mock to return the key and error provided when derive shared key is called.

func MockGetInfo

func MockGetInfo(m *mock.Mock, info *lndclient.Info, err error)

MockGetInfo primes our mock to return the info and error provided when GetInfo is called.

func MockGetNodeInfo

func MockGetNodeInfo(m *mock.Mock, pubkey route.Vertex, includeChannels bool,
	info *lndclient.NodeInfo, err error)

MockGetNodeInfo primes our mock to return the info and error provided when a call to get node info with the peer/include channels params is made.

func MockListChannels

func MockListChannels(m *mock.Mock, activeOnly, publicOnly bool,
	channels []lndclient.ChannelInfo, err error)

MockListChannels primes our mock to return the channel list and error provided when ListChannels is called.

func MockListPeers

func MockListPeers(m *mock.Mock, peers []lndclient.Peer, err error)

MockListPeers primes our mock to return the peers and error specified on a call to ListPeers.

func MockQueryRoutes

func MockQueryRoutes(m *mock.Mock, req lndclient.QueryRoutesRequest,
	resp *lndclient.QueryRoutesResponse, err error)

MockQueryRoutes primes our mock to return the response provided on a call to query routes.

func MockSendAnyCustomMessage

func MockSendAnyCustomMessage(m *mock.Mock, err error)

MockSendAnyCustomMessage primes our mock to return the error provided when send custom message is called with any CustomMessage.

func MockSubscribeCustomMessages

func MockSubscribeCustomMessages(m *mock.Mock,
	msgChan <-chan lndclient.CustomMessage, errChan <-chan error,
	err error)

MockSubscribeCustomMessages primes our mock to return the channels and error provided when we subscribe to custom messages.

Types

type MockLND

type MockLND struct {
	*mock.Mock
}

MockLND creates a mock that substitutes for an API connection to lnd.

func NewMockLnd

func NewMockLnd() *MockLND

NewMockLnd creates a lnd mock.

func (*MockLND) Connect

func (m *MockLND) Connect(ctx context.Context, peer route.Vertex, host string,
	permanent bool) error

Connect mocks a connection to the peer provided.

func (*MockLND) DeriveSharedKey

func (m *MockLND) DeriveSharedKey(ctx context.Context,
	ephemeralPubKey *btcec.PublicKey, keyLocator *keychain.KeyLocator) (
	[32]byte, error)

DeriveSharedKey mocks lnd's ECDH operations.

func (*MockLND) GetInfo

func (m *MockLND) GetInfo(ctx context.Context) (*lndclient.Info, error)

GetInfo mocks a call to lnd's getinfo.

func (*MockLND) GetNodeInfo

func (m *MockLND) GetNodeInfo(ctx context.Context, pubkey route.Vertex,
	includeChannels bool) (*lndclient.NodeInfo, error)

GetNodeInfo mocks looking up a node in the public ln graph.

func (*MockLND) ListChannels

func (m *MockLND) ListChannels(ctx context.Context, activeOnly,
	publicOnly bool) ([]lndclient.ChannelInfo, error)

ListChannels mocks a call to lnd's list channels api.

func (*MockLND) ListPeers

func (m *MockLND) ListPeers(ctx context.Context) ([]lndclient.Peer, error)

ListPeers mocks returning lnd's current set of peers.

func (*MockLND) QueryRoutes

QueryRoutes mocks a call to lnd's query routes api.

func (*MockLND) SendCustomMessage

func (m *MockLND) SendCustomMessage(ctx context.Context,
	msg lndclient.CustomMessage) error

SendCustomMessage mocks sending a custom message to a peer.

func (*MockLND) SubscribeCustomMessages

func (m *MockLND) SubscribeCustomMessages(ctx context.Context) (
	<-chan lndclient.CustomMessage, <-chan error, error)

SubscribeCustomMessages mocks subscribing to custom messages from lnd.

type MockRouteGenerator

type MockRouteGenerator struct {
	*mock.Mock
}

MockRouteGenerator creates a mock that substitutes for blinded route generation.

func NewMockRouteGenerator

func NewMockRouteGenerator() *MockRouteGenerator

NewMockRouteGenerator produces a mock for blinded path generation.

func (*MockRouteGenerator) ReplyPath

func (m *MockRouteGenerator) ReplyPath(ctx context.Context,
	features []lndwire.FeatureBit) (*sphinx.BlindedPath, error)

ReplyPath mocks creation of a blinded route.

Jump to

Keyboard shortcuts

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