Skip to content

Commit e39d009

Browse files
authored
Merge pull request #5260 from guggero/windows-itest
Travis: fix Windows itest
2 parents a2138f0 + e4873ac commit e39d009

File tree

5 files changed

+64
-26
lines changed

5 files changed

+64
-26
lines changed

.travis.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,9 @@ jobs:
7777

7878
- name: Btcd Integration Windows
7979
script:
80-
- make itest-parallel windows=1
80+
# The windows VM seems to be slower than the other Travis VMs. We only
81+
# run 2 test suites in parallel instead of the default 4.
82+
- make itest-parallel windows=1 ITEST_PARALLELISM=2
8183
os: windows
8284
before_install:
8385
- choco upgrade --no-progress -y make netcat curl findutils

lntest/harness.go

+14-5
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ import (
3232
// DefaultCSV is the CSV delay (remotedelay) we will start our test nodes with.
3333
const DefaultCSV = 4
3434

35+
// NodeOption is a function for updating a node's configuration.
36+
type NodeOption func(*NodeConfig)
37+
3538
// NetworkHarness is an integration testing harness for the lightning network.
3639
// The harness by default is created with two active nodes on the network:
3740
// Alice and Bob.
@@ -427,10 +430,11 @@ func (n *NetworkHarness) newNodeWithSeed(name string, extraArgs []string,
427430
// be used for regular rpc operations.
428431
func (n *NetworkHarness) RestoreNodeWithSeed(name string, extraArgs []string,
429432
password []byte, mnemonic []string, recoveryWindow int32,
430-
chanBackups *lnrpc.ChanBackupSnapshot) (*HarnessNode, error) {
433+
chanBackups *lnrpc.ChanBackupSnapshot,
434+
opts ...NodeOption) (*HarnessNode, error) {
431435

432436
node, err := n.newNode(
433-
name, extraArgs, true, password, n.embeddedEtcd, true,
437+
name, extraArgs, true, password, n.embeddedEtcd, true, opts...,
434438
)
435439
if err != nil {
436440
return nil, err
@@ -461,10 +465,10 @@ func (n *NetworkHarness) RestoreNodeWithSeed(name string, extraArgs []string,
461465
// can be used immediately. Otherwise, the node will require an additional
462466
// initialization phase where the wallet is either created or restored.
463467
func (n *NetworkHarness) newNode(name string, extraArgs []string, hasSeed bool,
464-
password []byte, embeddedEtcd, wait bool) (
468+
password []byte, embeddedEtcd, wait bool, opts ...NodeOption) (
465469
*HarnessNode, error) {
466470

467-
node, err := newNode(NodeConfig{
471+
cfg := &NodeConfig{
468472
Name: name,
469473
LogFilenamePrefix: n.currentTestCase,
470474
HasSeed: hasSeed,
@@ -474,7 +478,12 @@ func (n *NetworkHarness) newNode(name string, extraArgs []string, hasSeed bool,
474478
ExtraArgs: extraArgs,
475479
FeeURL: n.feeService.url,
476480
Etcd: embeddedEtcd,
477-
})
481+
}
482+
for _, opt := range opts {
483+
opt(cfg)
484+
}
485+
486+
node, err := newNode(*cfg)
478487
if err != nil {
479488
return nil, err
480489
}

lntest/itest/lnd_channel_backup_test.go

+29-12
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func testChannelBackupRestore(net *lntest.NetworkHarness, t *harnessTest) {
6363
// the node from seed, then manually recover
6464
// the channel backup.
6565
return chanRestoreViaRPC(
66-
net, password, mnemonic, multi,
66+
net, password, mnemonic, multi, oldNode,
6767
)
6868
},
6969
},
@@ -89,7 +89,7 @@ func testChannelBackupRestore(net *lntest.NetworkHarness, t *harnessTest) {
8989
// create a new nodeRestorer that will restore
9090
// using the on-disk channels.backup.
9191
return chanRestoreViaRPC(
92-
net, password, mnemonic, multi,
92+
net, password, mnemonic, multi, oldNode,
9393
)
9494
},
9595
},
@@ -124,6 +124,7 @@ func testChannelBackupRestore(net *lntest.NetworkHarness, t *harnessTest) {
124124
return net.RestoreNodeWithSeed(
125125
"dave", nil, password,
126126
mnemonic, 1000, backupSnapshot,
127+
copyPorts(oldNode),
127128
)
128129
}, nil
129130
},
@@ -160,6 +161,7 @@ func testChannelBackupRestore(net *lntest.NetworkHarness, t *harnessTest) {
160161
newNode, err := net.RestoreNodeWithSeed(
161162
"dave", nil, password,
162163
mnemonic, 1000, nil,
164+
copyPorts(oldNode),
163165
)
164166
if err != nil {
165167
return nil, err
@@ -206,7 +208,7 @@ func testChannelBackupRestore(net *lntest.NetworkHarness, t *harnessTest) {
206208
return func() (*lntest.HarnessNode, error) {
207209
newNode, err := net.RestoreNodeWithSeed(
208210
"dave", nil, password, mnemonic,
209-
1000, nil,
211+
1000, nil, copyPorts(oldNode),
210212
)
211213
if err != nil {
212214
return nil, fmt.Errorf("unable to "+
@@ -276,7 +278,7 @@ func testChannelBackupRestore(net *lntest.NetworkHarness, t *harnessTest) {
276278
// the node from seed, then manually recover
277279
// the channel backup.
278280
return chanRestoreViaRPC(
279-
net, password, mnemonic, multi,
281+
net, password, mnemonic, multi, oldNode,
280282
)
281283
},
282284
},
@@ -326,7 +328,7 @@ func testChannelBackupRestore(net *lntest.NetworkHarness, t *harnessTest) {
326328
// the channel backup.
327329
multi := chanBackup.MultiChanBackup.MultiChanBackup
328330
return chanRestoreViaRPC(
329-
net, password, mnemonic, multi,
331+
net, password, mnemonic, multi, oldNode,
330332
)
331333
},
332334
},
@@ -353,7 +355,7 @@ func testChannelBackupRestore(net *lntest.NetworkHarness, t *harnessTest) {
353355
// create a new nodeRestorer that will restore
354356
// using the on-disk channels.backup.
355357
return chanRestoreViaRPC(
356-
net, password, mnemonic, multi,
358+
net, password, mnemonic, multi, oldNode,
357359
)
358360
},
359361
},
@@ -384,7 +386,7 @@ func testChannelBackupRestore(net *lntest.NetworkHarness, t *harnessTest) {
384386
// the node from seed, then manually recover the
385387
// channel backup.
386388
return chanRestoreViaRPC(
387-
net, password, mnemonic, multi,
389+
net, password, mnemonic, multi, oldNode,
388390
)
389391
},
390392
},
@@ -825,9 +827,12 @@ func testChanRestoreScenario(t *harnessTest, net *lntest.NetworkHarness,
825827

826828
ctxb := context.Background()
827829

828-
var nodeArgs []string
830+
nodeArgs := []string{
831+
"--minbackoff=50ms",
832+
"--maxbackoff=1s",
833+
}
829834
if testCase.anchorCommit {
830-
nodeArgs = commitTypeAnchors.Args()
835+
nodeArgs = append(nodeArgs, commitTypeAnchors.Args()...)
831836
}
832837

833838
// First, we'll create a brand new node we'll use within the test. If
@@ -1225,9 +1230,9 @@ func createLegacyRevocationChannel(net *lntest.NetworkHarness, t *harnessTest,
12251230
// chanRestoreViaRPC is a helper test method that returns a nodeRestorer
12261231
// instance which will restore the target node from a password+seed, then
12271232
// trigger a SCB restore using the RPC interface.
1228-
func chanRestoreViaRPC(net *lntest.NetworkHarness,
1229-
password []byte, mnemonic []string,
1230-
multi []byte) (nodeRestorer, error) {
1233+
func chanRestoreViaRPC(net *lntest.NetworkHarness, password []byte,
1234+
mnemonic []string, multi []byte,
1235+
oldNode *lntest.HarnessNode) (nodeRestorer, error) {
12311236

12321237
backup := &lnrpc.RestoreChanBackupRequest_MultiChanBackup{
12331238
MultiChanBackup: multi,
@@ -1238,6 +1243,7 @@ func chanRestoreViaRPC(net *lntest.NetworkHarness,
12381243
return func() (*lntest.HarnessNode, error) {
12391244
newNode, err := net.RestoreNodeWithSeed(
12401245
"dave", nil, password, mnemonic, 1000, nil,
1246+
copyPorts(oldNode),
12411247
)
12421248
if err != nil {
12431249
return nil, fmt.Errorf("unable to "+
@@ -1257,3 +1263,14 @@ func chanRestoreViaRPC(net *lntest.NetworkHarness,
12571263
return newNode, nil
12581264
}, nil
12591265
}
1266+
1267+
// copyPorts returns a node option function that copies the ports of an existing
1268+
// node over to the newly created one.
1269+
func copyPorts(oldNode *lntest.HarnessNode) lntest.NodeOption {
1270+
return func(cfg *lntest.NodeConfig) {
1271+
cfg.P2PPort = oldNode.Cfg.P2PPort
1272+
cfg.RPCPort = oldNode.Cfg.RPCPort
1273+
cfg.RESTPort = oldNode.Cfg.RESTPort
1274+
cfg.ProfilePort = oldNode.Cfg.ProfilePort
1275+
}
1276+
}

lntest/itest/log_error_whitelist.txt

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<time> [ERR] BRAR: Unable to broadcast justice tx: Transaction rejected: output already spent
2+
<time> [ERR] BRAR: Unable to check for spentness of outpoint=<chan_point>: TxNotifier is exiting
23
<time> [ERR] BRAR: Unable to register for conf for txid(<hex>): TxNotifier is exiting
4+
<time> [ERR] BRAR: Unable to register for block notifications: chainntnfs: system interrupt while attempting to register for block epoch notification.
35
<time> [ERR] BTCN: Broadcast attempt failed: rejected by <ip>: replacement transaction <hex> has an insufficient absolute fee: needs <amt>, has <amt>
46
<time> [ERR] BTCN: Broadcast attempt failed: rejected by <ip>: replacement transaction <hex> has an insufficient fee rate: needs more than <amt>, has <amt>
57
<time> [ERR] BTCN: Broadcast attempt failed: rejected by <ip>: transaction already exists
@@ -78,6 +80,7 @@
7880
<time> [ERR] FNDG: Unable to advance state(<chan_point>): error sending channel announcement: channel announcement failed: unable add proof to the channel chanID=<hex>: edge marked as zombie
7981
<time> [ERR] FNDG: Unable to advance state(<chan_point>): error sending channel announcement: channel announcement failed: unable add proof to the channel chanID=<hex>: edge not found
8082
<time> [ERR] FNDG: Unable to advance state(<chan_point>): error sending channel announcement: unable to register for confirmation of ChannelPoint(<chan_point>): chain notifier shutting down
83+
<time> [ERR] FNDG: Unable to advance state(<chan_point>): error sending channel announcement: unable to register for confirmation of ChannelPoint(<chan_point>): TxNotifier is exiting
8184
<time> [ERR] FNDG: Unable to advance state(<chan_point>): failed adding to router graph: error sending channel announcement: gossiper is shutting down
8285
<time> [ERR] FNDG: Unable to advance state(<chan_point>): failed adding to router graph: error sending channel announcement: router shutting down
8386
<time> [ERR] FNDG: Unable to advance state(<chan_point>): failed adding to router graph: funding manager shutting down
@@ -242,6 +245,7 @@
242245
<time> [ERR] RPCS: [/lnrpc.Lightning/GetInfo]: expected 1 macaroon, got 0
243246
<time> [ERR] RPCS: [/lnrpc.Lightning/GetInfo]: permission denied
244247
<time> [ERR] RPCS: [/lnrpc.Lightning/GetInfo]: the RPC server is in the process of starting up, but not yet ready to accept calls
248+
<time> [ERR] RPCS: [/lnrpc.Lightning/GetInfo]: wallet locked, unlock it to enable full RPC access
245249
<time> [ERR] RPCS: [/lnrpc.Lightning/ListMacaroonIDs]: cannot retrieve macaroon: cannot get macaroon: root key with id 1 doesn't exist
246250
<time> [ERR] RPCS: [/lnrpc.Lightning/NewAddress]: permission denied
247251
<time> [ERR] RPCS: unable to open channel to NodeKey(<hex>): received funding error from <hex>: chan_id=<hex>, err=channel too large

lntest/node.go

+14-8
Original file line numberDiff line numberDiff line change
@@ -155,13 +155,19 @@ func GenerateBtcdListenerAddresses() (string, string) {
155155
// generateListeningPorts returns four ints representing ports to listen on
156156
// designated for the current lightning network test. This returns the next
157157
// available ports for the p2p, rpc, rest and profiling services.
158-
func generateListeningPorts() (int, int, int, int) {
159-
p2p := NextAvailablePort()
160-
rpc := NextAvailablePort()
161-
rest := NextAvailablePort()
162-
profile := NextAvailablePort()
163-
164-
return p2p, rpc, rest, profile
158+
func generateListeningPorts(cfg *NodeConfig) {
159+
if cfg.P2PPort == 0 {
160+
cfg.P2PPort = NextAvailablePort()
161+
}
162+
if cfg.RPCPort == 0 {
163+
cfg.RPCPort = NextAvailablePort()
164+
}
165+
if cfg.RESTPort == 0 {
166+
cfg.RESTPort = NextAvailablePort()
167+
}
168+
if cfg.ProfilePort == 0 {
169+
cfg.ProfilePort = NextAvailablePort()
170+
}
165171
}
166172

167173
// BackendConfig is an interface that abstracts away the specific chain backend
@@ -411,7 +417,7 @@ func newNode(cfg NodeConfig) (*HarnessNode, error) {
411417
cfg.ReadMacPath = filepath.Join(networkDir, "readonly.macaroon")
412418
cfg.InvoiceMacPath = filepath.Join(networkDir, "invoice.macaroon")
413419

414-
cfg.P2PPort, cfg.RPCPort, cfg.RESTPort, cfg.ProfilePort = generateListeningPorts()
420+
generateListeningPorts(&cfg)
415421

416422
// Run all tests with accept keysend. The keysend code is very isolated
417423
// and it is highly unlikely that it would affect regular itests when

0 commit comments

Comments
 (0)