make+itest: make itest Windows compatible

This commit is contained in:
Oliver Gugger 2020-07-31 10:32:30 +02:00
parent 2f1f8561ae
commit 6115a7b12b
No known key found for this signature in database
GPG Key ID: 8E4256593F177720
3 changed files with 34 additions and 6 deletions

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)

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 {

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)
}