itest: add flags for lnd executable
This commit is contained in:
parent
f358a4474d
commit
ca7564e4b4
@ -14,7 +14,6 @@ import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"runtime"
|
||||
"strings"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
@ -14213,23 +14212,9 @@ func TestLightningNetworkDaemon(t *testing.T) {
|
||||
t, chainBackend.ConnectMiner(), "failed to connect to miner",
|
||||
)
|
||||
|
||||
binary := itestLndBinary
|
||||
if runtime.GOOS == "windows" {
|
||||
// Windows (even in a bash like environment like git bash as on
|
||||
// Travis) doesn't seem to like relative paths to exe files...
|
||||
currentDir, err := os.Getwd()
|
||||
if err != nil {
|
||||
ht.Fatalf("unable to get working directory: %v", err)
|
||||
}
|
||||
targetPath := filepath.Join(currentDir, "../../lnd-itest.exe")
|
||||
binary, err = filepath.Abs(targetPath)
|
||||
if err != nil {
|
||||
ht.Fatalf("unable to get absolute path: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// Now we can set up our test harness (LND instance), with the chain
|
||||
// backend we just created.
|
||||
binary := ht.getLndBinary()
|
||||
lndHarness, err = lntest.NewNetworkHarness(miner, chainBackend, binary)
|
||||
if err != nil {
|
||||
ht.Fatalf("unable to create lightning network harness: %v", err)
|
||||
|
@ -3,8 +3,12 @@ package itest
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"flag"
|
||||
"fmt"
|
||||
"math"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@ -20,6 +24,11 @@ import (
|
||||
|
||||
var (
|
||||
harnessNetParams = &chaincfg.RegressionNetParams
|
||||
|
||||
// lndExecutable is the full path to the lnd binary.
|
||||
lndExecutable = flag.String(
|
||||
"lndexec", itestLndBinary, "full path to lnd binary",
|
||||
)
|
||||
)
|
||||
|
||||
const (
|
||||
@ -111,6 +120,31 @@ func (h *harnessTest) Log(args ...interface{}) {
|
||||
h.t.Log(args...)
|
||||
}
|
||||
|
||||
func (h *harnessTest) getLndBinary() string {
|
||||
binary := itestLndBinary
|
||||
lndExec := ""
|
||||
if lndExecutable != nil && *lndExecutable != "" {
|
||||
lndExec = *lndExecutable
|
||||
}
|
||||
if lndExec == "" && runtime.GOOS == "windows" {
|
||||
// Windows (even in a bash like environment like git bash as on
|
||||
// Travis) doesn't seem to like relative paths to exe files...
|
||||
currentDir, err := os.Getwd()
|
||||
if err != nil {
|
||||
h.Fatalf("unable to get working directory: %v", err)
|
||||
}
|
||||
targetPath := filepath.Join(currentDir, "../../lnd-itest.exe")
|
||||
binary, err = filepath.Abs(targetPath)
|
||||
if err != nil {
|
||||
h.Fatalf("unable to get absolute path: %v", err)
|
||||
}
|
||||
} else if lndExec != "" {
|
||||
binary = lndExec
|
||||
}
|
||||
|
||||
return binary
|
||||
}
|
||||
|
||||
type testCase struct {
|
||||
name string
|
||||
test func(net *lntest.NetworkHarness, t *harnessTest)
|
||||
|
Loading…
Reference in New Issue
Block a user