test

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2021 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateKey

func CreateKey(index int32) (*btcec.PrivateKey, *btcec.PublicKey)

CreateKey returns a deterministically generated key pair.

Types

type MockLightning

type MockLightning struct {
	lndclient.LightningClient

	SendPaymentChannel chan PaymentChannelMessage
	NodePubkey         string
	ChainParams        *chaincfg.Params
	ScbKeyRing         *ScbKeyRing

	Transactions []lndclient.Transaction
	Sweeps       []string

	// Invoices is a set of invoices that have been created by the mock,
	// keyed by hash string.
	Invoices map[lntypes.Hash]*lndclient.Invoice

	Channels         []lndclient.ChannelInfo
	ChannelsClosed   []lndclient.ClosedChannel
	ChannelsPending  []lndclient.PendingChannel
	ForwardingEvents []lndclient.ForwardingEvent
	Payments         []lndclient.Payment
	// contains filtered or unexported fields
}

func NewMockLightning

func NewMockLightning() *MockLightning

func (*MockLightning) AddInvoice

func (*MockLightning) ChannelBackup

func (m *MockLightning) ChannelBackup(_ context.Context,
	op wire.OutPoint) ([]byte, error)

ChannelBackup retrieves the backup for a particular channel. The backup is returned as an encrypted chanbackup.Single payload.

func (*MockLightning) ChannelBackups

func (m *MockLightning) ChannelBackups(context.Context) ([]byte, error)

ChannelBackups retrieves backups for all existing pending open and open channels. The backups are returned as an encrypted chanbackup.Multi payload.

func (*MockLightning) CloseChannel

func (*MockLightning) ClosedChannels

func (m *MockLightning) ClosedChannels(
	context.Context) ([]lndclient.ClosedChannel, error)

ClosedChannels returns a list of our closed channels.

func (*MockLightning) ConfirmedWalletBalance

func (m *MockLightning) ConfirmedWalletBalance(context.Context) (
	btcutil.Amount, error)

func (*MockLightning) Connect

func (m *MockLightning) Connect(_ context.Context, peer route.Vertex,
	host string, _ bool) error

func (*MockLightning) Connections

func (m *MockLightning) Connections() map[route.Vertex]string

func (*MockLightning) DecodePaymentRequest

func (m *MockLightning) DecodePaymentRequest(context.Context,
	string) (*lndclient.PaymentRequest, error)

func (*MockLightning) EstimateFeeToP2WSH

func (m *MockLightning) EstimateFeeToP2WSH(context.Context,
	btcutil.Amount, int32) (btcutil.Amount, error)

func (*MockLightning) ForwardingHistory

ForwardingHistory returns the mock's set of forwarding events.

func (*MockLightning) GetChanInfo

func (m *MockLightning) GetChanInfo(ctx context.Context,
	cid uint64) (*lndclient.ChannelEdge, error)

func (*MockLightning) GetInfo

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

func (*MockLightning) ListChannels

func (m *MockLightning) ListChannels(context.Context) ([]lndclient.ChannelInfo,
	error)

ListChannels retrieves all channels of the backing lnd node.

func (*MockLightning) ListInvoices

ListInvoices returns our mock's invoices.

func (*MockLightning) ListPayments

ListPayments makes a paginated call to our list payments endpoint.

func (*MockLightning) ListTransactions

func (m *MockLightning) ListTransactions(context.Context, int32,
	int32) ([]lndclient.Transaction, error)

ListTransactions returns all known transactions of the backing lnd node.

func (*MockLightning) LookupInvoice

func (m *MockLightning) LookupInvoice(_ context.Context,
	hash lntypes.Hash) (*lndclient.Invoice, error)

LookupInvoice looks up an invoice in the mock's set of stored invoices. If it is not found, this call will fail. Note that these invoices should be settled using settleInvoice to have a preimage, settled state and settled date set.

func (*MockLightning) OpenChannel

func (m *MockLightning) OpenChannel(_ context.Context, peer route.Vertex,
	localSat, pushSat btcutil.Amount, _ bool) (*wire.OutPoint, error)

func (*MockLightning) PayInvoice

func (m *MockLightning) PayInvoice(_ context.Context, invoice string,
	_ btcutil.Amount, _ *uint64) chan lndclient.PaymentResult

PayInvoice pays an invoice.

func (*MockLightning) PendingChannels

func (m *MockLightning) PendingChannels(
	context.Context) (*lndclient.PendingChannels, error)

func (*MockLightning) SubscribeChannelBackups

func (m *MockLightning) SubscribeChannelBackups(ctx context.Context,
) (<-chan lnrpc.ChanBackupSnapshot, <-chan error, error)

func (*MockLightning) SubscribeChannelEvents

func (m *MockLightning) SubscribeChannelEvents(ctx context.Context) (
	<-chan *lndclient.ChannelEventUpdate, <-chan error, error)

func (*MockLightning) UpdateChanPolicy

func (m *MockLightning) UpdateChanPolicy(ctx context.Context,
	req lndclient.PolicyUpdateRequest, chanPoint *wire.OutPoint) error

func (*MockLightning) WaitForFinished

func (m *MockLightning) WaitForFinished()

type MockSigner

type MockSigner struct {
	SignOutputRawChannel chan SignOutputRawRequest

	Height       int32
	NodePubkey   string
	Signature    []byte
	SignatureMsg string
}

func NewMockSigner

func NewMockSigner() *MockSigner

func (*MockSigner) ComputeInputScript

func (s *MockSigner) ComputeInputScript(context.Context, *wire.MsgTx,
	[]*lndclient.SignDescriptor) ([]*input.Script, error)

func (*MockSigner) DeriveSharedKey

func (s *MockSigner) DeriveSharedKey(context.Context, *btcec.PublicKey,
	*keychain.KeyLocator) ([32]byte, error)

func (*MockSigner) SignMessage

func (s *MockSigner) SignMessage(context.Context, []byte,
	keychain.KeyLocator) ([]byte, error)

func (*MockSigner) SignOutputRaw

func (s *MockSigner) SignOutputRaw(_ context.Context, tx *wire.MsgTx,
	signDescriptors []*lndclient.SignDescriptor) ([][]byte, error)

func (*MockSigner) VerifyMessage

func (s *MockSigner) VerifyMessage(_ context.Context, msg, sig []byte,
	_ [33]byte) (bool, error)

type MockWalletKit

type MockWalletKit struct {
	TxPublishChannel   chan *wire.MsgTx
	SendOutputsChannel chan wire.MsgTx
	Transactions       []*wire.MsgTx
	Sweeps             []string
	// contains filtered or unexported fields
}

func NewMockWalletKit

func NewMockWalletKit() *MockWalletKit

func (*MockWalletKit) AddTx

func (m *MockWalletKit) AddTx(tx *wire.MsgTx)

AddRelevantTx marks the given transaction as relevant.

func (*MockWalletKit) BumpFee

func (*MockWalletKit) DeriveKey

func (*MockWalletKit) DeriveNextKey

func (m *MockWalletKit) DeriveNextKey(_ context.Context, family int32) (
	*keychain.KeyDescriptor, error)

func (*MockWalletKit) EstimateFee

func (m *MockWalletKit) EstimateFee(_ context.Context, confTarget int32) (
	chainfee.SatPerKWeight, error)

func (*MockWalletKit) LeaseOutput

func (*MockWalletKit) ListSweeps

func (m *MockWalletKit) ListSweeps(_ context.Context) ([]string, error)

ListSweeps returns a list of the sweep transaction ids known to our node.

func (*MockWalletKit) ListUnspent

func (m *MockWalletKit) ListUnspent(context.Context, int32,
	int32) ([]*lnwallet.Utxo, error)

func (*MockWalletKit) NextAddr

func (*MockWalletKit) PublishTransaction

func (m *MockWalletKit) PublishTransaction(_ context.Context,
	tx *wire.MsgTx, label string) error

func (*MockWalletKit) ReleaseOutput

func (*MockWalletKit) SendOutputs

func (m *MockWalletKit) SendOutputs(_ context.Context, outputs []*wire.TxOut,
	_ chainfee.SatPerKWeight, label string) (*wire.MsgTx, error)

type PaymentChannelMessage

type PaymentChannelMessage struct {
	PaymentRequest string
	Done           chan lndclient.PaymentResult
}

PaymentChannelMessage is the data that passed through SendPaymentChannel.

type ScbKeyRing

type ScbKeyRing struct {
	EncryptionKey keychain.KeyDescriptor
}

func (*ScbKeyRing) DeriveKey

func (*ScbKeyRing) DeriveNextKey

func (k *ScbKeyRing) DeriveNextKey(
	keychain.KeyFamily) (keychain.KeyDescriptor, error)

type SignOutputRawRequest

type SignOutputRawRequest struct {
	Tx              *wire.MsgTx
	SignDescriptors []*lndclient.SignDescriptor
}

SignOutputRawRequest contains input data for a tx signing request.

Jump to

Keyboard shortcuts

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