Documentation ¶
Index ¶
- Constants
- func CheckChannelPolicy(policy, expectedPolicy *lnrpc.RoutingPolicy) error
- func CopyFile(dest, src string) error
- func MakeOutpoint(chanPoint *lnrpc.ChannelPoint) (wire.OutPoint, error)
- type HarnessNode
- func (hn *HarnessNode) AddToLog(format string, a ...interface{})
- func (hn *HarnessNode) AdminMacPath() string
- func (hn *HarnessNode) ChanBackupPath() string
- func (hn *HarnessNode) ConnectRPC(useMacs bool) (*grpc.ClientConn, error)
- func (hn *HarnessNode) ConnectRPCWithMacaroon(mac *macaroon.Macaroon) (*grpc.ClientConn, error)
- func (hn *HarnessNode) DBDir() string
- func (hn *HarnessNode) DBPath() string
- func (hn *HarnessNode) FetchNodeInfo() error
- func (hn *HarnessNode) Init(ctx context.Context, initReq *lnrpc.InitWalletRequest) (*lnrpc.InitWalletResponse, error)
- func (hn *HarnessNode) InitChangePassword(ctx context.Context, chngPwReq *lnrpc.ChangePasswordRequest) (*lnrpc.ChangePasswordResponse, error)
- func (hn *HarnessNode) InvoiceMacPath() string
- func (hn *HarnessNode) Name() string
- func (hn *HarnessNode) PrintErr(format string, a ...interface{})
- func (hn *HarnessNode) ReadMacPath() string
- func (hn *HarnessNode) ReadMacaroon(macPath string, timeout time.Duration) (*macaroon.Macaroon, error)
- func (hn *HarnessNode) SetExtraArgs(extraArgs []string)
- func (hn *HarnessNode) Start(litdBinary string, litdError chan<- error, waitForStart bool, ...) error
- func (hn *HarnessNode) Stop() error
- func (hn *HarnessNode) String() string
- func (hn *HarnessNode) TLSCertStr() string
- func (hn *HarnessNode) TLSKeyStr() string
- func (hn *HarnessNode) Unlock(ctx context.Context, unlockReq *lnrpc.UnlockWalletRequest) error
- func (hn *HarnessNode) WaitForBalance(expectedBalance btcutil.Amount, confirmed bool) error
- func (hn *HarnessNode) WaitForBlockchainSync(ctx context.Context) error
- func (hn *HarnessNode) WaitForChannelPolicyUpdate(ctx context.Context, advertisingNode string, policy *lnrpc.RoutingPolicy, ...) error
- func (hn *HarnessNode) WaitForNetworkChannelClose(ctx context.Context, chanPoint *lnrpc.ChannelPoint) error
- func (hn *HarnessNode) WaitForNetworkChannelOpen(ctx context.Context, chanPoint *lnrpc.ChannelPoint) error
- func (hn *HarnessNode) WaitUntilStarted(conn grpc.ClientConnInterface, timeout time.Duration) error
- type LitArgOption
- type LitNodeConfig
- type NetworkHarness
- func (n *NetworkHarness) AssertChannelExists(node *HarnessNode, chanPoint *wire.OutPoint, checks ...func(*lnrpc.Channel)) error
- func (n *NetworkHarness) AssertNodeKnown(node, target *HarnessNode) error
- func (n *NetworkHarness) CloseChannel(lnNode *HarnessNode, cp *lnrpc.ChannelPoint, force bool) (lnrpc.Lightning_CloseChannelClient, *chainhash.Hash, error)
- func (n *NetworkHarness) ConnectNodes(t *testing.T, a, b *HarnessNode)
- func (n *NetworkHarness) ConnectNodesPerm(t *testing.T, a, b *HarnessNode)
- func (n *NetworkHarness) DisconnectNodes(a, b *HarnessNode) error
- func (n *NetworkHarness) DumpLogs(node *HarnessNode) (string, error)
- func (n *NetworkHarness) EnsureConnected(t *testing.T, a, b *HarnessNode)
- func (n *NetworkHarness) KillNode(node *HarnessNode) error
- func (n *NetworkHarness) LookUpNodeByPub(pubStr string) (*HarnessNode, error)
- func (n *NetworkHarness) NewNode(t *testing.T, name string, extraArgs []string, remoteMode bool, wait bool, ...) (*HarnessNode, error)
- func (n *NetworkHarness) OpenChannel(srcNode, destNode *HarnessNode, p lntest.OpenChannelParams) (lnrpc.Lightning_OpenChannelClient, error)
- func (n *NetworkHarness) OpenPendingChannel(srcNode, destNode *HarnessNode, amt btcutil.Amount, pushAmt btcutil.Amount) (*lnrpc.PendingUpdate, error)
- func (n *NetworkHarness) ProcessErrors() <-chan error
- func (n *NetworkHarness) RegisterNode(node *HarnessNode)
- func (n *NetworkHarness) RestartNode(node *HarnessNode, callback func() error, litArgOpts []LitArgOption, ...) error
- func (n *NetworkHarness) RestartNodeNoUnlock(node *HarnessNode, callback func() error, wait bool, ...) error
- func (n *NetworkHarness) SendCoins(t *testing.T, amt btcutil.Amount, target *HarnessNode)
- func (n *NetworkHarness) SendCoinsUnconfirmed(t *testing.T, amt btcutil.Amount, target *HarnessNode)
- func (n *NetworkHarness) SetUp(t *testing.T, testCase string, lndArgs []string) error
- func (n *NetworkHarness) ShutdownNode(node *HarnessNode) error
- func (n *NetworkHarness) Stop()
- func (n *NetworkHarness) StopAndBackupDB(node *HarnessNode) error
- func (n *NetworkHarness) StopAndRestoreDB(node *HarnessNode) error
- func (n *NetworkHarness) StopNode(node *HarnessNode) error
- func (n *NetworkHarness) SuspendNode(node *HarnessNode) (func() error, error)
- func (n *NetworkHarness) TearDown() error
- func (n *NetworkHarness) WaitForChannelClose(stream lnrpc.Lightning_CloseChannelClient) (*lnrpc.ChannelCloseUpdate, error)
- func (n *NetworkHarness) WaitForChannelOpen(openChanStream lnrpc.Lightning_OpenChannelClient) (*lnrpc.ChannelPoint, error)
- type ServerHarness
Constants ¶
const ( // DefaultAutogenValidity is the default validity of a self-signed // certificate. The value corresponds to 14 months // (14 months * 30 days * 24 hours). DefaultAutogenValidity = 14 * 30 * 24 * time.Hour )
Variables ¶
This section is empty.
Functions ¶
func CheckChannelPolicy ¶
func CheckChannelPolicy(policy, expectedPolicy *lnrpc.RoutingPolicy) error
CheckChannelPolicy checks that the policy matches the expected one.
func MakeOutpoint ¶
func MakeOutpoint(chanPoint *lnrpc.ChannelPoint) (wire.OutPoint, error)
MakeOutpoint returns the outpoint of the channel's funding transaction.
Types ¶
type HarnessNode ¶
type HarnessNode struct { Cfg *LitNodeConfig // NodeID is a unique identifier for the node within a NetworkHarness. NodeID int RemoteLnd *node.HarnessNode // PubKey is the serialized compressed identity public key of the node. // This field will only be populated once the node itself has been // started via the start() method. PubKey [33]byte PubKeyStr string lnrpc.LightningClient lnrpc.WalletUnlockerClient invoicesrpc.InvoicesClient // SignerClient cannot be embedded because the name collisions of the // methods SignMessage and VerifyMessage. SignerClient signrpc.SignerClient // RouterClient, WalletKitClient, WatchtowerClient cannot be embedded, // because a name collision would occur with LightningClient. RouterClient routerrpc.RouterClient WalletKitClient walletrpc.WalletKitClient Watchtower watchtowerrpc.WatchtowerClient WatchtowerClient wtclientrpc.WatchtowerClientClient StateClient lnrpc.StateClient // contains filtered or unexported fields }
HarnessNode represents an instance of lnd running within our test network harness. Each HarnessNode instance also fully embeds an RPC client in order to pragmatically drive the node.
func NewNode ¶
func NewNode(t *testing.T, cfg *LitNodeConfig, harness *lntest.HarnessTest) (*HarnessNode, error)
NewNode creates a new test lightning node instance from the passed config.
func (*HarnessNode) AddToLog ¶
func (hn *HarnessNode) AddToLog(format string, a ...interface{})
AddToLog adds a line of choice to the node's logfile. This is useful to interleave test output with output from the node.
func (*HarnessNode) AdminMacPath ¶
func (hn *HarnessNode) AdminMacPath() string
AdminMacPath returns the filepath to the admin.macaroon file for this node.
func (*HarnessNode) ChanBackupPath ¶
func (hn *HarnessNode) ChanBackupPath() string
ChanBackupPath returns the fielpath to the on-disk channel.backup file for this node.
func (*HarnessNode) ConnectRPC ¶
func (hn *HarnessNode) ConnectRPC(useMacs bool) (*grpc.ClientConn, error)
ConnectRPC uses the TLS certificate and admin macaroon files written by the lnd node to create a gRPC client connection.
func (*HarnessNode) ConnectRPCWithMacaroon ¶
func (hn *HarnessNode) ConnectRPCWithMacaroon(mac *macaroon.Macaroon) ( *grpc.ClientConn, error)
ConnectRPCWithMacaroon uses the TLS certificate and given macaroon to create a gRPC client connection.
func (*HarnessNode) DBDir ¶
func (hn *HarnessNode) DBDir() string
DBDir returns the path for the directory holding channeldb file(s).
func (*HarnessNode) DBPath ¶
func (hn *HarnessNode) DBPath() string
DBPath returns the filepath to the channeldb database file for this node.
func (*HarnessNode) FetchNodeInfo ¶
func (hn *HarnessNode) FetchNodeInfo() error
FetchNodeInfo queries an unlocked node to retrieve its public key.
func (*HarnessNode) Init ¶
func (hn *HarnessNode) Init(ctx context.Context, initReq *lnrpc.InitWalletRequest) (*lnrpc.InitWalletResponse, error)
Init initializes a harness node by passing the init request via rpc. After the request is submitted, this method will block until a macaroon-authenticated RPC connection can be established to the harness node. Once established, the new connection is used to initialize the LightningClient and subscribes the HarnessNode to topology changes.
func (*HarnessNode) InitChangePassword ¶
func (hn *HarnessNode) InitChangePassword(ctx context.Context, chngPwReq *lnrpc.ChangePasswordRequest) (*lnrpc.ChangePasswordResponse, error)
InitChangePassword initializes a harness node by passing the change password request via RPC. After the request is submitted, this method will block until a macaroon-authenticated RPC connection can be established to the harness node. Once established, the new connection is used to initialize the LightningClient and subscribes the HarnessNode to topology changes.
func (*HarnessNode) InvoiceMacPath ¶
func (hn *HarnessNode) InvoiceMacPath() string
InvoiceMacPath returns the filepath to the invoice.macaroon file for this node.
func (*HarnessNode) Name ¶
func (hn *HarnessNode) Name() string
Name returns the name of this node set during initialization.
func (*HarnessNode) PrintErr ¶
func (hn *HarnessNode) PrintErr(format string, a ...interface{})
PrintErr prints an error to the console.
func (*HarnessNode) ReadMacPath ¶
func (hn *HarnessNode) ReadMacPath() string
ReadMacPath returns the filepath to the readonly.macaroon file for this node.
func (*HarnessNode) ReadMacaroon ¶
func (hn *HarnessNode) ReadMacaroon(macPath string, timeout time.Duration) ( *macaroon.Macaroon, error)
ReadMacaroon waits a given duration for the macaroon file to be created. If the file is readable within the timeout, its content is de-serialized as a macaroon and returned.
func (*HarnessNode) SetExtraArgs ¶
func (hn *HarnessNode) SetExtraArgs(extraArgs []string)
SetExtraArgs assigns the ExtraArgs field for the node's configuration. The changes will take effect on restart.
func (*HarnessNode) Start ¶
func (hn *HarnessNode) Start(litdBinary string, litdError chan<- error, waitForStart bool, litArgOpts ...LitArgOption) error
Start launches a new process running lnd. Additionally, the PID of the launched process is saved in order to possibly kill the process forcibly later.
This may not clean up properly if an error is returned, so the caller should call shutdown() regardless of the return value.
func (*HarnessNode) Stop ¶
func (hn *HarnessNode) Stop() error
Stop attempts to Stop the active litd process.
func (*HarnessNode) String ¶
func (hn *HarnessNode) String() string
String gives the internal state of the node which is useful for debugging.
func (*HarnessNode) TLSCertStr ¶
func (hn *HarnessNode) TLSCertStr() string
TLSCertStr returns the path where the TLS certificate is stored.
func (*HarnessNode) TLSKeyStr ¶
func (hn *HarnessNode) TLSKeyStr() string
TLSKeyStr returns the path where the TLS key is stored.
func (*HarnessNode) Unlock ¶
func (hn *HarnessNode) Unlock(ctx context.Context, unlockReq *lnrpc.UnlockWalletRequest) error
Unlock attempts to unlock the wallet of the target HarnessNode. This method should be called after the restart of a HarnessNode that was created with a seed+password. Once this method returns, the HarnessNode will be ready to accept normal gRPC requests and harness command.
func (*HarnessNode) WaitForBalance ¶
func (hn *HarnessNode) WaitForBalance(expectedBalance btcutil.Amount, confirmed bool) error
WaitForBalance waits until the node sees the expected confirmed/unconfirmed balance within their wallet.
func (*HarnessNode) WaitForBlockchainSync ¶
func (hn *HarnessNode) WaitForBlockchainSync(ctx context.Context) error
WaitForBlockchainSync waits for the target node to be fully synchronized with the blockchain. If the passed context object has a set timeout, it will continually poll until the timeout has elapsed. In the case that the chain isn't synced before the timeout is up, this function will return an error.
func (*HarnessNode) WaitForChannelPolicyUpdate ¶
func (hn *HarnessNode) WaitForChannelPolicyUpdate(ctx context.Context, advertisingNode string, policy *lnrpc.RoutingPolicy, chanPoint *lnrpc.ChannelPoint, includeUnannounced bool) error
WaitForChannelPolicyUpdate will block until a channel policy with the target outpoint and advertisingNode is seen within the network.
func (*HarnessNode) WaitForNetworkChannelClose ¶
func (hn *HarnessNode) WaitForNetworkChannelClose(ctx context.Context, chanPoint *lnrpc.ChannelPoint) error
WaitForNetworkChannelClose will block until a channel with the target outpoint is seen as closed within the network. A channel is considered closed once a transaction spending the funding outpoint is seen within a confirmed block.
func (*HarnessNode) WaitForNetworkChannelOpen ¶
func (hn *HarnessNode) WaitForNetworkChannelOpen(ctx context.Context, chanPoint *lnrpc.ChannelPoint) error
WaitForNetworkChannelOpen will block until a channel with the target outpoint is seen as being fully advertised within the network. A channel is considered "fully advertised" once both of its directional edges has been advertised within the test Lightning Network.
func (*HarnessNode) WaitUntilStarted ¶
func (hn *HarnessNode) WaitUntilStarted(conn grpc.ClientConnInterface, timeout time.Duration) error
WaitUntilStarted waits until the wallet state flips from "WAITING_TO_START".
type LitArgOption ¶
type LitArgOption func(args *litArgs)
LitArgOption defines the signature of a functional option that can be used to tweak the default arguments of a Litd node.
func WithLitArg ¶
func WithLitArg(key, value string) LitArgOption
WithLitArg can be used to set a Litd config option. An empty value string will mean that the key will be added as a boolean flag.
func WithoutLitArg ¶
func WithoutLitArg(arg string) LitArgOption
WithoutLitArg can be used to delete a litd config option.
type LitNodeConfig ¶
type LitNodeConfig struct { *node.BaseNodeConfig LitArgs []string ActiveArgs *litArgs RemoteMode bool HasSeed bool FaradayMacPath string LoopMacPath string PoolMacPath string TapMacPath string LitTLSCertPath string LitMacPath string UIPassword string LitDir string FaradayDir string LoopDir string PoolDir string TapdDir string LitPort int LitRESTPort int // contains filtered or unexported fields }
func (*LitNodeConfig) GenArgs ¶
func (cfg *LitNodeConfig) GenArgs(opts ...LitArgOption) []string
GenArgs generates a slice of command line arguments from the lightning node config struct.
func (*LitNodeConfig) GenerateListeningPorts ¶
func (cfg *LitNodeConfig) GenerateListeningPorts()
func (*LitNodeConfig) LitAddr ¶
func (cfg *LitNodeConfig) LitAddr() string
func (*LitNodeConfig) LitRESTAddr ¶
func (cfg *LitNodeConfig) LitRESTAddr() string
type NetworkHarness ¶
type NetworkHarness struct { // Miner is a reference to a running full node that can be used to create // new blocks on the network. Miner *lntest.HarnessMiner LNDHarness *lntest.HarnessTest // BackendCfg houses the information necessary to use a node as LND // chain backend, such as rpc configuration, P2P information etc. BackendCfg node.BackendConfig // Alice and Bob are the initial seeder nodes that are automatically // created to be the initial participants of the test network. Alice *HarnessNode Bob *HarnessNode // contains filtered or unexported fields }
NetworkHarness is an integration testing harness for the lightning network. The harness by default is created with two active nodes on the network: Alice and Bob.
func NewNetworkHarness ¶
func NewNetworkHarness(lndHarness *lntest.HarnessTest, b node.BackendConfig, litdBinary string) (*NetworkHarness, error)
NewNetworkHarness creates a new network test harness.
func (*NetworkHarness) AssertChannelExists ¶
func (n *NetworkHarness) AssertChannelExists(node *HarnessNode, chanPoint *wire.OutPoint, checks ...func(*lnrpc.Channel)) error
AssertChannelExists asserts that an active channel identified by the specified channel point exists from the point-of-view of the node. It takes an optional set of check functions which can be used to make further assertions using channel's values. These functions are responsible for failing the test themselves if they do not pass.
func (*NetworkHarness) AssertNodeKnown ¶
func (n *NetworkHarness) AssertNodeKnown(node, target *HarnessNode) error
AssertNodeKnown makes sure the given node knows about the target node in the network graph.
func (*NetworkHarness) CloseChannel ¶
func (n *NetworkHarness) CloseChannel(lnNode *HarnessNode, cp *lnrpc.ChannelPoint, force bool) (lnrpc.Lightning_CloseChannelClient, *chainhash.Hash, error)
CloseChannel attempts to close the channel indicated by the passed channel point, initiated by the passed lnNode. If the passed context has a timeout, an error is returned if that timeout is reached before the channel close is pending.
func (*NetworkHarness) ConnectNodes ¶
func (n *NetworkHarness) ConnectNodes(t *testing.T, a, b *HarnessNode)
ConnectNodes attempts to create a connection between nodes a and b.
func (*NetworkHarness) ConnectNodesPerm ¶
func (n *NetworkHarness) ConnectNodesPerm(t *testing.T, a, b *HarnessNode)
ConnectNodesPerm attempts to connect nodes a and b and sets node b as a peer that node a should persistently attempt to reconnect to if they become disconnected.
func (*NetworkHarness) DisconnectNodes ¶
func (n *NetworkHarness) DisconnectNodes(a, b *HarnessNode) error
DisconnectNodes disconnects node a from node b by sending RPC message from a node to b node
func (*NetworkHarness) DumpLogs ¶
func (n *NetworkHarness) DumpLogs(node *HarnessNode) (string, error)
DumpLogs reads the current logs generated by the passed node, and returns the logs as a single string. This function is useful for examining the logs of a particular node in the case of a test failure. Logs from lightning node being generated with delay - you should add time.Sleep() in order to get all logs.
func (*NetworkHarness) EnsureConnected ¶
func (n *NetworkHarness) EnsureConnected(t *testing.T, a, b *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 15s timeout expires.
func (*NetworkHarness) KillNode ¶
func (n *NetworkHarness) KillNode(node *HarnessNode) error
KillNode kills the node (but won't wait for the node process to stop).
func (*NetworkHarness) LookUpNodeByPub ¶
func (n *NetworkHarness) LookUpNodeByPub(pubStr string) (*HarnessNode, error)
LookUpNodeByPub queries the set of active nodes to locate a node according to its public key. The second value will be true if the node was found, and false otherwise.
func (*NetworkHarness) NewNode ¶
func (n *NetworkHarness) NewNode(t *testing.T, name string, extraArgs []string, remoteMode bool, wait bool, additionalLitArgs ...string) (*HarnessNode, error)
NewNode initializes a new HarnessNode.
func (*NetworkHarness) OpenChannel ¶
func (n *NetworkHarness) OpenChannel(srcNode, destNode *HarnessNode, p lntest.OpenChannelParams) (lnrpc.Lightning_OpenChannelClient, error)
OpenChannel attempts to open a channel between srcNode and destNode with the passed channel funding parameters. If the passed context has a timeout, then if the timeout is reached before the channel pending notification is received, an error is returned. The confirmed boolean determines whether we should fund the channel with confirmed outputs or not.
func (*NetworkHarness) OpenPendingChannel ¶
func (n *NetworkHarness) OpenPendingChannel(srcNode, destNode *HarnessNode, amt btcutil.Amount, pushAmt btcutil.Amount) (*lnrpc.PendingUpdate, error)
OpenPendingChannel attempts to open a channel between srcNode and destNode with the passed channel funding parameters. If the passed context has a timeout, then if the timeout is reached before the channel pending notification is received, an error is returned.
func (*NetworkHarness) ProcessErrors ¶
func (n *NetworkHarness) ProcessErrors() <-chan error
ProcessErrors returns a channel used for reporting any fatal process errors. If any of the active nodes within the harness' test network incur a fatal error, that error is sent over this channel.
func (*NetworkHarness) RegisterNode ¶
func (n *NetworkHarness) RegisterNode(node *HarnessNode)
RegisterNode records a new HarnessNode in the NetworkHarnesses map of known nodes. This method should only be called with nodes that have successfully retrieved their public keys via FetchNodeInfo.
func (*NetworkHarness) RestartNode ¶
func (n *NetworkHarness) RestartNode(node *HarnessNode, callback func() error, litArgOpts []LitArgOption, chanBackups ...*lnrpc.ChanBackupSnapshot) error
RestartNode attempts to restart a lightning node by shutting it down cleanly, then restarting the process. This function is fully blocking. Upon restart, the RPC connection to the node will be re-attempted, continuing iff the connection attempt is successful. If the callback parameter is non-nil, then the function will be executed after the node shuts down, but *before* the process has been started up again.
This method can be useful when testing edge cases such as a node broadcast and invalidated prior state, or persistent state recovery, simulating node crashes, etc. Additionally, each time the node is restarted, the caller can pass a set of SCBs to pass in via the Unlock method allowing them to restore channels during restart.
func (*NetworkHarness) RestartNodeNoUnlock ¶
func (n *NetworkHarness) RestartNodeNoUnlock(node *HarnessNode, callback func() error, wait bool, litArgOpts ...LitArgOption) error
RestartNodeNoUnlock attempts to restart a lightning node by shutting it down cleanly, then restarting the process. In case the node was setup with a seed, it will be left in the unlocked state. This function is fully blocking. If the callback parameter is non-nil, then the function will be executed after the node shuts down, but *before* the process has been started up again.
func (*NetworkHarness) SendCoins ¶
func (n *NetworkHarness) SendCoins(t *testing.T, amt btcutil.Amount, target *HarnessNode)
SendCoins attempts to send amt satoshis from the internal mining node to the targeted lightning node using a P2WKH address. 6 blocks are mined after in order to confirm the transaction.
func (*NetworkHarness) SendCoinsUnconfirmed ¶
func (n *NetworkHarness) SendCoinsUnconfirmed(t *testing.T, amt btcutil.Amount, target *HarnessNode)
SendCoinsUnconfirmed sends coins from the internal mining node to the target lightning node using a P2WPKH address. No blocks are mined after, so the transaction remains unconfirmed.
func (*NetworkHarness) SetUp ¶
SetUp starts the initial seeder nodes within the test harness. The initial node's wallets will be funded wallets with ten 1 BTC outputs each. Finally rpc clients capable of communicating with the initial seeder nodes are created. Nodes are initialized with the given extra command line flags, which should be formatted properly - "--arg=value".
func (*NetworkHarness) ShutdownNode ¶
func (n *NetworkHarness) ShutdownNode(node *HarnessNode) error
ShutdownNode stops an active lnd process and returns when the process has exited and any temporary directories have been cleaned up.
func (*NetworkHarness) StopAndBackupDB ¶
func (n *NetworkHarness) StopAndBackupDB(node *HarnessNode) error
StopAndBackupDB backs up the database of the target node.
func (*NetworkHarness) StopAndRestoreDB ¶
func (n *NetworkHarness) StopAndRestoreDB(node *HarnessNode) error
StopAndRestoreDB stops the target node, restores the database from a backup and starts the node again.
func (*NetworkHarness) StopNode ¶
func (n *NetworkHarness) StopNode(node *HarnessNode) error
StopNode stops the target node, but doesn't yet clean up its directories. This can be used to temporarily bring a node down during a test, to be later started up again.
func (*NetworkHarness) SuspendNode ¶
func (n *NetworkHarness) SuspendNode(node *HarnessNode) (func() error, error)
SuspendNode stops the given node and returns a callback that can be used to start it again.
func (*NetworkHarness) TearDown ¶
func (n *NetworkHarness) TearDown() error
TearDown tears down all active nodes within the test lightning network.
func (*NetworkHarness) WaitForChannelClose ¶
func (n *NetworkHarness) WaitForChannelClose( stream lnrpc.Lightning_CloseChannelClient) (*lnrpc.ChannelCloseUpdate, error)
WaitForChannelClose waits for a notification from the passed channel close stream that the node has deemed the channel has been fully closed. If the passed context has a timeout, then if the timeout is reached before the notification is received then an error is returned.
func (*NetworkHarness) WaitForChannelOpen ¶
func (n *NetworkHarness) WaitForChannelOpen( openChanStream lnrpc.Lightning_OpenChannelClient) (*lnrpc.ChannelPoint, error)
WaitForChannelOpen waits for a notification that a channel is open by consuming a message from the past open channel stream. If the passed context has a timeout, then if the timeout is reached before the channel has been opened, then an error is returned.
type ServerHarness ¶
type ServerHarness struct { ServerHost string CertFile string // contains filtered or unexported fields }
func NewServerHarness ¶
func NewServerHarness(serverHost string) *ServerHarness
NewServerHarness creates a new ServerHarness instance.
func (*ServerHarness) Start ¶
func (s *ServerHarness) Start() error
Start starts the mock Loop/Pool server.