diff --git a/.travis.yml b/.travis.yml index 3d8bd27e..97b895da 100644 --- a/.travis.yml +++ b/.travis.yml @@ -77,7 +77,9 @@ jobs: - name: Btcd Integration Windows script: - - make itest-parallel windows=1 + # The windows VM seems to be slower than the other Travis VMs. We only + # run 2 test suites in parallel instead of the default 4. + - make itest-parallel windows=1 ITEST_PARALLELISM=2 os: windows before_install: - choco upgrade --no-progress -y make netcat curl findutils diff --git a/lntest/harness.go b/lntest/harness.go index ee3865e8..89dd13d6 100644 --- a/lntest/harness.go +++ b/lntest/harness.go @@ -32,6 +32,9 @@ import ( // DefaultCSV is the CSV delay (remotedelay) we will start our test nodes with. const DefaultCSV = 4 +// NodeOption is a function for updating a node's configuration. +type NodeOption func(*NodeConfig) + // NetworkHarness is an integration testing harness for the lightning network. // The harness by default is created with two active nodes on the network: // Alice and Bob. @@ -427,10 +430,11 @@ func (n *NetworkHarness) newNodeWithSeed(name string, extraArgs []string, // be used for regular rpc operations. func (n *NetworkHarness) RestoreNodeWithSeed(name string, extraArgs []string, password []byte, mnemonic []string, recoveryWindow int32, - chanBackups *lnrpc.ChanBackupSnapshot) (*HarnessNode, error) { + chanBackups *lnrpc.ChanBackupSnapshot, + opts ...NodeOption) (*HarnessNode, error) { node, err := n.newNode( - name, extraArgs, true, password, n.embeddedEtcd, true, + name, extraArgs, true, password, n.embeddedEtcd, true, opts..., ) if err != nil { return nil, err @@ -461,10 +465,10 @@ func (n *NetworkHarness) RestoreNodeWithSeed(name string, extraArgs []string, // can be used immediately. Otherwise, the node will require an additional // initialization phase where the wallet is either created or restored. func (n *NetworkHarness) newNode(name string, extraArgs []string, hasSeed bool, - password []byte, embeddedEtcd, wait bool) ( + password []byte, embeddedEtcd, wait bool, opts ...NodeOption) ( *HarnessNode, error) { - node, err := newNode(NodeConfig{ + cfg := &NodeConfig{ Name: name, LogFilenamePrefix: n.currentTestCase, HasSeed: hasSeed, @@ -474,7 +478,12 @@ func (n *NetworkHarness) newNode(name string, extraArgs []string, hasSeed bool, ExtraArgs: extraArgs, FeeURL: n.feeService.url, Etcd: embeddedEtcd, - }) + } + for _, opt := range opts { + opt(cfg) + } + + node, err := newNode(*cfg) if err != nil { return nil, err } diff --git a/lntest/itest/lnd_channel_backup_test.go b/lntest/itest/lnd_channel_backup_test.go index 437b924b..1b299e29 100644 --- a/lntest/itest/lnd_channel_backup_test.go +++ b/lntest/itest/lnd_channel_backup_test.go @@ -63,7 +63,7 @@ func testChannelBackupRestore(net *lntest.NetworkHarness, t *harnessTest) { // the node from seed, then manually recover // the channel backup. return chanRestoreViaRPC( - net, password, mnemonic, multi, + net, password, mnemonic, multi, oldNode, ) }, }, @@ -89,7 +89,7 @@ func testChannelBackupRestore(net *lntest.NetworkHarness, t *harnessTest) { // create a new nodeRestorer that will restore // using the on-disk channels.backup. return chanRestoreViaRPC( - net, password, mnemonic, multi, + net, password, mnemonic, multi, oldNode, ) }, }, @@ -124,6 +124,7 @@ func testChannelBackupRestore(net *lntest.NetworkHarness, t *harnessTest) { return net.RestoreNodeWithSeed( "dave", nil, password, mnemonic, 1000, backupSnapshot, + copyPorts(oldNode), ) }, nil }, @@ -160,6 +161,7 @@ func testChannelBackupRestore(net *lntest.NetworkHarness, t *harnessTest) { newNode, err := net.RestoreNodeWithSeed( "dave", nil, password, mnemonic, 1000, nil, + copyPorts(oldNode), ) if err != nil { return nil, err @@ -206,7 +208,7 @@ func testChannelBackupRestore(net *lntest.NetworkHarness, t *harnessTest) { return func() (*lntest.HarnessNode, error) { newNode, err := net.RestoreNodeWithSeed( "dave", nil, password, mnemonic, - 1000, nil, + 1000, nil, copyPorts(oldNode), ) if err != nil { return nil, fmt.Errorf("unable to "+ @@ -276,7 +278,7 @@ func testChannelBackupRestore(net *lntest.NetworkHarness, t *harnessTest) { // the node from seed, then manually recover // the channel backup. return chanRestoreViaRPC( - net, password, mnemonic, multi, + net, password, mnemonic, multi, oldNode, ) }, }, @@ -326,7 +328,7 @@ func testChannelBackupRestore(net *lntest.NetworkHarness, t *harnessTest) { // the channel backup. multi := chanBackup.MultiChanBackup.MultiChanBackup return chanRestoreViaRPC( - net, password, mnemonic, multi, + net, password, mnemonic, multi, oldNode, ) }, }, @@ -353,7 +355,7 @@ func testChannelBackupRestore(net *lntest.NetworkHarness, t *harnessTest) { // create a new nodeRestorer that will restore // using the on-disk channels.backup. return chanRestoreViaRPC( - net, password, mnemonic, multi, + net, password, mnemonic, multi, oldNode, ) }, }, @@ -384,7 +386,7 @@ func testChannelBackupRestore(net *lntest.NetworkHarness, t *harnessTest) { // the node from seed, then manually recover the // channel backup. return chanRestoreViaRPC( - net, password, mnemonic, multi, + net, password, mnemonic, multi, oldNode, ) }, }, @@ -825,9 +827,12 @@ func testChanRestoreScenario(t *harnessTest, net *lntest.NetworkHarness, ctxb := context.Background() - var nodeArgs []string + nodeArgs := []string{ + "--minbackoff=50ms", + "--maxbackoff=1s", + } if testCase.anchorCommit { - nodeArgs = commitTypeAnchors.Args() + nodeArgs = append(nodeArgs, commitTypeAnchors.Args()...) } // 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, // chanRestoreViaRPC is a helper test method that returns a nodeRestorer // instance which will restore the target node from a password+seed, then // trigger a SCB restore using the RPC interface. -func chanRestoreViaRPC(net *lntest.NetworkHarness, - password []byte, mnemonic []string, - multi []byte) (nodeRestorer, error) { +func chanRestoreViaRPC(net *lntest.NetworkHarness, password []byte, + mnemonic []string, multi []byte, + oldNode *lntest.HarnessNode) (nodeRestorer, error) { backup := &lnrpc.RestoreChanBackupRequest_MultiChanBackup{ MultiChanBackup: multi, @@ -1238,6 +1243,7 @@ func chanRestoreViaRPC(net *lntest.NetworkHarness, return func() (*lntest.HarnessNode, error) { newNode, err := net.RestoreNodeWithSeed( "dave", nil, password, mnemonic, 1000, nil, + copyPorts(oldNode), ) if err != nil { return nil, fmt.Errorf("unable to "+ @@ -1257,3 +1263,14 @@ func chanRestoreViaRPC(net *lntest.NetworkHarness, return newNode, nil }, nil } + +// copyPorts returns a node option function that copies the ports of an existing +// node over to the newly created one. +func copyPorts(oldNode *lntest.HarnessNode) lntest.NodeOption { + return func(cfg *lntest.NodeConfig) { + cfg.P2PPort = oldNode.Cfg.P2PPort + cfg.RPCPort = oldNode.Cfg.RPCPort + cfg.RESTPort = oldNode.Cfg.RESTPort + cfg.ProfilePort = oldNode.Cfg.ProfilePort + } +} diff --git a/lntest/itest/log_error_whitelist.txt b/lntest/itest/log_error_whitelist.txt index 31610f3d..82fe9f3b 100644 --- a/lntest/itest/log_error_whitelist.txt +++ b/lntest/itest/log_error_whitelist.txt @@ -1,5 +1,7 @@