itest: add flags for lnd executable
This commit is contained in:
parent
f358a4474d
commit
ca7564e4b4
@ -14,7 +14,6 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"reflect"
|
"reflect"
|
||||||
"runtime"
|
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
@ -14213,23 +14212,9 @@ func TestLightningNetworkDaemon(t *testing.T) {
|
|||||||
t, chainBackend.ConnectMiner(), "failed to connect to miner",
|
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
|
// Now we can set up our test harness (LND instance), with the chain
|
||||||
// backend we just created.
|
// backend we just created.
|
||||||
|
binary := ht.getLndBinary()
|
||||||
lndHarness, err = lntest.NewNetworkHarness(miner, chainBackend, binary)
|
lndHarness, err = lntest.NewNetworkHarness(miner, chainBackend, binary)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ht.Fatalf("unable to create lightning network harness: %v", err)
|
ht.Fatalf("unable to create lightning network harness: %v", err)
|
||||||
|
@ -3,8 +3,12 @@ package itest
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math"
|
"math"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
"runtime"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -20,6 +24,11 @@ import (
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
harnessNetParams = &chaincfg.RegressionNetParams
|
harnessNetParams = &chaincfg.RegressionNetParams
|
||||||
|
|
||||||
|
// lndExecutable is the full path to the lnd binary.
|
||||||
|
lndExecutable = flag.String(
|
||||||
|
"lndexec", itestLndBinary, "full path to lnd binary",
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -111,6 +120,31 @@ func (h *harnessTest) Log(args ...interface{}) {
|
|||||||
h.t.Log(args...)
|
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 {
|
type testCase struct {
|
||||||
name string
|
name string
|
||||||
test func(net *lntest.NetworkHarness, t *harnessTest)
|
test func(net *lntest.NetworkHarness, t *harnessTest)
|
||||||
|
Loading…
Reference in New Issue
Block a user