Documentation ¶
Overview ¶
Package lntest provides testing utilities for the lnd repository.
This package contains infrastructure for integration tests that launch full lnd nodes in a controlled environment and interact with them via RPC. Using a NetworkHarness, a test can launch multiple lnd nodes, open channels between them, create defined network topologies, and anything else that is possible with RPC commands.
Index ¶
- Constants
- func CalcStaticFee(c lnrpc.CommitmentType, numHTLCs int) btcutil.Amount
- func CalcStaticFeeBuffer(c lnrpc.CommitmentType, numHTLCs int) btcutil.Amount
- func CalculateMaxHtlc(chanCap btcutil.Amount) uint64
- func ChanPointFromPendingUpdate(pu *lnrpc.PendingUpdate) *lnrpc.ChannelPoint
- func CommitTypeHasAnchors(commitType lnrpc.CommitmentType) bool
- func CommitTypeHasTaproot(commitType lnrpc.CommitmentType) bool
- func CopyFile(dest, src string) error
- func NodeArgsForCommitType(commitType lnrpc.CommitmentType) []string
- func ParseDerivationPath(path string) ([]uint32, error)
- type BtcdBackendConfig
- type FeeService
- type HarnessOpt
- type HarnessTest
- func (h *HarnessTest) AssertActiveHtlcs(hn *node.HarnessNode, payHashes ...[]byte)
- func (h *HarnessTest) AssertActiveNodesSynced()
- func (h *HarnessTest) AssertActiveNodesSyncedTo(bestBlock *wire.MsgBlock)
- func (h *HarnessTest) AssertAllTxesSpendFrom(txes []*wire.MsgTx, prevTxid chainhash.Hash)
- func (h *HarnessTest) AssertAmountPaid(channelName string, hn *node.HarnessNode, chanPoint *lnrpc.ChannelPoint, ...)
- func (h *HarnessTest) AssertChannelActive(hn *node.HarnessNode, cp *lnrpc.ChannelPoint) *lnrpc.Channel
- func (h *HarnessTest) AssertChannelBalanceResp(hn *node.HarnessNode, expected *lnrpc.ChannelBalanceResponse)
- func (h *HarnessTest) AssertChannelCommitHeight(hn *node.HarnessNode, cp *lnrpc.ChannelPoint, height int)
- func (h *HarnessTest) AssertChannelExists(hn *node.HarnessNode, cp *lnrpc.ChannelPoint) *lnrpc.Channel
- func (h *HarnessTest) AssertChannelInactive(hn *node.HarnessNode, cp *lnrpc.ChannelPoint) *lnrpc.Channel
- func (h *HarnessTest) AssertChannelLocalBalance(hn *node.HarnessNode, cp *lnrpc.ChannelPoint, balance int64) *lnrpc.Channel
- func (h *HarnessTest) AssertChannelNumUpdates(hn *node.HarnessNode, num uint64, cp *lnrpc.ChannelPoint)
- func (h *HarnessTest) AssertChannelPendingForceClose(hn *node.HarnessNode, chanPoint *lnrpc.ChannelPoint) PendingForceClose
- func (h *HarnessTest) AssertChannelPolicy(hn *node.HarnessNode, advertisingNode string, ...)
- func (h *HarnessTest) AssertChannelPolicyUpdate(hn *node.HarnessNode, advertisingNode *node.HarnessNode, ...)
- func (h *HarnessTest) AssertChannelWaitingClose(hn *node.HarnessNode, chanPoint *lnrpc.ChannelPoint) WaitingCloseChannel
- func (h *HarnessTest) AssertClosingTxInMempool(cp *lnrpc.ChannelPoint, c lnrpc.CommitmentType) *wire.MsgTx
- func (h *HarnessTest) AssertConnected(a, b *node.HarnessNode)
- func (h *HarnessTest) AssertFeeReport(hn *node.HarnessNode, day, week, month int)
- func (h *HarnessTest) AssertFirstHTLCError(hn *node.HarnessNode, code lnrpc.Failure_FailureCode)
- func (h *HarnessTest) AssertHTLCNotActive(hn *node.HarnessNode, cp *lnrpc.ChannelPoint, payHash []byte) *lnrpc.HTLC
- func (h *HarnessTest) AssertHtlcEventType(client rpc.HtlcEventsClient, userType routerrpc.HtlcEvent_EventType) *routerrpc.HtlcEvent
- func (h *HarnessTest) AssertHtlcEventTypes(client rpc.HtlcEventsClient, userType routerrpc.HtlcEvent_EventType, ...) *routerrpc.HtlcEvent
- func (h *HarnessTest) AssertHtlcEvents(client rpc.HtlcEventsClient, ...) []*routerrpc.HtlcEvent
- func (h *HarnessTest) AssertIncomingHTLCActive(hn *node.HarnessNode, cp *lnrpc.ChannelPoint, payHash []byte) *lnrpc.HTLC
- func (h *HarnessTest) AssertInvoiceEqual(a, b *lnrpc.Invoice)
- func (h *HarnessTest) AssertInvoiceSettled(hn *node.HarnessNode, addr []byte)
- func (h *HarnessTest) AssertInvoiceState(stream rpc.SingleInvoiceClient, state lnrpc.Invoice_InvoiceState) *lnrpc.Invoice
- func (h *HarnessTest) AssertLastHTLCError(hn *node.HarnessNode, code lnrpc.Failure_FailureCode)
- func (h *HarnessTest) AssertMinerBlockHeightDelta(tempMiner *miner.HarnessMiner, delta int32)
- func (h *HarnessTest) AssertNodeNumChannels(hn *node.HarnessNode, numChannels int)
- func (h *HarnessTest) AssertNodesNumPendingOpenChannels(a, b *node.HarnessNode, expected int)
- func (h *HarnessTest) AssertNotConnected(a, b *node.HarnessNode)
- func (h *HarnessTest) AssertNotInGraph(hn *node.HarnessNode, chanID uint64)
- func (h *HarnessTest) AssertNumActiveHtlcs(hn *node.HarnessNode, num int)
- func (h *HarnessTest) AssertNumChannelUpdates(hn *node.HarnessNode, chanPoint *lnrpc.ChannelPoint, num int)
- func (h *HarnessTest) AssertNumEdges(hn *node.HarnessNode, expected int, includeUnannounced bool) []*lnrpc.ChannelEdge
- func (h *HarnessTest) AssertNumHTLCsAndStage(hn *node.HarnessNode, chanPoint *lnrpc.ChannelPoint, num int, stage uint32)
- func (h *HarnessTest) AssertNumInvoices(hn *node.HarnessNode, num int) []*lnrpc.Invoice
- func (h *HarnessTest) AssertNumNodeAnns(hn *node.HarnessNode, pubkey string, num int) []*lnrpc.NodeUpdate
- func (h *HarnessTest) AssertNumPayments(hn *node.HarnessNode, num int) []*lnrpc.Payment
- func (h *HarnessTest) AssertNumPendingForceClose(hn *node.HarnessNode, num int) []*lnrpc.PendingChannelsResponse_ForceClosedChannel
- func (h *HarnessTest) AssertNumPendingOpenChannels(hn *node.HarnessNode, expected int) []*lnrpc.PendingChannelsResponse_PendingOpenChannel
- func (h *HarnessTest) AssertNumPendingSweeps(hn *node.HarnessNode, n int) []*walletrpc.PendingSweep
- func (h *HarnessTest) AssertNumPolicyUpdates(hn *node.HarnessNode, chanPoint *lnrpc.ChannelPoint, ...)
- func (h *HarnessTest) AssertNumTxsInMempool(n int) []*chainhash.Hash
- func (h *HarnessTest) AssertNumUTXOs(hn *node.HarnessNode, num int) []*lnrpc.Utxo
- func (h *HarnessTest) AssertNumUTXOsConfirmed(hn *node.HarnessNode, num int) []*lnrpc.Utxo
- func (h *HarnessTest) AssertNumUTXOsUnconfirmed(hn *node.HarnessNode, num int) []*lnrpc.Utxo
- func (h *HarnessTest) AssertNumUTXOsWithConf(hn *node.HarnessNode, expectedUtxos int, max, min int32) []*lnrpc.Utxo
- func (h *HarnessTest) AssertNumWaitingClose(hn *node.HarnessNode, num int) []*lnrpc.PendingChannelsResponse_WaitingCloseChannel
- func (h *HarnessTest) AssertOutgoingHTLCActive(hn *node.HarnessNode, cp *lnrpc.ChannelPoint, payHash []byte) *lnrpc.HTLC
- func (h *HarnessTest) AssertOutpointInMempool(op wire.OutPoint) *wire.MsgTx
- func (h *HarnessTest) AssertOutputScriptClass(tx *btcutil.Tx, outputIndex uint32, scriptClass txscript.ScriptClass)
- func (h *HarnessTest) AssertPaymentFailureReason(hn *node.HarnessNode, preimage lntypes.Preimage, ...)
- func (h *HarnessTest) AssertPaymentStatus(hn *node.HarnessNode, preimage lntypes.Preimage, ...) *lnrpc.Payment
- func (h *HarnessTest) AssertPaymentStatusFromStream(stream rpc.PaymentClient, status lnrpc.Payment_PaymentStatus) *lnrpc.Payment
- func (h *HarnessTest) AssertPaymentSucceedWithTimeout(stream rpc.PaymentClient, timeout time.Duration) *lnrpc.Payment
- func (h *HarnessTest) AssertPeerConnected(a, b *node.HarnessNode)
- func (h *HarnessTest) AssertPeerNotConnected(a, b *node.HarnessNode)
- func (h *HarnessTest) AssertStreamChannelCoopClosed(hn *node.HarnessNode, cp *lnrpc.ChannelPoint, anchors bool, ...) *chainhash.Hash
- func (h *HarnessTest) AssertStreamChannelForceClosed(hn *node.HarnessNode, cp *lnrpc.ChannelPoint, anchorSweep bool, ...) *chainhash.Hash
- func (h *HarnessTest) AssertSweepFound(hn *node.HarnessNode, sweep string, verbose bool, startHeight int32)
- func (h *HarnessTest) AssertTopologyChannelClosed(hn *node.HarnessNode, chanPoint *lnrpc.ChannelPoint) *lnrpc.ClosedChannelUpdate
- func (h *HarnessTest) AssertTopologyChannelOpen(hn *node.HarnessNode, chanPoint *lnrpc.ChannelPoint)
- func (h *HarnessTest) AssertTransactionInWallet(hn *node.HarnessNode, txid chainhash.Hash)
- func (h *HarnessTest) AssertTransactionNotInWallet(hn *node.HarnessNode, txid chainhash.Hash)
- func (h *HarnessTest) AssertTxAtHeight(hn *node.HarnessNode, height int32, txid *chainhash.Hash) *lnrpc.Transaction
- func (h *HarnessTest) AssertTxInBlock(block *wire.MsgBlock, txid *chainhash.Hash)
- func (h *HarnessTest) AssertTxInMempool(txid *chainhash.Hash) *wire.MsgTx
- func (h *HarnessTest) AssertTxNotInMempool(txid chainhash.Hash) *wire.MsgTx
- func (h *HarnessTest) AssertTxSpendFrom(tx *wire.MsgTx, prevTxid chainhash.Hash)
- func (h *HarnessTest) AssertUTXOInWallet(hn *node.HarnessNode, op *lnrpc.OutPoint, account string)
- func (h *HarnessTest) AssertWalletAccountBalance(hn *node.HarnessNode, account string, ...)
- func (h *HarnessTest) AssertWalletLockedBalance(hn *node.HarnessNode, balance int64)
- func (h *HarnessTest) AssertZombieChannel(hn *node.HarnessNode, chanID uint64)
- func (h *HarnessTest) BackupDB(hn *node.HarnessNode)
- func (h *HarnessTest) CalculateTxFee(tx *wire.MsgTx) btcutil.Amount
- func (h *HarnessTest) CalculateTxFeeRate(tx *wire.MsgTx) chainfee.SatPerKWeight
- func (h *HarnessTest) CalculateTxWeight(tx *wire.MsgTx) lntypes.WeightUnit
- func (h *HarnessTest) CalculateTxesFeeRate(txns []*wire.MsgTx) int64
- func (h *HarnessTest) ChainBackendName() string
- func (h *HarnessTest) CleanShutDown()
- func (h *HarnessTest) CleanupForceClose(hn *node.HarnessNode)
- func (h *HarnessTest) CloseChannel(hn *node.HarnessNode, cp *lnrpc.ChannelPoint) *chainhash.Hash
- func (h *HarnessTest) CloseChannelAssertErr(hn *node.HarnessNode, cp *lnrpc.ChannelPoint, force bool) error
- func (h *HarnessTest) CloseChannelAssertPending(hn *node.HarnessNode, cp *lnrpc.ChannelPoint, force bool) (rpc.CloseChanClient, *chainhash.Hash)
- func (h *HarnessTest) CompletePaymentRequests(hn *node.HarnessNode, paymentRequests []string, opts ...HarnessOpt)
- func (h *HarnessTest) CompletePaymentRequestsNoWait(hn *node.HarnessNode, paymentRequests []string, chanPoint *lnrpc.ChannelPoint)
- func (h *HarnessTest) ConnectMiner()
- func (h *HarnessTest) ConnectNodes(a, b *node.HarnessNode)
- func (h *HarnessTest) ConnectNodesPerm(a, b *node.HarnessNode)
- func (h *HarnessTest) ConnectToMiner(tempMiner *miner.HarnessMiner)
- func (h *HarnessTest) Context() context.Context
- func (h *HarnessTest) CreateBurnAddr(addrType lnrpc.AddressType) ([]byte, btcutil.Address)
- func (h *HarnessTest) CreatePayReqs(hn *node.HarnessNode, paymentAmt btcutil.Amount, numInvoices int, ...) ([]string, [][]byte, []*lnrpc.Invoice)
- func (h *HarnessTest) CreateTransaction(outputs []*wire.TxOut, feeRate btcutil.Amount) *wire.MsgTx
- func (h *HarnessTest) CurrentHeight() uint32
- func (h *HarnessTest) DecodeAddress(addr string) btcutil.Address
- func (h *HarnessTest) DisconnectFromMiner(tempMiner *miner.HarnessMiner)
- func (h *HarnessTest) DisconnectMiner()
- func (h *HarnessTest) DisconnectNodes(a, b *node.HarnessNode)
- func (h *HarnessTest) EnsureConnected(a, b *node.HarnessNode)
- func (h *HarnessTest) FindSweepingTxns(txns []*wire.MsgTx, expectedNumSweeps int, closeTxid chainhash.Hash) []*wire.MsgTx
- func (h *HarnessTest) ForceCloseChannel(hn *node.HarnessNode, cp *lnrpc.ChannelPoint) *chainhash.Hash
- func (h *HarnessTest) FundCoins(amt btcutil.Amount, hn *node.HarnessNode)
- func (h *HarnessTest) FundCoinsNP2WKH(amt btcutil.Amount, target *node.HarnessNode)
- func (h *HarnessTest) FundCoinsP2TR(amt btcutil.Amount, target *node.HarnessNode)
- func (h *HarnessTest) FundCoinsUnconfirmed(amt btcutil.Amount, hn *node.HarnessNode)
- func (h *HarnessTest) GetBestBlock() (*chainhash.Hash, int32)
- func (h *HarnessTest) GetChanPointFundingTxid(cp *lnrpc.ChannelPoint) *chainhash.Hash
- func (h *HarnessTest) GetChannelByChanPoint(hn *node.HarnessNode, chanPoint *lnrpc.ChannelPoint) *lnrpc.Channel
- func (h *HarnessTest) GetChannelCommitType(hn *node.HarnessNode, chanPoint *lnrpc.ChannelPoint) lnrpc.CommitmentType
- func (h *HarnessTest) GetNumTxsFromMempool(n int) []*wire.MsgTx
- func (h *HarnessTest) GetOutputIndex(txid *chainhash.Hash, addr string) int
- func (h *HarnessTest) GetRawMempool() []*chainhash.Hash
- func (h *HarnessTest) GetRawTransaction(txid *chainhash.Hash) *btcutil.Tx
- func (h *HarnessTest) GetUTXOs(hn *node.HarnessNode, account string) []*lnrpc.Utxo
- func (h *HarnessTest) GetUTXOsConfirmed(hn *node.HarnessNode, account string) []*lnrpc.Utxo
- func (h *HarnessTest) GetUTXOsUnconfirmed(hn *node.HarnessNode, account string) []*lnrpc.Utxo
- func (h *HarnessTest) IsNeutrinoBackend() bool
- func (h *HarnessTest) KillNode(hn *node.HarnessNode)
- func (h *HarnessTest) MineBlockWithTx(tx *wire.MsgTx) *wire.MsgBlock
- func (h *HarnessTest) MineBlocks(num int)
- func (h *HarnessTest) MineBlocksAndAssertNumTxes(num uint32, numTxs int) []*wire.MsgBlock
- func (h *HarnessTest) MineClosingTx(cp *lnrpc.ChannelPoint) *wire.MsgTx
- func (h *HarnessTest) MineEmptyBlocks(num int) []*wire.MsgBlock
- func (h *HarnessTest) Miner() *miner.HarnessMiner
- func (h *HarnessTest) NewMinerAddress() btcutil.Address
- func (h *HarnessTest) NewNode(name string, extraArgs []string) *node.HarnessNode
- func (h *HarnessTest) NewNodeEtcd(name string, etcdCfg *etcd.Config, password []byte, cluster bool, ...) *node.HarnessNode
- func (h *HarnessTest) NewNodeRemoteSigner(name string, extraArgs []string, password []byte, watchOnly *lnrpc.WatchOnly) *node.HarnessNode
- func (h *HarnessTest) NewNodeWithSeed(name string, extraArgs []string, password []byte, statelessInit bool) (*node.HarnessNode, []string, []byte)
- func (h *HarnessTest) NewNodeWithSeedEtcd(name string, etcdCfg *etcd.Config, password []byte, ...) (*node.HarnessNode, []string, []byte)
- func (h *HarnessTest) OpenChannel(alice, bob *node.HarnessNode, p OpenChannelParams) *lnrpc.ChannelPoint
- func (h *HarnessTest) OpenChannelAssertErr(srcNode, destNode *node.HarnessNode, p OpenChannelParams, expectedErr error)
- func (h *HarnessTest) OpenChannelAssertPending(srcNode, destNode *node.HarnessNode, p OpenChannelParams) *lnrpc.PendingUpdate
- func (h *HarnessTest) OpenChannelAssertStream(srcNode, destNode *node.HarnessNode, p OpenChannelParams) rpc.OpenChanClient
- func (h *HarnessTest) OpenChannelNoAnnounce(alice, bob *node.HarnessNode, p OpenChannelParams) *lnrpc.ChannelPoint
- func (h *HarnessTest) OpenChannelPsbt(srcNode, destNode *node.HarnessNode, p OpenChannelParams) (rpc.OpenChanClient, []byte)
- func (h *HarnessTest) OpenMultiChannelsAsync(reqs []*OpenChannelRequest) []*lnrpc.ChannelPoint
- func (h *HarnessTest) OutPointFromChannelPoint(cp *lnrpc.ChannelPoint) wire.OutPoint
- func (h *HarnessTest) PayToAddrScript(addr btcutil.Address) []byte
- func (h *HarnessTest) QueryChannelByChanPoint(hn *node.HarnessNode, chanPoint *lnrpc.ChannelPoint, opts ...ListChannelOption) *lnrpc.Channel
- func (h *HarnessTest) QueryRoutesAndRetry(hn *node.HarnessNode, req *lnrpc.QueryRoutesRequest) *lnrpc.QueryRoutesResponse
- func (h *HarnessTest) Random32Bytes() []byte
- func (h *HarnessTest) RandomPreimage() lntypes.Preimage
- func (h *HarnessTest) ReceiveChannelEvent(stream rpc.ChannelEventsClient) *lnrpc.ChannelEventUpdate
- func (h *HarnessTest) ReceiveCloseChannelUpdate(stream rpc.CloseChanClient) (*lnrpc.CloseStatusUpdate, error)
- func (h *HarnessTest) ReceiveHtlcEvent(stream rpc.HtlcEventsClient) *routerrpc.HtlcEvent
- func (h *HarnessTest) ReceiveHtlcInterceptor(stream rpc.InterceptorClient) *routerrpc.ForwardHtlcInterceptRequest
- func (h *HarnessTest) ReceiveInvoiceUpdate(stream rpc.InvoiceUpdateClient) *lnrpc.Invoice
- func (h *HarnessTest) ReceiveOpenChannelError(stream rpc.OpenChanClient, expectedErr error)
- func (h *HarnessTest) ReceiveOpenChannelUpdate(stream rpc.OpenChanClient) *lnrpc.OpenStatusUpdate
- func (h *HarnessTest) ReceivePaymentUpdate(stream rpc.PaymentClient) (*lnrpc.Payment, error)
- func (h *HarnessTest) ReceiveSendToRouteUpdate(stream rpc.SendToRouteClient) (*lnrpc.SendResponse, error)
- func (h *HarnessTest) ReceiveSingleInvoice(stream rpc.SingleInvoiceClient) *lnrpc.Invoice
- func (h *HarnessTest) ReceiveTrackPayment(stream rpc.TrackPaymentClient) *lnrpc.Payment
- func (h *HarnessTest) RestartNode(hn *node.HarnessNode)
- func (h *HarnessTest) RestartNodeAndRestoreDB(hn *node.HarnessNode)
- func (h *HarnessTest) RestartNodeNoUnlock(hn *node.HarnessNode)
- func (h *HarnessTest) RestartNodeWithChanBackups(hn *node.HarnessNode, chanBackups ...*lnrpc.ChanBackupSnapshot)
- func (h *HarnessTest) RestartNodeWithExtraArgs(hn *node.HarnessNode, extraArgs []string)
- func (h *HarnessTest) RestoreNodeWithSeed(name string, extraArgs []string, password []byte, mnemonic []string, ...) *node.HarnessNode
- func (h *HarnessTest) RunTestCase(testCase *TestCase)
- func (h *HarnessTest) SendCoins(a, b *node.HarnessNode, amt btcutil.Amount) *wire.MsgTx
- func (h *HarnessTest) SendOutputsWithoutChange(outputs []*wire.TxOut, feeRate btcutil.Amount) *chainhash.Hash
- func (h *HarnessTest) SendPaymentAndAssertStatus(hn *node.HarnessNode, req *routerrpc.SendPaymentRequest, ...) *lnrpc.Payment
- func (h *HarnessTest) SendPaymentAssertFail(hn *node.HarnessNode, req *routerrpc.SendPaymentRequest, ...) *lnrpc.Payment
- func (h *HarnessTest) SendPaymentAssertInflight(hn *node.HarnessNode, req *routerrpc.SendPaymentRequest) *lnrpc.Payment
- func (h *HarnessTest) SendPaymentAssertSettled(hn *node.HarnessNode, req *routerrpc.SendPaymentRequest) *lnrpc.Payment
- func (h *HarnessTest) SendRawTransaction(tx *wire.MsgTx, allowHighFees bool) (chainhash.Hash, error)
- func (h *HarnessTest) SetFeeEstimate(fee chainfee.SatPerKWeight)
- func (h *HarnessTest) SetFeeEstimateWithConf(fee chainfee.SatPerKWeight, conf uint32)
- func (h *HarnessTest) SetMinRelayFeerate(fee chainfee.SatPerKVByte)
- func (h *HarnessTest) SetTestName(name string)
- func (h *HarnessTest) SetupRemoteSigningStandbyNodes()
- func (h *HarnessTest) SetupStandbyNodes()
- func (h *HarnessTest) Shutdown(node *node.HarnessNode)
- func (h *HarnessTest) SpawnTempMiner() *miner.HarnessMiner
- func (h *HarnessTest) Start(chain node.BackendConfig, miner *miner.HarnessMiner)
- func (h *HarnessTest) Stop()
- func (h *HarnessTest) Subtest(t *testing.T) *HarnessTest
- func (h *HarnessTest) SuspendNode(node *node.HarnessNode) func() error
- func (h *HarnessTest) WaitForBalanceConfirmed(hn *node.HarnessNode, expected btcutil.Amount)
- func (h *HarnessTest) WaitForBalanceUnconfirmed(hn *node.HarnessNode, expected btcutil.Amount)
- func (h *HarnessTest) WaitForBlockchainSync(hn *node.HarnessNode)
- func (h *HarnessTest) WaitForBlockchainSyncTo(hn *node.HarnessNode, bestBlock *wire.MsgBlock)
- func (h HarnessTest) WaitForChannelCloseEvent(stream rpc.CloseChanClient) *chainhash.Hash
- func (h HarnessTest) WaitForChannelOpenEvent(stream rpc.OpenChanClient) *lnrpc.ChannelPoint
- func (h *HarnessTest) WaitForGraphSync(hn *node.HarnessNode)
- func (h *HarnessTest) WaitForNodeBlockHeight(hn *node.HarnessNode, height int32)
- type HtlcEvent
- type ListChannelOption
- type OpenChannelParams
- type OpenChannelRequest
- type PendingForceClose
- type TestCase
- type WaitingCloseChannel
- type WebFeeService
Constants ¶
const ( // NeutrinoBackendName is the name of the neutrino backend. NeutrinoBackendName = "neutrino" DefaultTimeout = wait.DefaultTimeout )
const ( // DefaultFeeRateSatPerKw specifies the default fee rate used in the // tests. DefaultFeeRateSatPerKw = 12500 )
Variables ¶
This section is empty.
Functions ¶
func CalcStaticFee ¶
func CalcStaticFee(c lnrpc.CommitmentType, numHTLCs int) btcutil.Amount
CalcStaticFee calculates appropriate fees for commitment transactions. This function provides a simple way to allow test balance assertions to take fee calculations into account.
func CalcStaticFeeBuffer ¶
func CalcStaticFeeBuffer(c lnrpc.CommitmentType, numHTLCs int) btcutil.Amount
CalcStaticFeeBuffer calculates appropriate fee buffer which must be taken into account when sending htlcs.
func CalculateMaxHtlc ¶
CalculateMaxHtlc re-implements the RequiredRemoteChannelReserve of the funding manager's config, which corresponds to the maximum MaxHTLC value we allow users to set when updating a channel policy.
func ChanPointFromPendingUpdate ¶
func ChanPointFromPendingUpdate(pu *lnrpc.PendingUpdate) *lnrpc.ChannelPoint
ChanPointFromPendingUpdate constructs a channel point from a lnrpc pending update.
func CommitTypeHasAnchors ¶
func CommitTypeHasAnchors(commitType lnrpc.CommitmentType) bool
CommitTypeHasAnchors returns whether commitType uses anchor outputs.
func CommitTypeHasTaproot ¶
func CommitTypeHasTaproot(commitType lnrpc.CommitmentType) bool
CommitTypeHasTaproot returns whether commitType is a taproot commitment.
func NodeArgsForCommitType ¶
func NodeArgsForCommitType(commitType lnrpc.CommitmentType) []string
NodeArgsForCommitType returns the command line flag to supply to enable this commitment type.
func ParseDerivationPath ¶
parseDerivationPath parses a path in the form of m/x'/y'/z'/a/b into a slice of [x, y, z, a, b], meaning that the apostrophe is ignored and 2^31 is _not_ added to the numbers.
Types ¶
type BtcdBackendConfig ¶
type BtcdBackendConfig struct {
// contains filtered or unexported fields
}
BtcdBackendConfig is an implementation of the BackendConfig interface backed by a btcd node.
func NewBackend ¶
func NewBackend(miner string, netParams *chaincfg.Params) ( *BtcdBackendConfig, func() error, error)
NewBackend starts a new rpctest.Harness and returns a BtcdBackendConfig for that node. miner should be set to the P2P address of the miner to connect to.
func (BtcdBackendConfig) ConnectMiner ¶
func (b BtcdBackendConfig) ConnectMiner() error
ConnectMiner is called to establish a connection to the test miner.
func (BtcdBackendConfig) Credentials ¶
func (b BtcdBackendConfig) Credentials() (string, string, string, error)
Credentials returns the rpc username, password and host for the backend.
func (BtcdBackendConfig) DisconnectMiner ¶
func (b BtcdBackendConfig) DisconnectMiner() error
DisconnectMiner is called to disconnect the miner.
func (BtcdBackendConfig) GenArgs ¶
func (b BtcdBackendConfig) GenArgs() []string
GenArgs returns the arguments needed to be passed to LND at startup for using this node as a chain backend.
func (BtcdBackendConfig) Name ¶
func (b BtcdBackendConfig) Name() string
Name returns the name of the backend type.
type FeeService ¶
FeeService runs a web service that provides fee estimation information.
func NewFeeService ¶
func NewFeeService(t *testing.T) *FeeService
NewFeeService spins up a go-routine to serve fee estimates.
func (*FeeService) Reset ¶
func (f *FeeService) Reset()
Reset resets the fee rate map to the default value.
func (*FeeService) SetFeeRate ¶
func (f *FeeService) SetFeeRate(fee chainfee.SatPerKWeight, conf uint32)
SetFeeRate sets a fee for the given confirmation target.
func (*FeeService) SetMinRelayFeerate ¶
func (f *FeeService) SetMinRelayFeerate(fee chainfee.SatPerKVByte)
SetMinRelayFeerate sets a min relay feerate.
type HarnessOpt ¶
type HarnessOpt func(*harnessOpts)
HarnessOpt is a functional option that can be used to modify the behavior of harness functionality.
func WithAMP ¶
func WithAMP() HarnessOpt
WithAMP is a functional option that can be used to enable the AMP feature for sending payments.
type HarnessTest ¶
HarnessTest builds on top of a testing.T with enhanced error detection. It is responsible for managing the interactions among different nodes, and providing easy-to-use assertions.
func NewHarnessTest ¶
func NewHarnessTest(t *testing.T, lndBinary string, feeService WebFeeService, dbBackend node.DatabaseBackend, nativeSQL bool) *HarnessTest
NewHarnessTest creates a new instance of a harnessTest from a regular testing.T instance.
func SetupHarness ¶
func SetupHarness(t *testing.T, binaryPath, dbBackendName string, nativeSQL bool, feeService WebFeeService) *HarnessTest
SetupHarness creates a new HarnessTest with a series of setups such that the instance is ready for usage. The setups are, 1. create the directories to hold lnd files. 2. start a btcd miner. 3. start a chain backend(btcd, bitcoind, or neutrino). 4. connect the miner and the chain backend. 5. start the HarnessTest.
func (*HarnessTest) AssertActiveHtlcs ¶
func (h *HarnessTest) AssertActiveHtlcs(hn *node.HarnessNode, payHashes ...[]byte)
AssertActiveHtlcs makes sure the node has the _exact_ HTLCs matching payHashes on _all_ their channels.
func (*HarnessTest) AssertActiveNodesSynced ¶
func (h *HarnessTest) AssertActiveNodesSynced()
AssertActiveNodesSynced asserts all active nodes have synced to the chain.
func (*HarnessTest) AssertActiveNodesSyncedTo ¶
func (h *HarnessTest) AssertActiveNodesSyncedTo(bestBlock *wire.MsgBlock)
AssertActiveNodesSyncedTo asserts all active nodes have synced to the provided bestBlock.
func (*HarnessTest) AssertAllTxesSpendFrom ¶
func (h *HarnessTest) AssertAllTxesSpendFrom(txes []*wire.MsgTx, prevTxid chainhash.Hash)
assertAllTxesSpendFrom asserts that all txes in the list spend from the given tx.
func (*HarnessTest) AssertAmountPaid ¶
func (h *HarnessTest) AssertAmountPaid(channelName string, hn *node.HarnessNode, chanPoint *lnrpc.ChannelPoint, amountSent, amountReceived int64)
AssertAmountPaid checks that the ListChannels command of the provided node list the total amount sent and received as expected for the provided channel.
func (*HarnessTest) AssertChannelActive ¶
func (h *HarnessTest) AssertChannelActive(hn *node.HarnessNode, cp *lnrpc.ChannelPoint) *lnrpc.Channel
AssertChannelActive checks if a channel identified by the specified channel point is active.
func (*HarnessTest) AssertChannelBalanceResp ¶
func (h *HarnessTest) AssertChannelBalanceResp(hn *node.HarnessNode, expected *lnrpc.ChannelBalanceResponse)
AssertChannelBalanceResp makes a ChannelBalance request and checks the returned response matches the expected.
func (*HarnessTest) AssertChannelCommitHeight ¶
func (h *HarnessTest) AssertChannelCommitHeight(hn *node.HarnessNode, cp *lnrpc.ChannelPoint, height int)
AssertChannelCommitHeight asserts the given channel for the node has the expected commit height(`NumUpdates`).
func (*HarnessTest) AssertChannelExists ¶
func (h *HarnessTest) AssertChannelExists(hn *node.HarnessNode, cp *lnrpc.ChannelPoint) *lnrpc.Channel
AssertChannelExists asserts that an active channel identified by the specified channel point exists from the point-of-view of the node.
func (*HarnessTest) AssertChannelInactive ¶
func (h *HarnessTest) AssertChannelInactive(hn *node.HarnessNode, cp *lnrpc.ChannelPoint) *lnrpc.Channel
AssertChannelInactive checks if a channel identified by the specified channel point is inactive.
func (*HarnessTest) AssertChannelLocalBalance ¶
func (h *HarnessTest) AssertChannelLocalBalance(hn *node.HarnessNode, cp *lnrpc.ChannelPoint, balance int64) *lnrpc.Channel
AssertChannelLocalBalance checks the local balance of the given channel is expected. The channel found using the specified channel point is returned.
func (*HarnessTest) AssertChannelNumUpdates ¶
func (h *HarnessTest) AssertChannelNumUpdates(hn *node.HarnessNode, num uint64, cp *lnrpc.ChannelPoint)
AssertChannelNumUpdates checks the num of updates is expected from the given channel.
func (*HarnessTest) AssertChannelPendingForceClose ¶
func (h *HarnessTest) AssertChannelPendingForceClose(hn *node.HarnessNode, chanPoint *lnrpc.ChannelPoint) PendingForceClose
AssertChannelPendingForceClose asserts that the given channel found in the node is pending force close. Returns the PendingForceClose if found.
func (*HarnessTest) AssertChannelPolicy ¶
func (h *HarnessTest) AssertChannelPolicy(hn *node.HarnessNode, advertisingNode string, expectedPolicy *lnrpc.RoutingPolicy, chanPoint *lnrpc.ChannelPoint)
AssertChannelPolicy asserts that the passed node's known channel policy for the passed chanPoint is consistent with the expected policy values.
func (*HarnessTest) AssertChannelPolicyUpdate ¶
func (h *HarnessTest) AssertChannelPolicyUpdate(hn *node.HarnessNode, advertisingNode *node.HarnessNode, policy *lnrpc.RoutingPolicy, chanPoint *lnrpc.ChannelPoint, includeUnannounced bool)
AssertChannelPolicyUpdate checks that the required policy update has happened on the given node.
func (*HarnessTest) AssertChannelWaitingClose ¶
func (h *HarnessTest) AssertChannelWaitingClose(hn *node.HarnessNode, chanPoint *lnrpc.ChannelPoint) WaitingCloseChannel
AssertChannelWaitingClose asserts that the given channel found in the node is waiting close. Returns the WaitingCloseChannel if found.
func (*HarnessTest) AssertClosingTxInMempool ¶
func (h *HarnessTest) AssertClosingTxInMempool(cp *lnrpc.ChannelPoint, c lnrpc.CommitmentType) *wire.MsgTx
AssertClosingTxInMempool assert that the closing transaction of the given channel point can be found in the mempool. If the channel has anchors, it will assert the anchor sweep tx is also in the mempool.
func (*HarnessTest) AssertConnected ¶
func (h *HarnessTest) AssertConnected(a, b *node.HarnessNode)
AssertConnected asserts that two peers are connected.
func (*HarnessTest) AssertFeeReport ¶
func (h *HarnessTest) AssertFeeReport(hn *node.HarnessNode, day, week, month int)
AssertFeeReport checks that the fee report from the given node has the desired day, week, and month sum values.
func (*HarnessTest) AssertFirstHTLCError ¶
func (h *HarnessTest) AssertFirstHTLCError(hn *node.HarnessNode, code lnrpc.Failure_FailureCode)
AssertFirstHTLCError checks that the first HTLC of the last payment sent by the given node failed with the expected failure code.
func (*HarnessTest) AssertHTLCNotActive ¶
func (h *HarnessTest) AssertHTLCNotActive(hn *node.HarnessNode, cp *lnrpc.ChannelPoint, payHash []byte) *lnrpc.HTLC
AssertHLTCNotActive asserts the node doesn't have a pending HTLC in the given channel, which mean either the HTLC never exists, or it was pending and now settled. Returns the HTLC if found and active.
NOTE: to check a pending HTLC becoming settled, first use AssertHLTCActive then follow this check.
func (*HarnessTest) AssertHtlcEventType ¶
func (h *HarnessTest) AssertHtlcEventType(client rpc.HtlcEventsClient, userType routerrpc.HtlcEvent_EventType) *routerrpc.HtlcEvent
AssertHtlcEventType consumes one event from a client and asserts the event type is matched.
func (*HarnessTest) AssertHtlcEventTypes ¶
func (h *HarnessTest) AssertHtlcEventTypes(client rpc.HtlcEventsClient, userType routerrpc.HtlcEvent_EventType, eventType HtlcEvent) *routerrpc.HtlcEvent
AssertHtlcEventType consumes one event from a client and asserts both the user event type the event.Event type is matched.
func (*HarnessTest) AssertHtlcEvents ¶
func (h *HarnessTest) AssertHtlcEvents(client rpc.HtlcEventsClient, fwdCount, fwdFailCount, settleCount, linkFailCount int, userType routerrpc.HtlcEvent_EventType) []*routerrpc.HtlcEvent
AssertHtlcEvents consumes events from a client and ensures that they are of the expected type and contain the expected number of forwards, forward failures and settles.
TODO(yy): needs refactor to reduce its complexity.
func (*HarnessTest) AssertIncomingHTLCActive ¶
func (h *HarnessTest) AssertIncomingHTLCActive(hn *node.HarnessNode, cp *lnrpc.ChannelPoint, payHash []byte) *lnrpc.HTLC
AssertIncomingHTLCActive asserts the node has a pending incoming HTLC in the given channel. Returns the HTLC if found and active.
func (*HarnessTest) AssertInvoiceEqual ¶
func (h *HarnessTest) AssertInvoiceEqual(a, b *lnrpc.Invoice)
AssertInvoiceEqual asserts that two lnrpc.Invoices are equivalent. A custom comparison function is defined for these tests, since proto message returned from unary and streaming RPCs (as of protobuf 1.23.0 and grpc 1.29.1) aren't consistent with the private fields set on the messages. As a result, we avoid using require.Equal and test only the actual data members.
func (*HarnessTest) AssertInvoiceSettled ¶
func (h *HarnessTest) AssertInvoiceSettled(hn *node.HarnessNode, addr []byte)
AssertInvoiceSettled asserts a given invoice specified by its payment address is settled.
func (*HarnessTest) AssertInvoiceState ¶
func (h *HarnessTest) AssertInvoiceState(stream rpc.SingleInvoiceClient, state lnrpc.Invoice_InvoiceState) *lnrpc.Invoice
AssertInvoiceState takes a single invoice subscription stream and asserts that a given invoice has became the desired state before timeout and returns the invoice found.
func (*HarnessTest) AssertLastHTLCError ¶
func (h *HarnessTest) AssertLastHTLCError(hn *node.HarnessNode, code lnrpc.Failure_FailureCode)
AssertLastHTLCError checks that the last sent HTLC of the last payment sent by the given node failed with the expected failure code.
func (*HarnessTest) AssertMinerBlockHeightDelta ¶
func (h *HarnessTest) AssertMinerBlockHeightDelta( tempMiner *miner.HarnessMiner, delta int32)
AssertMinerBlockHeightDelta ensures that tempMiner is 'delta' blocks ahead of miner.
func (*HarnessTest) AssertNodeNumChannels ¶
func (h *HarnessTest) AssertNodeNumChannels(hn *node.HarnessNode, numChannels int)
AssertNodeNumChannels polls the provided node's list channels rpc until it reaches the desired number of total channels.
func (*HarnessTest) AssertNodesNumPendingOpenChannels ¶
func (h *HarnessTest) AssertNodesNumPendingOpenChannels(a, b *node.HarnessNode, expected int)
AssertNodesNumPendingOpenChannels asserts that both of the nodes have the expected number of pending open channels.
func (*HarnessTest) AssertNotConnected ¶
func (h *HarnessTest) AssertNotConnected(a, b *node.HarnessNode)
AssertNotConnected asserts that two peers are not connected.
func (*HarnessTest) AssertNotInGraph ¶
func (h *HarnessTest) AssertNotInGraph(hn *node.HarnessNode, chanID uint64)
AssertNotInGraph asserts that a given channel is either not found at all in the graph or that it has been marked as a zombie.
func (*HarnessTest) AssertNumActiveHtlcs ¶
func (h *HarnessTest) AssertNumActiveHtlcs(hn *node.HarnessNode, num int)
AssertNumActiveHtlcs asserts that a given number of HTLCs are seen in the node's channels.
func (*HarnessTest) AssertNumChannelUpdates ¶
func (h *HarnessTest) AssertNumChannelUpdates(hn *node.HarnessNode, chanPoint *lnrpc.ChannelPoint, num int)
AssertNumChannelUpdates asserts that a given number of channel updates has been seen in the specified node's network topology.
func (*HarnessTest) AssertNumEdges ¶
func (h *HarnessTest) AssertNumEdges(hn *node.HarnessNode, expected int, includeUnannounced bool) []*lnrpc.ChannelEdge
AssertNumEdges checks that an expected number of edges can be found in the node specified.
func (*HarnessTest) AssertNumHTLCsAndStage ¶
func (h *HarnessTest) AssertNumHTLCsAndStage(hn *node.HarnessNode, chanPoint *lnrpc.ChannelPoint, num int, stage uint32)
AssertNumHTLCsAndStage takes a pending force close channel's channel point and asserts the expected number of pending HTLCs and HTLC stage are matched.
func (*HarnessTest) AssertNumInvoices ¶
func (h *HarnessTest) AssertNumInvoices(hn *node.HarnessNode, num int) []*lnrpc.Invoice
AssertNumInvoices asserts that the number of invoices made within the test scope is as expected.
func (*HarnessTest) AssertNumNodeAnns ¶
func (h *HarnessTest) AssertNumNodeAnns(hn *node.HarnessNode, pubkey string, num int) []*lnrpc.NodeUpdate
AssertNumNodeAnns asserts that a given number of node announcements has been seen in the specified node.
func (*HarnessTest) AssertNumPayments ¶
func (h *HarnessTest) AssertNumPayments(hn *node.HarnessNode, num int) []*lnrpc.Payment
AssertNumPayments asserts that the number of payments made within the test scope is as expected, including the incomplete ones.
func (*HarnessTest) AssertNumPendingForceClose ¶
func (h *HarnessTest) AssertNumPendingForceClose(hn *node.HarnessNode, num int) []*lnrpc.PendingChannelsResponse_ForceClosedChannel
AssertNumPendingForceClose checks that a PendingChannels response from the node reports the expected number of pending force close channels.
func (*HarnessTest) AssertNumPendingOpenChannels ¶
func (h *HarnessTest) AssertNumPendingOpenChannels(hn *node.HarnessNode, expected int) []*lnrpc.PendingChannelsResponse_PendingOpenChannel
AssertNumPendingOpenChannels asserts that a given node have the expected number of pending open channels.
func (*HarnessTest) AssertNumPendingSweeps ¶
func (h *HarnessTest) AssertNumPendingSweeps(hn *node.HarnessNode, n int) []*walletrpc.PendingSweep
AssertNumPendingSweeps asserts the number of pending sweeps for the given node.
func (*HarnessTest) AssertNumPolicyUpdates ¶
func (h *HarnessTest) AssertNumPolicyUpdates(hn *node.HarnessNode, chanPoint *lnrpc.ChannelPoint, advertisingNode *node.HarnessNode, num int)
AssertNumPolicyUpdates asserts that a given number of channel policy updates has been seen in the specified node.
func (*HarnessTest) AssertNumTxsInMempool ¶
func (h *HarnessTest) AssertNumTxsInMempool(n int) []*chainhash.Hash
AssertNumTxsInMempool polls until finding the desired number of transactions in the provided miner's mempool. It will asserrt if this number is not met after the given timeout.
func (*HarnessTest) AssertNumUTXOs ¶
func (h *HarnessTest) AssertNumUTXOs(hn *node.HarnessNode, num int) []*lnrpc.Utxo
AssertNumUTXOs asserts the expected num of utxos are seen, including confirmed and unconfirmed outputs.
NOTE: for standby nodes(Alice and Bob), this method takes account of the previous state of the node's UTXOs. Check `AssertNumUTXOsWithConf` for details.
func (*HarnessTest) AssertNumUTXOsConfirmed ¶
func (h *HarnessTest) AssertNumUTXOsConfirmed(hn *node.HarnessNode, num int) []*lnrpc.Utxo
AssertNumUTXOsConfirmed asserts the expected num of confirmed utxos are seen, which means the returned utxos have at least one confirmation.
NOTE: for standby nodes(Alice and Bob), this method takes account of the previous state of the node's UTXOs. Check `AssertNumUTXOsWithConf` for details.
func (*HarnessTest) AssertNumUTXOsUnconfirmed ¶
func (h *HarnessTest) AssertNumUTXOsUnconfirmed(hn *node.HarnessNode, num int) []*lnrpc.Utxo
AssertNumUTXOsUnconfirmed asserts the expected num of unconfirmed utxos are seen.
NOTE: for standby nodes(Alice and Bob), this method takes account of the previous state of the node's UTXOs. Check `AssertNumUTXOsWithConf` for details.
func (*HarnessTest) AssertNumUTXOsWithConf ¶
func (h *HarnessTest) AssertNumUTXOsWithConf(hn *node.HarnessNode, expectedUtxos int, max, min int32) []*lnrpc.Utxo
AssertNumUTXOsWithConf waits for the given number of UTXOs with the specified confirmations range to be available or fails if that isn't the case before the default timeout.
NOTE: for standby nodes(Alice and Bob), this method takes account of the previous state of the node's UTXOs. The previous state is snapshotted when finishing a previous test case via the cleanup function in `Subtest`. In other words, this assertion only checks the new changes made in the current test.
func (*HarnessTest) AssertNumWaitingClose ¶
func (h *HarnessTest) AssertNumWaitingClose(hn *node.HarnessNode, num int) []*lnrpc.PendingChannelsResponse_WaitingCloseChannel
AssertNumWaitingClose checks that a PendingChannels response from the node reports the expected number of waiting close channels.
func (*HarnessTest) AssertOutgoingHTLCActive ¶
func (h *HarnessTest) AssertOutgoingHTLCActive(hn *node.HarnessNode, cp *lnrpc.ChannelPoint, payHash []byte) *lnrpc.HTLC
AssertOutgoingHTLCActive asserts the node has a pending outgoing HTLC in the given channel. Returns the HTLC if found and active.
func (*HarnessTest) AssertOutpointInMempool ¶
func (h *HarnessTest) AssertOutpointInMempool(op wire.OutPoint) *wire.MsgTx
AssertOutpointInMempool asserts a given outpoint can be found in the mempool.
func (*HarnessTest) AssertOutputScriptClass ¶
func (h *HarnessTest) AssertOutputScriptClass(tx *btcutil.Tx, outputIndex uint32, scriptClass txscript.ScriptClass)
AssertOutputScriptClass checks that the specified transaction output has the expected script class.
func (*HarnessTest) AssertPaymentFailureReason ¶
func (h *HarnessTest) AssertPaymentFailureReason(hn *node.HarnessNode, preimage lntypes.Preimage, reason lnrpc.PaymentFailureReason)
AssertPaymentFailureReason asserts that the given node lists a payment with the given preimage which has the expected failure reason.
func (*HarnessTest) AssertPaymentStatus ¶
func (h *HarnessTest) AssertPaymentStatus(hn *node.HarnessNode, preimage lntypes.Preimage, status lnrpc.Payment_PaymentStatus) *lnrpc.Payment
AssertPaymentStatus asserts that the given node list a payment with the given preimage has the expected status. It also checks that the payment has the expected preimage, which is empty when it's not settled and matches the given preimage when it's succeeded.
func (*HarnessTest) AssertPaymentStatusFromStream ¶
func (h *HarnessTest) AssertPaymentStatusFromStream(stream rpc.PaymentClient, status lnrpc.Payment_PaymentStatus) *lnrpc.Payment
AssertPaymentStatusFromStream takes a client stream and asserts the payment is in desired status before default timeout. The payment found is returned once succeeded.
func (*HarnessTest) AssertPaymentSucceedWithTimeout ¶
func (h *HarnessTest) AssertPaymentSucceedWithTimeout(stream rpc.PaymentClient, timeout time.Duration) *lnrpc.Payment
AssertPaymentSucceedWithTimeout asserts that a payment is succeeded within the specified timeout.
func (*HarnessTest) AssertPeerConnected ¶
func (h *HarnessTest) AssertPeerConnected(a, b *node.HarnessNode)
AssertPeerConnected asserts that the given node b is connected to a.
func (*HarnessTest) AssertPeerNotConnected ¶
func (h *HarnessTest) AssertPeerNotConnected(a, b *node.HarnessNode)
AssertPeerNotConnected asserts that the given node b is not connected to a.
func (*HarnessTest) AssertStreamChannelCoopClosed ¶
func (h *HarnessTest) AssertStreamChannelCoopClosed(hn *node.HarnessNode, cp *lnrpc.ChannelPoint, anchors bool, stream rpc.CloseChanClient) *chainhash.Hash
AssertStreamChannelCoopClosed reads an update from the close channel client stream and asserts that the mempool state and node's topology match a coop close. In specific, - assert the channel is waiting close and has the expected ChanStatusFlags. - assert the mempool has the closing txes and anchor sweeps. - mine a block and assert the closing txid is mined. - assert the node has zero waiting close channels. - assert the node has seen the channel close update.
func (*HarnessTest) AssertStreamChannelForceClosed ¶
func (h *HarnessTest) AssertStreamChannelForceClosed(hn *node.HarnessNode, cp *lnrpc.ChannelPoint, anchorSweep bool, stream rpc.CloseChanClient) *chainhash.Hash
AssertStreamChannelForceClosed reads an update from the close channel client stream and asserts that the mempool state and node's topology match a local force close. In specific,
- assert the channel is waiting close and has the expected ChanStatusFlags.
- assert the mempool has the closing txes.
- mine a block and assert the closing txid is mined.
- assert the channel is pending force close.
- assert the node has seen the channel close update.
- assert there's a pending anchor sweep request once the force close tx is confirmed.
func (*HarnessTest) AssertSweepFound ¶
func (h *HarnessTest) AssertSweepFound(hn *node.HarnessNode, sweep string, verbose bool, startHeight int32)
AssertSweepFound looks up a sweep in a nodes list of broadcast sweeps and asserts it's found.
NOTE: Does not account for node's internal state.
func (*HarnessTest) AssertTopologyChannelClosed ¶
func (h *HarnessTest) AssertTopologyChannelClosed(hn *node.HarnessNode, chanPoint *lnrpc.ChannelPoint) *lnrpc.ClosedChannelUpdate
AssertTopologyChannelClosed asserts a given channel is closed by checking the graph topology subscription of the specified node. Returns the closed channel update if found.
func (*HarnessTest) AssertTopologyChannelOpen ¶
func (h *HarnessTest) AssertTopologyChannelOpen(hn *node.HarnessNode, chanPoint *lnrpc.ChannelPoint)
AssertTopologyChannelOpen asserts that a given channel outpoint is seen by the passed node's network topology.
func (*HarnessTest) AssertTransactionInWallet ¶
func (h *HarnessTest) AssertTransactionInWallet(hn *node.HarnessNode, txid chainhash.Hash)
AssertTransactionInWallet asserts a given txid can be found in the node's wallet.
func (*HarnessTest) AssertTransactionNotInWallet ¶
func (h *HarnessTest) AssertTransactionNotInWallet(hn *node.HarnessNode, txid chainhash.Hash)
AssertTransactionNotInWallet asserts a given txid can NOT be found in the node's wallet.
func (*HarnessTest) AssertTxAtHeight ¶
func (h *HarnessTest) AssertTxAtHeight(hn *node.HarnessNode, height int32, txid *chainhash.Hash) *lnrpc.Transaction
AssertTxAtHeight gets all of the transactions that a node's wallet has a record of at the target height, and finds and returns the tx with the target txid, failing if it is not found.
func (*HarnessTest) AssertTxInBlock ¶
func (h *HarnessTest) AssertTxInBlock(block *wire.MsgBlock, txid *chainhash.Hash)
AssertTxInBlock asserts that a given txid can be found in the passed block.
func (*HarnessTest) AssertTxInMempool ¶
func (h *HarnessTest) AssertTxInMempool(txid *chainhash.Hash) *wire.MsgTx
AssertTxInMempool asserts a given transaction can be found in the mempool.
func (*HarnessTest) AssertTxNotInMempool ¶
func (h *HarnessTest) AssertTxNotInMempool(txid chainhash.Hash) *wire.MsgTx
AssertTxNotInMempool asserts a given transaction cannot be found in the mempool. It assumes the mempool is not empty.
NOTE: this should be used after `AssertTxInMempool` to ensure the tx has entered the mempool before. Otherwise it might give false positive and the tx may enter the mempool after the check.
func (*HarnessTest) AssertTxSpendFrom ¶
func (h *HarnessTest) AssertTxSpendFrom(tx *wire.MsgTx, prevTxid chainhash.Hash)
AssertTxSpendFrom asserts that a given tx is spent from a previous tx.
func (*HarnessTest) AssertUTXOInWallet ¶
func (h *HarnessTest) AssertUTXOInWallet(hn *node.HarnessNode, op *lnrpc.OutPoint, account string)
AssertUTXOInWallet asserts that a given UTXO can be found in the node's wallet.
func (*HarnessTest) AssertWalletAccountBalance ¶
func (h *HarnessTest) AssertWalletAccountBalance(hn *node.HarnessNode, account string, confirmedBalance, unconfirmedBalance int64)
AssertWalletAccountBalance asserts that the unconfirmed and confirmed balance for the given account is satisfied by the WalletBalance and ListUnspent RPCs. The unconfirmed balance is not checked for neutrino nodes.
func (*HarnessTest) AssertWalletLockedBalance ¶
func (h *HarnessTest) AssertWalletLockedBalance(hn *node.HarnessNode, balance int64)
AssertWalletLockedBalance asserts the expected amount has been marked as locked in the node's WalletBalance response.
func (*HarnessTest) AssertZombieChannel ¶
func (h *HarnessTest) AssertZombieChannel(hn *node.HarnessNode, chanID uint64)
AssertZombieChannel asserts that a given channel found using the chanID is marked as zombie.
func (*HarnessTest) BackupDB ¶
func (h *HarnessTest) BackupDB(hn *node.HarnessNode)
BackupDB creates a backup of the current database. It will stop the node first, copy the database files, and restart the node.
func (*HarnessTest) CalculateTxFee ¶
func (h *HarnessTest) CalculateTxFee(tx *wire.MsgTx) btcutil.Amount
CalculateTxFee retrieves parent transactions and reconstructs the fee paid.
func (*HarnessTest) CalculateTxFeeRate ¶
func (h *HarnessTest) CalculateTxFeeRate( tx *wire.MsgTx) chainfee.SatPerKWeight
CalculateTxFeeRate calculates the fee rate for a given tx.
func (*HarnessTest) CalculateTxWeight ¶
func (h *HarnessTest) CalculateTxWeight(tx *wire.MsgTx) lntypes.WeightUnit
CalculateTxWeight calculates the weight for a given tx.
TODO(yy): use weight estimator to get more accurate result.
func (*HarnessTest) CalculateTxesFeeRate ¶
func (h *HarnessTest) CalculateTxesFeeRate(txns []*wire.MsgTx) int64
CalculateTxesFeeRate takes a list of transactions and estimates the fee rate used to sweep them.
NOTE: only used in current test file.
func (*HarnessTest) ChainBackendName ¶
func (h *HarnessTest) ChainBackendName() string
ChainBackendName returns the chain backend name used in the test.
func (*HarnessTest) CleanShutDown ¶
func (h *HarnessTest) CleanShutDown()
CleanShutDown is used to quickly end a test by shutting down all non-standby nodes and mining blocks to empty the mempool.
NOTE: this method provides a faster exit for a test that involves force closures as the caller doesn't need to mine all the blocks to make sure the mempool is empty.
func (*HarnessTest) CleanupForceClose ¶
func (h *HarnessTest) CleanupForceClose(hn *node.HarnessNode)
CleanupForceClose mines blocks to clean up the force close process. This is used for tests that are not asserting the expected behavior is found during the force close process, e.g., num of sweeps, etc. Instead, it provides a shortcut to move the test forward with a clean mempool.
func (*HarnessTest) CloseChannel ¶
func (h *HarnessTest) CloseChannel(hn *node.HarnessNode, cp *lnrpc.ChannelPoint) *chainhash.Hash
CloseChannel attempts to coop close a non-anchored channel identified by the passed channel point owned by the passed harness node. The following items are asserted,
- a close pending event is sent from the close channel client.
- the closing tx is found in the mempool.
- the node reports the channel being waiting to close.
- a block is mined and the closing tx should be found in it.
- the node reports zero waiting close channels.
- the node receives a topology update regarding the channel close.
func (*HarnessTest) CloseChannelAssertErr ¶
func (h *HarnessTest) CloseChannelAssertErr(hn *node.HarnessNode, cp *lnrpc.ChannelPoint, force bool) error
CloseChannelAssertErr closes the given channel and asserts an error returned.
func (*HarnessTest) CloseChannelAssertPending ¶
func (h *HarnessTest) CloseChannelAssertPending(hn *node.HarnessNode, cp *lnrpc.ChannelPoint, force bool) (rpc.CloseChanClient, *chainhash.Hash)
CloseChannelAssertPending attempts to close the channel indicated by the passed channel point, initiated by the passed node. Once the CloseChannel rpc is called, it will consume one event and assert it's a close pending event. In addition, it will check that the closing tx can be found in the mempool.
func (*HarnessTest) CompletePaymentRequests ¶
func (h *HarnessTest) CompletePaymentRequests(hn *node.HarnessNode, paymentRequests []string, opts ...HarnessOpt)
CompletePaymentRequests sends payments from a node to complete all payment requests. This function does not return until all payments successfully complete without errors.
func (*HarnessTest) CompletePaymentRequestsNoWait ¶
func (h *HarnessTest) CompletePaymentRequestsNoWait(hn *node.HarnessNode, paymentRequests []string, chanPoint *lnrpc.ChannelPoint)
CompletePaymentRequestsNoWait sends payments from a node to complete all payment requests without waiting for the results. Instead, it checks the number of updates in the specified channel has increased.
func (*HarnessTest) ConnectMiner ¶
func (h *HarnessTest) ConnectMiner()
ConnectMiner connects the miner with the chain backend in the network.
func (*HarnessTest) ConnectNodes ¶
func (h *HarnessTest) ConnectNodes(a, b *node.HarnessNode)
ConnectNodes creates a connection between the two nodes and asserts the connection is succeeded.
func (*HarnessTest) ConnectNodesPerm ¶
func (h *HarnessTest) ConnectNodesPerm(a, b *node.HarnessNode)
ConnectNodesPerm creates a persistent connection between the two nodes and asserts the connection is succeeded.
func (*HarnessTest) ConnectToMiner ¶
func (h *HarnessTest) ConnectToMiner(tempMiner *miner.HarnessMiner)
ConnectToMiner connects the miner to a temp miner.
func (*HarnessTest) Context ¶
func (h *HarnessTest) Context() context.Context
Context returns the run context used in this test. Usaually it should be managed by the test itself otherwise undefined behaviors will occur. It can be used, however, when a test needs to have its own context being managed differently. In that case, instead of using a background context, the run context should be used such that the test context scope can be fully controlled.
func (*HarnessTest) CreateBurnAddr ¶
func (h *HarnessTest) CreateBurnAddr(addrType lnrpc.AddressType) ([]byte, btcutil.Address)
CreateBurnAddr creates a random burn address of the given type.
func (*HarnessTest) CreatePayReqs ¶
func (h *HarnessTest) CreatePayReqs(hn *node.HarnessNode, paymentAmt btcutil.Amount, numInvoices int, routeHints ...*lnrpc.RouteHint) ([]string, [][]byte, []*lnrpc.Invoice)
CreatePayReqs is a helper method that will create a slice of payment requests for the given node.
func (*HarnessTest) CreateTransaction ¶
CreateTransaction uses the miner to create a transaction using the given outputs using the specified fee rate and returns the transaction.
func (*HarnessTest) CurrentHeight ¶
func (h *HarnessTest) CurrentHeight() uint32
CurrentHeight returns the current block height.
func (*HarnessTest) DecodeAddress ¶
func (h *HarnessTest) DecodeAddress(addr string) btcutil.Address
DecodeAddress decodes a given address and asserts there's no error.
func (*HarnessTest) DisconnectFromMiner ¶
func (h *HarnessTest) DisconnectFromMiner(tempMiner *miner.HarnessMiner)
DisconnectFromMiner disconnects the miner from the temp miner.
func (*HarnessTest) DisconnectMiner ¶
func (h *HarnessTest) DisconnectMiner()
DisconnectMiner removes the connection between the miner and the chain backend in the network.
func (*HarnessTest) DisconnectNodes ¶
func (h *HarnessTest) DisconnectNodes(a, b *node.HarnessNode)
DisconnectNodes disconnects the given two nodes and asserts the disconnection is succeeded. The request is made from node a and sent to node b.
func (*HarnessTest) EnsureConnected ¶
func (h *HarnessTest) EnsureConnected(a, b *node.HarnessNode)
EnsureConnected will try to connect to two nodes, returning no error if they are already connected. If the nodes were not connected previously, this will behave the same as ConnectNodes. If a pending connection request has already been made, the method will block until the two nodes appear in each other's peers list, or until the DefaultTimeout expires.
func (*HarnessTest) FindSweepingTxns ¶
func (h *HarnessTest) FindSweepingTxns(txns []*wire.MsgTx, expectedNumSweeps int, closeTxid chainhash.Hash) []*wire.MsgTx
FindSweepingTxns asserts the expected number of sweeping txns are found in the txns specified and return them.
func (*HarnessTest) ForceCloseChannel ¶
func (h *HarnessTest) ForceCloseChannel(hn *node.HarnessNode, cp *lnrpc.ChannelPoint) *chainhash.Hash
ForceCloseChannel attempts to force close a non-anchored channel identified by the passed channel point owned by the passed harness node. The following items are asserted,
- a close pending event is sent from the close channel client.
- the closing tx is found in the mempool.
- the node reports the channel being waiting to close.
- a block is mined and the closing tx should be found in it.
- the node reports zero waiting close channels.
- the node receives a topology update regarding the channel close.
- mine DefaultCSV-1 blocks.
- the node reports zero pending force close channels.
func (*HarnessTest) FundCoins ¶
func (h *HarnessTest) FundCoins(amt btcutil.Amount, hn *node.HarnessNode)
FundCoins attempts to send amt satoshis from the internal mining node to the targeted lightning node using a P2WKH address. 2 blocks are mined after in order to confirm the transaction.
func (*HarnessTest) FundCoinsNP2WKH ¶
func (h *HarnessTest) FundCoinsNP2WKH(amt btcutil.Amount, target *node.HarnessNode)
FundCoinsNP2WKH attempts to send amt satoshis from the internal mining node to the targeted lightning node using a NP2WKH address.
func (*HarnessTest) FundCoinsP2TR ¶
func (h *HarnessTest) FundCoinsP2TR(amt btcutil.Amount, target *node.HarnessNode)
FundCoinsP2TR attempts to send amt satoshis from the internal mining node to the targeted lightning node using a P2TR address.
func (*HarnessTest) FundCoinsUnconfirmed ¶
func (h *HarnessTest) FundCoinsUnconfirmed(amt btcutil.Amount, hn *node.HarnessNode)
FundCoinsUnconfirmed attempts to send amt satoshis from the internal mining node to the targeted lightning node using a P2WKH address. No blocks are mined after and the UTXOs are unconfirmed.
func (*HarnessTest) GetBestBlock ¶
func (h *HarnessTest) GetBestBlock() (*chainhash.Hash, int32)
GetBestBlock makes a RPC request to miner and asserts.
func (*HarnessTest) GetChanPointFundingTxid ¶
func (h *HarnessTest) GetChanPointFundingTxid( cp *lnrpc.ChannelPoint) *chainhash.Hash
GetChanPointFundingTxid takes a channel point and converts it into a chain hash.
func (*HarnessTest) GetChannelByChanPoint ¶
func (h *HarnessTest) GetChannelByChanPoint(hn *node.HarnessNode, chanPoint *lnrpc.ChannelPoint) *lnrpc.Channel
GetChannelByChanPoint tries to find a channel matching the channel point and asserts. It returns the channel found.
func (*HarnessTest) GetChannelCommitType ¶
func (h *HarnessTest) GetChannelCommitType(hn *node.HarnessNode, chanPoint *lnrpc.ChannelPoint) lnrpc.CommitmentType
GetChannelCommitType retrieves the active channel commitment type for the given chan point.
func (*HarnessTest) GetNumTxsFromMempool ¶
func (h *HarnessTest) GetNumTxsFromMempool(n int) []*wire.MsgTx
GetNumTxsFromMempool polls until finding the desired number of transactions in the miner's mempool and returns the full transactions to the caller.
func (*HarnessTest) GetOutputIndex ¶
func (h *HarnessTest) GetOutputIndex(txid *chainhash.Hash, addr string) int
GetOutputIndex returns the output index of the given address in the given transaction.
func (*HarnessTest) GetRawMempool ¶
func (h *HarnessTest) GetRawMempool() []*chainhash.Hash
GetRawMempool makes a RPC call to the miner's GetRawMempool and asserts.
func (*HarnessTest) GetRawTransaction ¶
func (h *HarnessTest) GetRawTransaction(txid *chainhash.Hash) *btcutil.Tx
GetRawTransaction makes a RPC call to the miner's GetRawTransaction and asserts.
func (*HarnessTest) GetUTXOs ¶
func (h *HarnessTest) GetUTXOs(hn *node.HarnessNode, account string) []*lnrpc.Utxo
GetUTXOs returns all the UTXOs for the given node's account, including confirmed and unconfirmed.
func (*HarnessTest) GetUTXOsConfirmed ¶
func (h *HarnessTest) GetUTXOsConfirmed(hn *node.HarnessNode, account string) []*lnrpc.Utxo
GetUTXOsConfirmed returns the confirmed UTXOs for the given node's account.
func (*HarnessTest) GetUTXOsUnconfirmed ¶
func (h *HarnessTest) GetUTXOsUnconfirmed(hn *node.HarnessNode, account string) []*lnrpc.Utxo
GetUTXOsUnconfirmed returns the unconfirmed UTXOs for the given node's account.
func (*HarnessTest) IsNeutrinoBackend ¶
func (h *HarnessTest) IsNeutrinoBackend() bool
IsNeutrinoBackend returns a bool indicating whether the node is using a neutrino as its backend. This is useful when we want to skip certain tests which cannot be done with a neutrino backend.
func (*HarnessTest) KillNode ¶
func (h *HarnessTest) KillNode(hn *node.HarnessNode)
KillNode kills the node (but won't wait for the node process to stop).
func (*HarnessTest) MineBlockWithTx ¶
func (h *HarnessTest) MineBlockWithTx(tx *wire.MsgTx) *wire.MsgBlock
MineBlockWithTx mines a single block to include the specifies tx only.
func (*HarnessTest) MineBlocks ¶
func (h *HarnessTest) MineBlocks(num int)
MineBlocks mines blocks and asserts all active nodes have synced to the chain. It assumes no txns are expected in the blocks.
NOTE: Use `MineBlocksAndAssertNumTxes` if you expect txns in the blocks. Use `MineEmptyBlocks` if you want to make sure that txns stay unconfirmed.
func (*HarnessTest) MineBlocksAndAssertNumTxes ¶
func (h *HarnessTest) MineBlocksAndAssertNumTxes(num uint32, numTxs int) []*wire.MsgBlock
MineBlocksAndAssertNumTxes mines blocks and asserts the number of transactions are found in the first block. It also asserts all active nodes have synced to the chain.
NOTE: this differs from miner's `MineBlocks` as it requires the nodes to be synced.
func (*HarnessTest) MineClosingTx ¶
func (h *HarnessTest) MineClosingTx(cp *lnrpc.ChannelPoint) *wire.MsgTx
AssertClosingTxInMempool assert that the closing transaction of the given channel point can be found in the mempool. If the channel has anchors, it will assert the anchor sweep tx is also in the mempool.
func (*HarnessTest) MineEmptyBlocks ¶
func (h *HarnessTest) MineEmptyBlocks(num int) []*wire.MsgBlock
MineEmptyBlocks mines a given number of empty blocks.
NOTE: this differs from miner's `MineEmptyBlocks` as it requires the nodes to be synced.
func (*HarnessTest) Miner ¶
func (h *HarnessTest) Miner() *miner.HarnessMiner
Miner returns the miner instance.
NOTE: Caller should keep in mind that when using this private instance, certain states won't be managed by the HarnessTest anymore. For instance, when mining directly, the nodes managed by the HarnessTest can be out of sync, and the `HarnessTest.CurrentHeight()` won't be accurate.
func (*HarnessTest) NewMinerAddress ¶
func (h *HarnessTest) NewMinerAddress() btcutil.Address
NewMinerAddress creates a new address for the miner and asserts.
func (*HarnessTest) NewNode ¶
func (h *HarnessTest) NewNode(name string, extraArgs []string) *node.HarnessNode
NewNode creates a new node and asserts its creation. The node is guaranteed to have finished its initialization and all its subservers are started.
func (*HarnessTest) NewNodeEtcd ¶
func (h *HarnessTest) NewNodeEtcd(name string, etcdCfg *etcd.Config, password []byte, cluster bool, leaderSessionTTL int) *node.HarnessNode
NewNodeEtcd starts a new node with seed that'll use an external etcd database as its storage. The passed cluster flag indicates that we'd like the node to join the cluster leader election. We won't wait until RPC is available (this is useful when the node is not expected to become the leader right away).
func (*HarnessTest) NewNodeRemoteSigner ¶
func (h *HarnessTest) NewNodeRemoteSigner(name string, extraArgs []string, password []byte, watchOnly *lnrpc.WatchOnly) *node.HarnessNode
NewNodeRemoteSigner creates a new remote signer node and asserts its creation.
func (*HarnessTest) NewNodeWithSeed ¶
func (h *HarnessTest) NewNodeWithSeed(name string, extraArgs []string, password []byte, statelessInit bool) (*node.HarnessNode, []string, []byte)
NewNodeWithSeed fully initializes a new HarnessNode after creating a fresh aezeed. The provided password is used as both the aezeed password and the wallet password. The generated mnemonic is returned along with the initialized harness node.
func (*HarnessTest) NewNodeWithSeedEtcd ¶
func (h *HarnessTest) NewNodeWithSeedEtcd(name string, etcdCfg *etcd.Config, password []byte, statelessInit, cluster bool, leaderSessionTTL int) (*node.HarnessNode, []string, []byte)
NewNodeWithSeedEtcd starts a new node with seed that'll use an external etcd database as its storage. The passed cluster flag indicates that we'd like the node to join the cluster leader election.
func (*HarnessTest) OpenChannel ¶
func (h *HarnessTest) OpenChannel(alice, bob *node.HarnessNode, p OpenChannelParams) *lnrpc.ChannelPoint
OpenChannel attempts to open a channel with the specified parameters extended from Alice to Bob. Additionally, for public channels, it will mine extra blocks so they are announced to the network. In specific, the following items are asserted,
- for non-zero conf channel, 1 blocks will be mined to confirm the funding tx.
- both nodes should see the channel edge update in their network graph.
- both nodes can report the status of the new channel from ListChannels.
- extra blocks are mined if it's a public channel.
func (*HarnessTest) OpenChannelAssertErr ¶
func (h *HarnessTest) OpenChannelAssertErr(srcNode, destNode *node.HarnessNode, p OpenChannelParams, expectedErr error)
OpenChannelAssertErr opens a channel between node srcNode and destNode, asserts that the expected error is returned from the channel opening.
func (*HarnessTest) OpenChannelAssertPending ¶
func (h *HarnessTest) OpenChannelAssertPending(srcNode, destNode *node.HarnessNode, p OpenChannelParams) *lnrpc.PendingUpdate
OpenChannelAssertPending attempts to open a channel between srcNode and destNode with the passed channel funding parameters. Once the `OpenChannel` is called, it will consume the first event it receives from the open channel client and asserts it's a channel pending event. It returns the `PendingUpdate`.
func (*HarnessTest) OpenChannelAssertStream ¶
func (h *HarnessTest) OpenChannelAssertStream(srcNode, destNode *node.HarnessNode, p OpenChannelParams) rpc.OpenChanClient
OpenChannelAssertStream attempts to open a channel between srcNode and destNode with the passed channel funding parameters. Once the `OpenChannel` is called, it will consume the first event it receives from the open channel client and asserts it's a channel pending event. It returns the open channel stream.
func (*HarnessTest) OpenChannelNoAnnounce ¶
func (h *HarnessTest) OpenChannelNoAnnounce(alice, bob *node.HarnessNode, p OpenChannelParams) *lnrpc.ChannelPoint
OpenChannelNoAnnounce attempts to open a channel with the specified parameters extended from Alice to Bob without mining the necessary blocks to announce the channel. Additionally, the following items are asserted,
- for non-zero conf channel, 1 blocks will be mined to confirm the funding tx.
- both nodes should see the channel edge update in their network graph.
- both nodes can report the status of the new channel from ListChannels.
func (*HarnessTest) OpenChannelPsbt ¶
func (h *HarnessTest) OpenChannelPsbt(srcNode, destNode *node.HarnessNode, p OpenChannelParams) (rpc.OpenChanClient, []byte)
OpenChannelPsbt attempts to open a channel between srcNode and destNode with the passed channel funding parameters. It will assert if the expected step of funding the PSBT is not received from the source node.
func (*HarnessTest) OpenMultiChannelsAsync ¶
func (h *HarnessTest) OpenMultiChannelsAsync( reqs []*OpenChannelRequest) []*lnrpc.ChannelPoint
OpenMultiChannelsAsync takes a list of OpenChannelRequest and opens them in batch. The channel points are returned in same the order of the requests once all of the channel open succeeded.
NOTE: compared to open multiple channel sequentially, this method will be faster as it doesn't need to mine 6 blocks for each channel open. However, it does make debugging the logs more difficult as messages are intertwined.
func (*HarnessTest) OutPointFromChannelPoint ¶
func (h *HarnessTest) OutPointFromChannelPoint( cp *lnrpc.ChannelPoint) wire.OutPoint
OutPointFromChannelPoint creates an outpoint from a given channel point.
func (*HarnessTest) PayToAddrScript ¶
func (h *HarnessTest) PayToAddrScript(addr btcutil.Address) []byte
PayToAddrScript creates a new script from the given address and asserts there's no error.
func (*HarnessTest) QueryChannelByChanPoint ¶
func (h *HarnessTest) QueryChannelByChanPoint(hn *node.HarnessNode, chanPoint *lnrpc.ChannelPoint, opts ...ListChannelOption) *lnrpc.Channel
QueryChannelByChanPoint tries to find a channel matching the channel point and asserts. It returns the channel found.
func (*HarnessTest) QueryRoutesAndRetry ¶
func (h *HarnessTest) QueryRoutesAndRetry(hn *node.HarnessNode, req *lnrpc.QueryRoutesRequest) *lnrpc.QueryRoutesResponse
QueryRoutesAndRetry attempts to keep querying a route until timeout is reached.
NOTE: when a channel is opened, we may need to query multiple times to get it in our QueryRoutes RPC. This happens even after we check the channel is heard by the node using ht.AssertChannelOpen. Deep down, this is because our GraphTopologySubscription and QueryRoutes give different results regarding a specific channel, with the formal reporting it being open while the latter not, resulting GraphTopologySubscription acting "faster" than QueryRoutes. TODO(yy): make sure related subsystems share the same view on a given channel.
func (*HarnessTest) Random32Bytes ¶
func (h *HarnessTest) Random32Bytes() []byte
Random32Bytes generates a random 32 bytes which can be used as a pay hash, preimage, etc.
func (*HarnessTest) RandomPreimage ¶
func (h *HarnessTest) RandomPreimage() lntypes.Preimage
RandomPreimage generates a random preimage which can be used as a payment preimage.
func (*HarnessTest) ReceiveChannelEvent ¶
func (h *HarnessTest) ReceiveChannelEvent( stream rpc.ChannelEventsClient) *lnrpc.ChannelEventUpdate
ReceiveChannelEvent waits until a message is received from the ChannelEventsClient stream or the timeout is reached.
func (*HarnessTest) ReceiveCloseChannelUpdate ¶
func (h *HarnessTest) ReceiveCloseChannelUpdate( stream rpc.CloseChanClient) (*lnrpc.CloseStatusUpdate, error)
ReceiveCloseChannelUpdate waits until a message or an error is received on the subscribe channel close stream or the timeout is reached.
func (*HarnessTest) ReceiveHtlcEvent ¶
func (h *HarnessTest) ReceiveHtlcEvent( stream rpc.HtlcEventsClient) *routerrpc.HtlcEvent
ReceiveHtlcEvent waits until a message is received on the subscribe htlc event stream or the timeout is reached.
func (*HarnessTest) ReceiveHtlcInterceptor ¶
func (h *HarnessTest) ReceiveHtlcInterceptor( stream rpc.InterceptorClient) *routerrpc.ForwardHtlcInterceptRequest
ReceiveHtlcInterceptor waits until a message is received on the htlc interceptor stream or the timeout is reached.
func (*HarnessTest) ReceiveInvoiceUpdate ¶
func (h *HarnessTest) ReceiveInvoiceUpdate( stream rpc.InvoiceUpdateClient) *lnrpc.Invoice
ReceiveInvoiceUpdate waits until a message is received on the subscribe invoice stream or the timeout is reached.
func (*HarnessTest) ReceiveOpenChannelError ¶
func (h *HarnessTest) ReceiveOpenChannelError( stream rpc.OpenChanClient, expectedErr error)
ReceiveOpenChannelError waits for the expected error during the open channel flow from the peer or times out.
func (*HarnessTest) ReceiveOpenChannelUpdate ¶
func (h *HarnessTest) ReceiveOpenChannelUpdate( stream rpc.OpenChanClient) *lnrpc.OpenStatusUpdate
ReceiveOpenChannelUpdate waits until a message is received on the stream or the timeout is reached.
func (*HarnessTest) ReceivePaymentUpdate ¶
func (h *HarnessTest) ReceivePaymentUpdate( stream rpc.PaymentClient) (*lnrpc.Payment, error)
ReceivePaymentUpdate waits until a message is received on the payment client stream or the timeout is reached.
func (*HarnessTest) ReceiveSendToRouteUpdate ¶
func (h *HarnessTest) ReceiveSendToRouteUpdate( stream rpc.SendToRouteClient) (*lnrpc.SendResponse, error)
ReceiveSendToRouteUpdate waits until a message is received on the SendToRoute client stream or the timeout is reached.
func (*HarnessTest) ReceiveSingleInvoice ¶
func (h *HarnessTest) ReceiveSingleInvoice( stream rpc.SingleInvoiceClient) *lnrpc.Invoice
ReceiveSingleInvoice waits until a message is received on the subscribe single invoice stream or the timeout is reached.
func (*HarnessTest) ReceiveTrackPayment ¶
func (h *HarnessTest) ReceiveTrackPayment( stream rpc.TrackPaymentClient) *lnrpc.Payment
ReceiveTrackPayment waits until a message is received on the track payment stream or the timeout is reached.
func (*HarnessTest) RestartNode ¶
func (h *HarnessTest) RestartNode(hn *node.HarnessNode)
RestartNode restarts a given node, unlocks it and asserts it's successfully started.
func (*HarnessTest) RestartNodeAndRestoreDB ¶
func (h *HarnessTest) RestartNodeAndRestoreDB(hn *node.HarnessNode)
RestartNodeAndRestoreDB restarts a given node with a callback to restore the db.
func (*HarnessTest) RestartNodeNoUnlock ¶
func (h *HarnessTest) RestartNodeNoUnlock(hn *node.HarnessNode)
RestartNodeNoUnlock restarts a given node without unlocking its wallet.
func (*HarnessTest) RestartNodeWithChanBackups ¶
func (h *HarnessTest) RestartNodeWithChanBackups(hn *node.HarnessNode, chanBackups ...*lnrpc.ChanBackupSnapshot)
RestartNodeWithChanBackups restarts a given node with the specified channel backups.
func (*HarnessTest) RestartNodeWithExtraArgs ¶
func (h *HarnessTest) RestartNodeWithExtraArgs(hn *node.HarnessNode, extraArgs []string)
RestartNodeWithExtraArgs updates the node's config and restarts it.
func (*HarnessTest) RestoreNodeWithSeed ¶
func (h *HarnessTest) RestoreNodeWithSeed(name string, extraArgs []string, password []byte, mnemonic []string, rootKey string, recoveryWindow int32, chanBackups *lnrpc.ChanBackupSnapshot) *node.HarnessNode
RestoreNodeWithSeed fully initializes a HarnessNode using a chosen mnemonic, password, recovery window, and optionally a set of static channel backups. After providing the initialization request to unlock the node, this method will finish initializing the LightningClient such that the HarnessNode can be used for regular rpc operations.
func (*HarnessTest) RunTestCase ¶
func (h *HarnessTest) RunTestCase(testCase *TestCase)
RunTestCase executes a harness test case. Any errors or panics will be represented as fatal.
func (*HarnessTest) SendCoins ¶
func (h *HarnessTest) SendCoins(a, b *node.HarnessNode, amt btcutil.Amount) *wire.MsgTx
SendCoins sends a coin from node A to node B with the given amount, returns the sending tx.
func (*HarnessTest) SendOutputsWithoutChange ¶
func (h *HarnessTest) SendOutputsWithoutChange(outputs []*wire.TxOut, feeRate btcutil.Amount) *chainhash.Hash
SendOutputsWithoutChange uses the miner to send the given outputs using the specified fee rate and returns the txid.
func (*HarnessTest) SendPaymentAndAssertStatus ¶
func (h *HarnessTest) SendPaymentAndAssertStatus(hn *node.HarnessNode, req *routerrpc.SendPaymentRequest, status lnrpc.Payment_PaymentStatus) *lnrpc.Payment
SendPaymentAndAssertStatus sends a payment from the passed node and asserts the desired status is reached.
func (*HarnessTest) SendPaymentAssertFail ¶
func (h *HarnessTest) SendPaymentAssertFail(hn *node.HarnessNode, req *routerrpc.SendPaymentRequest, reason lnrpc.PaymentFailureReason) *lnrpc.Payment
SendPaymentAssertFail sends a payment from the passed node and asserts the payment is failed with the specified failure reason .
func (*HarnessTest) SendPaymentAssertInflight ¶
func (h *HarnessTest) SendPaymentAssertInflight(hn *node.HarnessNode, req *routerrpc.SendPaymentRequest) *lnrpc.Payment
SendPaymentAssertInflight sends a payment from the passed node and asserts the payment is inflight.
func (*HarnessTest) SendPaymentAssertSettled ¶
func (h *HarnessTest) SendPaymentAssertSettled(hn *node.HarnessNode, req *routerrpc.SendPaymentRequest) *lnrpc.Payment
SendPaymentAssertSettled sends a payment from the passed node and asserts the payment is settled.
func (*HarnessTest) SendRawTransaction ¶
func (h *HarnessTest) SendRawTransaction(tx *wire.MsgTx, allowHighFees bool) (chainhash.Hash, error)
SendRawTransaction submits the encoded transaction to the server which will then relay it to the network.
func (*HarnessTest) SetFeeEstimate ¶
func (h *HarnessTest) SetFeeEstimate(fee chainfee.SatPerKWeight)
SetFeeEstimate sets a fee rate to be returned from fee estimator.
NOTE: this method will set the fee rate for a conf target of 1, which is the fallback fee rate for a `WebAPIEstimator` if a higher conf target's fee rate is not set. This means if the fee rate for conf target 6 is set, the fee estimator will use that value instead.
func (*HarnessTest) SetFeeEstimateWithConf ¶
func (h *HarnessTest) SetFeeEstimateWithConf( fee chainfee.SatPerKWeight, conf uint32)
SetFeeEstimateWithConf sets a fee rate of a specified conf target to be returned from fee estimator.
func (*HarnessTest) SetMinRelayFeerate ¶
func (h *HarnessTest) SetMinRelayFeerate(fee chainfee.SatPerKVByte)
SetMinRelayFeerate sets a min relay fee rate to be returned from fee estimator.
func (*HarnessTest) SetTestName ¶
func (h *HarnessTest) SetTestName(name string)
SetTestName set the test case name.
func (*HarnessTest) SetupRemoteSigningStandbyNodes ¶
func (h *HarnessTest) SetupRemoteSigningStandbyNodes()
SetupRemoteSigningStandbyNodes starts the initial seeder nodes within the test harness in a remote signing configuration. The initial node's wallets will be funded wallets with 100x1 BTC outputs each.
func (*HarnessTest) SetupStandbyNodes ¶
func (h *HarnessTest) SetupStandbyNodes()
SetUp starts the initial seeder nodes within the test harness. The initial node's wallets will be funded wallets with 10x10 BTC outputs each.
func (*HarnessTest) Shutdown ¶
func (h *HarnessTest) Shutdown(node *node.HarnessNode)
Shutdown shuts down the given node and asserts that no errors occur.
func (*HarnessTest) SpawnTempMiner ¶
func (h *HarnessTest) SpawnTempMiner() *miner.HarnessMiner
SpawnTempMiner creates a temp miner and syncs it with the current miner. Once miners are synced, the temp miner is disconnected from the original miner and returned.
func (*HarnessTest) Start ¶
func (h *HarnessTest) Start(chain node.BackendConfig, miner *miner.HarnessMiner)
Start will assemble the chain backend and the miner for the HarnessTest. It also starts the fee service and watches lnd process error.
func (*HarnessTest) Subtest ¶
func (h *HarnessTest) Subtest(t *testing.T) *HarnessTest
Subtest creates a child HarnessTest, which inherits the harness net and stand by nodes created by the parent test. It will return a cleanup function which resets all the standby nodes' configs back to its original state and create snapshots of each nodes' internal state.
func (*HarnessTest) SuspendNode ¶
func (h *HarnessTest) SuspendNode(node *node.HarnessNode) func() error
SuspendNode stops the given node and returns a callback that can be used to start it again.
func (*HarnessTest) WaitForBalanceConfirmed ¶
func (h *HarnessTest) WaitForBalanceConfirmed(hn *node.HarnessNode, expected btcutil.Amount)
WaitForBalanceConfirmed waits until the node sees the expected confirmed balance in its wallet.
func (*HarnessTest) WaitForBalanceUnconfirmed ¶
func (h *HarnessTest) WaitForBalanceUnconfirmed(hn *node.HarnessNode, expected btcutil.Amount)
WaitForBalanceUnconfirmed waits until the node sees the expected unconfirmed balance in its wallet.
func (*HarnessTest) WaitForBlockchainSync ¶
func (h *HarnessTest) WaitForBlockchainSync(hn *node.HarnessNode)
WaitForBlockchainSync waits until the node is synced to chain.
func (*HarnessTest) WaitForBlockchainSyncTo ¶
func (h *HarnessTest) WaitForBlockchainSyncTo(hn *node.HarnessNode, bestBlock *wire.MsgBlock)
WaitForBlockchainSyncTo waits until the node is synced to bestBlock.
func (HarnessTest) WaitForChannelCloseEvent ¶
func (h HarnessTest) WaitForChannelCloseEvent( stream rpc.CloseChanClient) *chainhash.Hash
WaitForChannelCloseEvent waits for a notification that a channel is closed by consuming a message from the passed close channel stream. Returns the closing txid if found.
func (HarnessTest) WaitForChannelOpenEvent ¶
func (h HarnessTest) WaitForChannelOpenEvent( stream rpc.OpenChanClient) *lnrpc.ChannelPoint
WaitForChannelOpenEvent waits for a notification that a channel is open by consuming a message from the passed open channel stream.
func (*HarnessTest) WaitForGraphSync ¶
func (h *HarnessTest) WaitForGraphSync(hn *node.HarnessNode)
WaitForGraphSync waits until the node is synced to graph or times out.
func (*HarnessTest) WaitForNodeBlockHeight ¶
func (h *HarnessTest) WaitForNodeBlockHeight(hn *node.HarnessNode, height int32)
WaitForNodeBlockHeight queries the node for its current block height until it reaches the passed height.
type HtlcEvent ¶
type HtlcEvent int
HtlcEvent maps the series of event types used in `*routerrpc.HtlcEvent_*`.
type ListChannelOption ¶
type ListChannelOption func(r *lnrpc.ListChannelsRequest)
FindChannelOption is a functional type for an option that modifies a ListChannelsRequest.
func WithPeerAliasLookup ¶
func WithPeerAliasLookup() ListChannelOption
WithPeerAliasLookup is an option for setting the peer alias lookup flag on a ListChannelsRequest.
type OpenChannelParams ¶
type OpenChannelParams struct { // Amt is the local amount being put into the channel. Amt btcutil.Amount // PushAmt is the amount that should be pushed to the remote when the // channel is opened. PushAmt btcutil.Amount // Private is a boolan indicating whether the opened channel should be // private. Private bool // SpendUnconfirmed is a boolean indicating whether we can utilize // unconfirmed outputs to fund the channel. SpendUnconfirmed bool // MinHtlc is the htlc_minimum_msat value set when opening the channel. MinHtlc lnwire.MilliSatoshi // RemoteMaxHtlcs is the remote_max_htlcs value set when opening the // channel, restricting the number of concurrent HTLCs the remote party // can add to a commitment. RemoteMaxHtlcs uint16 // FundingShim is an optional funding shim that the caller can specify // in order to modify the channel funding workflow. FundingShim *lnrpc.FundingShim // SatPerVByte is the amount of satoshis to spend in chain fees per // virtual byte of the transaction. SatPerVByte btcutil.Amount // ConfTarget is the number of blocks that the funding transaction // should be confirmed in. ConfTarget fn.Option[int32] // CommitmentType is the commitment type that should be used for the // channel to be opened. CommitmentType lnrpc.CommitmentType // ZeroConf is used to determine if the channel will be a zero-conf // channel. This only works if the explicit negotiation is used with // anchors or script enforced leases. ZeroConf bool // ScidAlias denotes whether the channel will be an option-scid-alias // channel type negotiation. ScidAlias bool // BaseFee is the channel base fee applied during the channel // announcement phase. BaseFee uint64 // FeeRate is the channel fee rate in ppm applied during the channel // announcement phase. FeeRate uint64 // UseBaseFee, if set, instructs the downstream logic to apply the // user-specified channel base fee to the channel update announcement. // If set to false it avoids applying a base fee of 0 and instead // activates the default configured base fee. UseBaseFee bool // UseFeeRate, if set, instructs the downstream logic to apply the // user-specified channel fee rate to the channel update announcement. // If set to false it avoids applying a fee rate of 0 and instead // activates the default configured fee rate. UseFeeRate bool // FundMax is a boolean indicating whether the channel should be funded // with the maximum possible amount from the wallet. FundMax bool // An optional note-to-self containing some useful information about the // channel. This is stored locally only, and is purely for reference. It // has no bearing on the channel's operation. Max allowed length is 500 // characters. Memo string // Outpoints is a list of client-selected outpoints that should be used // for funding a channel. If Amt is specified then this amount is // allocated from the sum of outpoints towards funding. If the // FundMax flag is specified the entirety of selected funds is // allocated towards channel funding. Outpoints []*lnrpc.OutPoint // CloseAddress sets the upfront_shutdown_script parameter during // channel open. It is expected to be encoded as a bitcoin address. CloseAddress string }
OpenChannelParams houses the params to specify when opening a new channel.
type OpenChannelRequest ¶
type OpenChannelRequest struct { // Local is the funding node. Local *node.HarnessNode // Remote is the receiving node. Remote *node.HarnessNode // Param is the open channel params. Param OpenChannelParams // contains filtered or unexported fields }
OpenChannelRequest is used to open a channel using the method OpenMultiChannelsAsync.
type PendingForceClose ¶
type PendingForceClose *lnrpc.PendingChannelsResponse_ForceClosedChannel
type TestCase ¶
type TestCase struct { // Name specifies the test name. Name string // TestFunc is the test case wrapped in a function. TestFunc func(t *HarnessTest) }
TestCase defines a test case that's been used in the integration test.
type WaitingCloseChannel ¶
type WaitingCloseChannel *lnrpc.PendingChannelsResponse_WaitingCloseChannel
type WebFeeService ¶
type WebFeeService interface { // Start starts the service. Start() error // Stop stops the service. Stop() error // URL returns the service's endpoint. URL() string // SetFeeRate sets the estimated fee rate for a given confirmation // target. SetFeeRate(feeRate chainfee.SatPerKWeight, conf uint32) // SetMinRelayFeerate sets a min relay feerate. SetMinRelayFeerate(fee chainfee.SatPerKVByte) // Reset resets the fee rate map to the default value. Reset() }
WebFeeService defines an interface that's used to provide fee estimation service used in the integration tests. It must provide an URL so that a lnd node can be started with the flag `--fee.url` and uses the customized fee estimator.