diff --git a/lntest/harness.go b/lntest/harness.go index 4887ba2b..1d69b3b1 100644 --- a/lntest/harness.go +++ b/lntest/harness.go @@ -35,6 +35,10 @@ const DefaultCSV = 4 type NetworkHarness struct { netParams *chaincfg.Params + // lndBinary is the full path to the lnd binary that was specifically + // compiled with all required itest flags. + lndBinary string + // Miner is a reference to a running full node that can be used to create // new blocks on the network. Miner *rpctest.Harness @@ -68,7 +72,9 @@ type NetworkHarness struct { // TODO(roasbeef): add option to use golang's build library to a binary of the // current repo. This will save developers from having to manually `go install` // within the repo each time before changes -func NewNetworkHarness(r *rpctest.Harness, b BackendConfig) (*NetworkHarness, error) { +func NewNetworkHarness(r *rpctest.Harness, b BackendConfig, lndBinary string) ( + *NetworkHarness, error) { + n := NetworkHarness{ activeNodes: make(map[int]*HarnessNode), nodesByPub: make(map[string]*HarnessNode), @@ -79,6 +85,7 @@ func NewNetworkHarness(r *rpctest.Harness, b BackendConfig) (*NetworkHarness, er Miner: r, BackendCfg: b, quit: make(chan struct{}), + lndBinary: lndBinary, } go n.networkWatcher() return &n, nil @@ -361,7 +368,7 @@ func (n *NetworkHarness) newNode(name string, extraArgs []string, n.activeNodes[node.NodeID] = node n.mtx.Unlock() - if err := node.start(n.lndErrorChan); err != nil { + if err := node.start(n.lndBinary, n.lndErrorChan); err != nil { return nil, err } @@ -612,7 +619,7 @@ func (n *NetworkHarness) RestartNode(node *HarnessNode, callback func() error, } } - if err := node.start(n.lndErrorChan); err != nil { + if err := node.start(n.lndBinary, n.lndErrorChan); err != nil { return err } @@ -643,7 +650,7 @@ func (n *NetworkHarness) SuspendNode(node *HarnessNode) (func() error, error) { } restart := func() error { - return node.start(n.lndErrorChan) + return node.start(n.lndBinary, n.lndErrorChan) } return restart, nil diff --git a/lntest/itest/lnd_test.go b/lntest/itest/lnd_test.go index 8cd889b4..503f143c 100644 --- a/lntest/itest/lnd_test.go +++ b/lntest/itest/lnd_test.go @@ -56,6 +56,7 @@ const ( minerMempoolTimeout = lntest.MinerMempoolTimeout channelOpenTimeout = lntest.ChannelOpenTimeout channelCloseTimeout = lntest.ChannelCloseTimeout + itestLndBinary = "../../lnd-itest" ) // harnessTest wraps a regular testing.T providing enhanced error detection @@ -15237,7 +15238,9 @@ func TestLightningNetworkDaemon(t *testing.T) { // Now we can set up our test harness (LND instance), with the chain // backend we just created. - lndHarness, err = lntest.NewNetworkHarness(miner, chainBackend) + lndHarness, err = lntest.NewNetworkHarness( + miner, chainBackend, itestLndBinary, + ) if err != nil { ht.Fatalf("unable to create lightning network harness: %v", err) } diff --git a/lntest/node.go b/lntest/node.go index 6e65d0ba..adb1b405 100644 --- a/lntest/node.go +++ b/lntest/node.go @@ -369,11 +369,11 @@ func (hn *HarnessNode) InvoiceMacPath() string { // // This may not clean up properly if an error is returned, so the caller should // call shutdown() regardless of the return value. -func (hn *HarnessNode) start(lndError chan<- error) error { +func (hn *HarnessNode) start(lndBinary string, lndError chan<- error) error { hn.quit = make(chan struct{}) args := hn.Cfg.genArgs() - hn.cmd = exec.Command("../../lnd-itest", args...) + hn.cmd = exec.Command(lndBinary, args...) // Redirect stderr output to buffer var errb bytes.Buffer