From 23f67ef009658d1fc963ba37f4735c0e0e9977a3 Mon Sep 17 00:00:00 2001 From: "Johan T. Halseth" Date: Fri, 27 Apr 2018 09:54:36 +0200 Subject: [PATCH] lnd_test: remove racy block generation This commit removes the mining of a block within the integration tests, that would lead to a flake during runs. The reason was that the sweeoing transaction was actually broadcast already at this point, and this block was mined with the assumption that it wasn't. However, test would pass more often than not because the UTXO nursery would be working on graduating new heights, whcih is a bit slow, so in most cases the block would be mined before it had broadcast the sweeping transaction. By removing this block we ensure that the sweeping transaction will be found for sure in the waitForTxInMempool call below. --- lnd_test.go | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/lnd_test.go b/lnd_test.go index 143f100f..d6d8f68a 100644 --- a/lnd_test.go +++ b/lnd_test.go @@ -6957,7 +6957,7 @@ func testMultHopRemoteForceCloseOnChainHtlcTimeout(net *lntest.NetworkHarness, t.Fatalf("unable to send alice htlc: %v", err) } - // Once the HTLC has cleared, all the nodes n our mini network should + // Once the HTLC has cleared, all the nodes in our mini network should // show that the HTLC has been locked in. var predErr error nodes := []*lntest.HarnessNode{net.Alice, net.Bob, carol} @@ -7004,7 +7004,8 @@ func testMultHopRemoteForceCloseOnChainHtlcTimeout(net *lntest.NetworkHarness, } // Next, we'll mine enough blocks for the HTLC to expire. At this - // point, Bob should hand off the output to his internal utxo nursery. + // point, Bob should hand off the output to his internal utxo nursery, + // which will broadcast a sweep transaction. if _, err := net.Miner.Node.Generate(finalCltvDelta - 1); err != nil { t.Fatalf("unable to generate blocks: %v", err) } @@ -7046,12 +7047,6 @@ func testMultHopRemoteForceCloseOnChainHtlcTimeout(net *lntest.NetworkHarness, t.Fatalf("bob didn't hand off time-locked HTLC: %v", predErr) } - // We'll now mine an additional block to push the HTLC to full - // expiration. - if _, err := net.Miner.Node.Generate(1); err != nil { - t.Fatalf("unable to generate block: %v", err) - } - // Bob's sweeping transaction should now be found in the mempool at // this point. _, err = waitForTxInMempool(net.Miner.Node, time.Second*20)