From 9b6055764a6c9f9a29d0cefa7be086bb22a3489e Mon Sep 17 00:00:00 2001 From: "Johan T. Halseth" Date: Mon, 29 Oct 2018 05:52:08 +0100 Subject: [PATCH 1/3] lntest: define and export various test constants --- lntest/harness.go | 22 ++++++++++++++++++++++ lntest/node.go | 2 +- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/lntest/harness.go b/lntest/harness.go index be57082d6..1de4cb8ba 100644 --- a/lntest/harness.go +++ b/lntest/harness.go @@ -22,6 +22,28 @@ import ( "github.com/lightningnetwork/lnd/lnwire" ) +const ( + // DefaultCSV is the CSV delay (remotedelay) we will start our test + // nodes with. + DefaultCSV = 4 + + // MinerMempoolTimeout is the max time we will wait for a transaction + // to propagate to the mining node's mempool. + MinerMempoolTimeout = time.Second * 30 + + // ChannelOpenTimeout is the max time we will wait before a channel to + // be considered opened. + ChannelOpenTimeout = time.Second * 30 + + // ChannelCloseTimeout is the max time we will wait before a channel is + // considered closed. + ChannelCloseTimeout = time.Second * 30 + + // DefaultTimeout is a timeout that will be used for various wait + // scenarios where no custom timeout value is defined. + DefaultTimeout = time.Second * 30 +) + // 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. diff --git a/lntest/node.go b/lntest/node.go index f73e2900b..944d62169 100644 --- a/lntest/node.go +++ b/lntest/node.go @@ -148,7 +148,7 @@ func (cfg nodeConfig) genArgs() []string { args = append(args, "--nobootstrap") args = append(args, "--debuglevel=debug") args = append(args, "--bitcoin.defaultchanconfs=1") - args = append(args, "--bitcoin.defaultremotedelay=4") + args = append(args, fmt.Sprintf("--bitcoin.defaultremotedelay=%v", DefaultCSV)) args = append(args, fmt.Sprintf("--btcd.rpchost=%v", cfg.RPCConfig.Host)) args = append(args, fmt.Sprintf("--btcd.rpcuser=%v", cfg.RPCConfig.User)) args = append(args, fmt.Sprintf("--btcd.rpcpass=%v", cfg.RPCConfig.Pass)) From 3bb9b398e5d4715e94d7f0727bc5dbe96facdc14 Mon Sep 17 00:00:00 2001 From: "Johan T. Halseth" Date: Mon, 5 Nov 2018 22:12:02 +0100 Subject: [PATCH 2/3] lnd_test: define global test timeouts In preparation for the added propagation delay by separating the miner and the chain backend, we increase several timeouts throughout the test, and extract them into constants that can easily be altered. --- lnd_test.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lnd_test.go b/lnd_test.go index 00506f8b1..3ff09185e 100644 --- a/lnd_test.go +++ b/lnd_test.go @@ -43,7 +43,12 @@ var ( ) const ( - testFeeBase = 1e+6 + testFeeBase = 1e+6 + defaultCSV = lntest.DefaultCSV + defaultTimeout = lntest.DefaultTimeout + minerMempoolTimeout = lntest.MinerMempoolTimeout + channelOpenTimeout = lntest.ChannelOpenTimeout + channelCloseTimeout = lntest.ChannelCloseTimeout ) // harnessTest wraps a regular testing.T providing enhanced error detection From 1208c66a89215e8c57914df9f03836715237e088 Mon Sep 17 00:00:00 2001 From: "Johan T. Halseth" Date: Mon, 29 Oct 2018 05:52:09 +0100 Subject: [PATCH 3/3] lnd_test: mine reorged out funding tx --- lnd_test.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lnd_test.go b/lnd_test.go index 3ff09185e..48e53803c 100644 --- a/lnd_test.go +++ b/lnd_test.go @@ -1561,7 +1561,16 @@ func testOpenChannelAfterReorg(net *lntest.NetworkHarness, t *harnessTest) { numEdges) } - ctxt, _ = context.WithTimeout(ctxb, timeout) + // Cleanup by mining the funding tx again, then closing the channel. + _, err = waitForTxInMempool(net.Miner.Node, minerMempoolTimeout) + if err != nil { + t.Fatalf("failed to find funding tx in mempool: %v", err) + } + + block = mineBlocks(t, net, 1)[0] + assertTxInBlock(t, block, fundingTxID) + + ctxt, _ = context.WithTimeout(ctxb, channelCloseTimeout) closeChannelAndAssert(ctxt, t, net, net.Alice, chanPoint, false) }