make+itest: make itest Windows compatible

This commit is contained in:
Oliver Gugger committed 2020-08-05 08:53:04 +02:00
1 parent 2f1f8561ae
commit 6115a7b12b
3 files changed
+34 -6

No files matched your search

+7
View File
@@ -132,6 +132,11 @@ build-itest:
$(GOBUILD) -tags="$(ITEST_TAGS)" -o lnd-itest $(ITEST_LDFLAGS) $(PKG)/cmd/lnd
$(GOBUILD) -tags="$(ITEST_TAGS)" -o lncli-itest $(ITEST_LDFLAGS) $(PKG)/cmd/lncli
build-itest-windows:
@$(call print, "Building itest lnd and lncli.")
$(GOBUILD) -tags="$(ITEST_TAGS)" -o lnd-itest.exe $(ITEST_LDFLAGS) $(PKG)/cmd/lnd
$(GOBUILD) -tags="$(ITEST_TAGS)" -o lncli-itest.exe $(ITEST_LDFLAGS) $(PKG)/cmd/lncli
install:
@$(call print, "Installing lnd and lncli.")
$(GOINSTALL) -tags="${tags}" $(LDFLAGS) $(PKG)/cmd/lnd
@@ -158,6 +163,8 @@ itest-only:
itest: btcd build-itest itest-only
itest-windows: btcd build-itest-windows itest-only
unit: btcd
@$(call print, "Running unit tests.")
$(UNIT)
+1
View File
@@ -81,6 +81,7 @@ func NewBackend(miner string, netParams *chaincfg.Params) (
"--debuglevel=debug",
"--logdir=" + logDir,
"--connect=" + miner,
"--nowinservice",
}
chainBackend, err := rpctest.New(netParams, nil, args)
if err != nil {
+26 -6
View File
@@ -15,6 +15,7 @@ import (
"os"
"path/filepath"
"reflect"
"runtime"
"strings"
"sync"
"sync/atomic"
@@ -2462,9 +2463,14 @@ func testOpenChannelAfterReorg(net *lntest.NetworkHarness, t *harnessTest) {
)
// Set up a new miner that we can use to cause a reorg.
args := []string{"--rejectnonstd", "--txindex"}
tempMiner, err := rpctest.New(harnessNetParams,
&rpcclient.NotificationHandlers{}, args)
args := []string{
"--rejectnonstd",
"--txindex",
"--nowinservice",
}
tempMiner, err := rpctest.New(
harnessNetParams, &rpcclient.NotificationHandlers{}, args,
)
if err != nil {
t.Fatalf("unable to create mining node: %v", err)
}
@@ -15284,6 +15290,7 @@ func TestLightningNetworkDaemon(t *testing.T) {
"--debuglevel=debug",
"--logdir=" + minerLogDir,
"--trickleinterval=100ms",
"--nowinservice",
}
handlers := &rpcclient.NotificationHandlers{
OnTxAccepted: func(hash *chainhash.Hash, amt btcutil.Amount) {
@@ -15329,11 +15336,24 @@ func TestLightningNetworkDaemon(t *testing.T) {
ht.Fatalf("unable to request transaction notifications: %v", err)
}
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.
lndHarness, err = lntest.NewNetworkHarness(
miner, chainBackend, itestLndBinary,
)
lndHarness, err = lntest.NewNetworkHarness(miner, chainBackend, binary)
if err != nil {
ht.Fatalf("unable to create lightning network harness: %v", err)
}