Documentation ¶
Index ¶
- Variables
- func CreateKey(index int32) (*btcec.PrivateKey, *btcec.PublicKey)
- func DumpGoroutines()
- func EncodePayReq(payReq *zpay32.Invoice) (string, error)
- func GetDestAddr(t *testing.T, nr byte) btcutil.Address
- func GetInvoice(hash lntypes.Hash, amt btcutil.Amount, memo string) (string, error)
- func Guard(t *testing.T) func()
- type ConfRegistration
- type Context
- func (ctx *Context) AssertFailed(expectedHash lntypes.Hash)
- func (ctx *Context) AssertPaid(expectedMemo string) func(error)
- func (ctx *Context) AssertRegisterConf(expectTxHash bool) *ConfRegistration
- func (ctx *Context) AssertRegisterSpendNtfn(script []byte)
- func (ctx *Context) AssertSettled(expectedHash lntypes.Hash) lntypes.Preimage
- func (ctx *Context) AssertTrackPayment() TrackPaymentMessage
- func (ctx *Context) DecodeInvoice(request string) *zpay32.Invoice
- func (ctx *Context) GetOutputIndex(tx *wire.MsgTx, script []byte) int
- func (ctx *Context) NotifyConf(tx *wire.MsgTx)
- func (ctx *Context) NotifyServerHeight(height int32)
- func (ctx *Context) NotifySpend(tx *wire.MsgTx, inputIndex uint32)
- func (ctx *Context) ReceiveTx() *wire.MsgTx
- type LndMockServices
- func (s *LndMockServices) AddTx(tx *wire.MsgTx)
- func (s *LndMockServices) DecodeInvoice(request string) (*zpay32.Invoice, error)
- func (s *LndMockServices) IsDone() error
- func (s *LndMockServices) NotifyHeight(height int32) error
- func (s *LndMockServices) SetFeeEstimate(confTarget int32, feeEstimate chainfee.SatPerKWeight)
- type PaymentChannelMessage
- type RouterPaymentChannelMessage
- type SignOutputRawRequest
- type SingleInvoiceSubscription
- type SpendRegistration
- type TrackPaymentMessage
Constants ¶
This section is empty.
Variables ¶
var ( // Timeout is the default timeout when tests wait for something to // happen. Timeout = time.Second * 5 // ErrTimeout is returned on timeout. ErrTimeout = errors.New("test timeout") )
Functions ¶
func CreateKey ¶
func CreateKey(index int32) (*btcec.PrivateKey, *btcec.PublicKey)
CreateKey returns a deterministically generated key pair.
func EncodePayReq ¶
EncodePayReq encodes a zpay32 invoice with a fixed key.
func GetDestAddr ¶
GetDestAddr deterministically generates a sweep address for testing.
func GetInvoice ¶
GetInvoice creates a testnet payment request with the given parameters.
Types ¶
type ConfRegistration ¶
type ConfRegistration struct { TxID *chainhash.Hash PkScript []byte HeightHint int32 NumConfs int32 ConfChan chan *chainntnfs.TxConfirmation }
ConfRegistration contains registration details.
type Context ¶
type Context struct { T *testing.T Lnd *LndMockServices FailedInvoices map[lntypes.Hash]struct{} PaidInvoices map[string]func(error) }
Context contains shared test context functions.
func NewContext ¶
func NewContext(t *testing.T, lnd *LndMockServices) Context
NewContext instanties a new common test context.
func (*Context) AssertFailed ¶
AssertFailed asserts that an invoice with the given hash is failed.
func (*Context) AssertPaid ¶
AssertPaid asserts that the expected payment request has been paid. This function returns a complete function to signal the final payment result.
func (*Context) AssertRegisterConf ¶
func (ctx *Context) AssertRegisterConf(expectTxHash bool) *ConfRegistration
AssertRegisterConf asserts that a register for conf has been received.
func (*Context) AssertRegisterSpendNtfn ¶
AssertRegisterSpendNtfn asserts that a register for spend has been received.
func (*Context) AssertSettled ¶
AssertSettled asserts that an invoice with the given hash is settled.
func (*Context) AssertTrackPayment ¶
func (ctx *Context) AssertTrackPayment() TrackPaymentMessage
AssertTrackPayment asserts that a call was made to track payment, and returns the track payment message so that it can be used to send updates to the test.
func (*Context) DecodeInvoice ¶
DecodeInvoice decodes a payment request string.
func (*Context) GetOutputIndex ¶
GetOutputIndex returns the index in the tx outs of the given script hash.
func (*Context) NotifyConf ¶
NotifyConf simulates a conf.
func (*Context) NotifyServerHeight ¶
NotifyServerHeight notifies the server of the arrival of a new block and waits for the notification to be processed by selecting on a dedicated test channel.
func (*Context) NotifySpend ¶
NotifySpend simulates a spend.
type LndMockServices ¶
type LndMockServices struct { lndclient.LndServices SendPaymentChannel chan PaymentChannelMessage SpendChannel chan *chainntnfs.SpendDetail TxPublishChannel chan *wire.MsgTx SendOutputsChannel chan wire.MsgTx SettleInvoiceChannel chan lntypes.Preimage FailInvoiceChannel chan lntypes.Hash ConfChannel chan *chainntnfs.TxConfirmation RegisterConfChannel chan *ConfRegistration RegisterSpendChannel chan *SpendRegistration SingleInvoiceSubcribeChannel chan *SingleInvoiceSubscription RouterSendPaymentChannel chan RouterPaymentChannelMessage TrackPaymentChannel chan TrackPaymentMessage SignOutputRawChannel chan SignOutputRawRequest Height int32 NodePubkey string Signature []byte SignatureMsg string 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 ClosedChannels []lndclient.ClosedChannel ForwardingEvents []lndclient.ForwardingEvent Payments []lndclient.Payment WaitForFinished func() // contains filtered or unexported fields }
LndMockServices provides a full set of mocked lnd services.
func NewMockLnd ¶
func NewMockLnd() *LndMockServices
NewMockLnd returns a new instance of LndMockServices that can be used in unit tests.
func (*LndMockServices) AddTx ¶
func (s *LndMockServices) AddTx(tx *wire.MsgTx)
AddRelevantTx marks the given transaction as relevant.
func (*LndMockServices) DecodeInvoice ¶
func (s *LndMockServices) DecodeInvoice(request string) (*zpay32.Invoice, error)
DecodeInvoice decodes a payment request string.
func (*LndMockServices) IsDone ¶
func (s *LndMockServices) IsDone() error
IsDone checks whether all channels have been fully emptied. If not this may indicate unexpected behaviour of the code under test.
func (*LndMockServices) NotifyHeight ¶
func (s *LndMockServices) NotifyHeight(height int32) error
NotifyHeight notifies a new block height.
func (*LndMockServices) SetFeeEstimate ¶
func (s *LndMockServices) SetFeeEstimate(confTarget int32, feeEstimate chainfee.SatPerKWeight)
type PaymentChannelMessage ¶
type PaymentChannelMessage struct { PaymentRequest string Done chan lndclient.PaymentResult }
PaymentChannelMessage is the data that passed through SendPaymentChannel.
type RouterPaymentChannelMessage ¶
type RouterPaymentChannelMessage struct { lndclient.SendPaymentRequest TrackPaymentMessage }
RouterPaymentChannelMessage is the data that passed through RouterSendPaymentChannel.
type SignOutputRawRequest ¶
type SignOutputRawRequest struct { Tx *wire.MsgTx SignDescriptors []*lndclient.SignDescriptor }
SignOutputRawRequest contains input data for a tx signing request.
type SingleInvoiceSubscription ¶
type SingleInvoiceSubscription struct { Hash lntypes.Hash Update chan lndclient.InvoiceUpdate Err chan error }
SingleInvoiceSubscription contains the single invoice subscribers
type SpendRegistration ¶
SpendRegistration contains registration details.
type TrackPaymentMessage ¶
type TrackPaymentMessage struct { Hash lntypes.Hash Updates chan lndclient.PaymentStatus Errors chan error }
TrackPaymentMessage is the data that passed through TrackPaymentChannel.