lntest: Add ShutdownNode method to harness.

This is preferable to calling Shutdown on the node directly so that
the harness manages the entire lifecycle of an lnd process.
This commit is contained in:
Jim Posen
2017-11-03 14:40:57 -07:00
committed by Olaoluwa Osuntokun
parent 77d5f21b54
commit 19ed1fb8db
3 changed files with 25 additions and 14 deletions

View File

@@ -224,7 +224,7 @@ out:
// TearDownAll tears down all active nodes within the test lightning network.
func (n *NetworkHarness) TearDownAll() error {
for _, node := range n.activeNodes {
if err := node.Shutdown(); err != nil {
if err := n.ShutdownNode(node); err != nil {
return err
}
}
@@ -341,6 +341,17 @@ func (n *NetworkHarness) RestartNode(node *HarnessNode, callback func() error) e
return node.restart(n.lndErrorChan, callback)
}
// ShutdownNode stops an active lnd process and returns when the process has
// exited and any temporary directories have been cleaned up.
func (n *NetworkHarness) ShutdownNode(node *HarnessNode) error {
if err := node.shutdown(); err != nil {
return err
}
delete(n.activeNodes, node.NodeID)
return nil
}
// TODO(roasbeef): add a WithChannel higher-order function?
// * python-like context manager w.r.t using a channel within a test
// * possibly adds more funds to the target wallet if the funds are not

View File

@@ -415,9 +415,9 @@ func (hn *HarnessNode) restart(errChan chan error, callback func() error) error
return hn.start(errChan)
}
// Shutdown stops the active lnd process and clean up any temporary directories
// shutdown stops the active lnd process and cleans up any temporary directories
// created along the way.
func (hn *HarnessNode) Shutdown() error {
func (hn *HarnessNode) shutdown() error {
if err := hn.stop(); err != nil {
return err
}