From 50e7cbe3be92d313fd16587ebaf6736bd1769bf9 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Mon, 26 Sep 2016 10:30:24 -0700 Subject: [PATCH] test: add ability to add additional nodes to the test network --- networktest.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/networktest.go b/networktest.go index 206e495ee..f904accea 100644 --- a/networktest.go +++ b/networktest.go @@ -275,6 +275,8 @@ type networkHarness struct { seenTxns chan wire.ShaHash watchRequests chan *watchRequest + + sync.Mutex } // newNetworkHarness creates a new network test harness. @@ -458,6 +460,26 @@ func (n *networkHarness) TearDownAll() error { return nil } +// NewNode fully initializes a returns a new lightningNode binded to the +// current instance of the network harness. The created node is running, but +// not yet connected to other nodes within the network. +func (n *networkHarness) NewNode(extraArgs []string) (*lightningNode, error) { + n.Lock() + defer n.Unlock() + + node, err := newLightningNode(&n.rpcConfig, extraArgs) + if err != nil { + return nil, err + } + + if err := node.start(); err != nil { + return nil, err + } + + n.activeNodes[node.nodeId] = node + + return node, nil +} // watchRequest encapsulates a request to the harness' network watcher to // dispatch a notification once a transaction with the target txid is seen // within the test network.