Skip to content

Commit f13e547

Browse files
committed
lnd_test: use global minerMempoolTimeout when waiting for miner to see TXs
1 parent ea32a13 commit f13e547

File tree

1 file changed

+39
-39
lines changed

1 file changed

+39
-39
lines changed

lnd_test.go

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -2496,7 +2496,7 @@ func testChannelForceClosure(net *lntest.NetworkHarness, t *harnessTest) {
24962496
// At this point, the sweeping transaction should now be broadcast. So
24972497
// we fetch the node's mempool to ensure it has been properly
24982498
// broadcast.
2499-
sweepingTXID, err := waitForTxInMempool(net.Miner.Node, 3*time.Second)
2499+
sweepingTXID, err := waitForTxInMempool(net.Miner.Node, minerMempoolTimeout)
25002500
if err != nil {
25012501
t.Fatalf("failed to get sweep tx from mempool: %v", err)
25022502
}
@@ -2667,7 +2667,7 @@ func testChannelForceClosure(net *lntest.NetworkHarness, t *harnessTest) {
26672667
// closing, we expect Alice to broadcast an htlc timeout txn for each
26682668
// one. Wait for them all to show up in the mempool.
26692669
htlcTxIDs, err := waitForNTxsInMempool(net.Miner.Node, numInvoices,
2670-
10*time.Second)
2670+
minerMempoolTimeout)
26712671
if err != nil {
26722672
t.Fatalf("unable to find htlc timeout txns in mempool: %v", err)
26732673
}
@@ -2780,7 +2780,7 @@ func testChannelForceClosure(net *lntest.NetworkHarness, t *harnessTest) {
27802780
}
27812781

27822782
// Wait for the single sweep txn to appear in the mempool.
2783-
htlcSweepTxID, err := waitForTxInMempool(net.Miner.Node, 15*time.Second)
2783+
htlcSweepTxID, err := waitForTxInMempool(net.Miner.Node, minerMempoolTimeout)
27842784
if err != nil {
27852785
t.Fatalf("failed to get sweep tx from mempool: %v", err)
27862786
}
@@ -5733,7 +5733,7 @@ func testFailingChannel(net *lntest.NetworkHarness, t *harnessTest) {
57335733
}
57345734

57355735
// Carol will use the correct preimage to resolve the HTLC on-chain.
5736-
_, err = waitForTxInMempool(net.Miner.Node, 5*time.Second)
5736+
_, err = waitForTxInMempool(net.Miner.Node, minerMempoolTimeout)
57375737
if err != nil {
57385738
t.Fatalf("unable to find Bob's breach tx in mempool: %v", err)
57395739
}
@@ -5746,7 +5746,7 @@ func testFailingChannel(net *lntest.NetworkHarness, t *harnessTest) {
57465746
}
57475747

57485748
// Wait for the sweeping tx to be broadcast.
5749-
_, err = waitForTxInMempool(net.Miner.Node, 5*time.Second)
5749+
_, err = waitForTxInMempool(net.Miner.Node, minerMempoolTimeout)
57505750
if err != nil {
57515751
t.Fatalf("unable to find Bob's breach tx in mempool: %v", err)
57525752
}
@@ -6218,7 +6218,7 @@ func testRevokedCloseRetribution(net *lntest.NetworkHarness, t *harnessTest) {
62186218

62196219
// Wait for Bob's breach transaction to show up in the mempool to ensure
62206220
// that Carol's node has started waiting for confirmations.
6221-
_, err = waitForTxInMempool(net.Miner.Node, 5*time.Second)
6221+
_, err = waitForTxInMempool(net.Miner.Node, minerMempoolTimeout)
62226222
if err != nil {
62236223
t.Fatalf("unable to find Bob's breach tx in mempool: %v", err)
62246224
}
@@ -6246,7 +6246,7 @@ func testRevokedCloseRetribution(net *lntest.NetworkHarness, t *harnessTest) {
62466246
// Query the mempool for Carol's justice transaction, this should be
62476247
// broadcast as Bob's contract breaching transaction gets confirmed
62486248
// above.
6249-
justiceTXID, err := waitForTxInMempool(net.Miner.Node, 5*time.Second)
6249+
justiceTXID, err := waitForTxInMempool(net.Miner.Node, minerMempoolTimeout)
62506250
if err != nil {
62516251
t.Fatalf("unable to find Carol's justice tx in mempool: %v", err)
62526252
}
@@ -6457,7 +6457,7 @@ func testRevokedCloseRetributionZeroValueRemoteOutput(net *lntest.NetworkHarness
64576457

64586458
// Query the mempool for the breaching closing transaction, this should
64596459
// be broadcast by Carol when she force closes the channel above.
6460-
txid, err := waitForTxInMempool(net.Miner.Node, 20*time.Second)
6460+
txid, err := waitForTxInMempool(net.Miner.Node, minerMempoolTimeout)
64616461
if err != nil {
64626462
t.Fatalf("unable to find Carol's force close tx in mempool: %v",
64636463
err)
@@ -6488,7 +6488,7 @@ func testRevokedCloseRetributionZeroValueRemoteOutput(net *lntest.NetworkHarness
64886488
// Query the mempool for Dave's justice transaction, this should be
64896489
// broadcast as Carol's contract breaching transaction gets confirmed
64906490
// above.
6491-
justiceTXID, err := waitForTxInMempool(net.Miner.Node, 15*time.Second)
6491+
justiceTXID, err := waitForTxInMempool(net.Miner.Node, minerMempoolTimeout)
64926492
if err != nil {
64936493
t.Fatalf("unable to find Dave's justice tx in mempool: %v",
64946494
err)
@@ -6774,7 +6774,7 @@ func testRevokedCloseRetributionRemoteHodl(net *lntest.NetworkHarness,
67746774

67756775
// Query the mempool for the breaching closing transaction, this should
67766776
// be broadcast by Carol when she force closes the channel above.
6777-
txid, err := waitForTxInMempool(net.Miner.Node, 20*time.Second)
6777+
txid, err := waitForTxInMempool(net.Miner.Node, minerMempoolTimeout)
67786778
if err != nil {
67796779
t.Fatalf("unable to find Carol's force close tx in mempool: %v",
67806780
err)
@@ -7190,7 +7190,7 @@ func testDataLossProtection(net *lntest.NetworkHarness, t *harnessTest) {
71907190

71917191
// Upon reconnection, the nodes should detect that Dave is out of sync.
71927192
// Carol should force close the channel using her latest commitment.
7193-
forceClose, err := waitForTxInMempool(net.Miner.Node, 15*time.Second)
7193+
forceClose, err := waitForTxInMempool(net.Miner.Node, minerMempoolTimeout)
71947194
if err != nil {
71957195
t.Fatalf("unable to find Carol's force close tx in mempool: %v",
71967196
err)
@@ -7216,7 +7216,7 @@ func testDataLossProtection(net *lntest.NetworkHarness, t *harnessTest) {
72167216
assertTxInBlock(t, block, forceClose)
72177217

72187218
// Dave should sweep his funds immediately, as they are not timelocked.
7219-
daveSweep, err := waitForTxInMempool(net.Miner.Node, 15*time.Second)
7219+
daveSweep, err := waitForTxInMempool(net.Miner.Node, minerMempoolTimeout)
72207220
if err != nil {
72217221
t.Fatalf("unable to find Dave's sweep tx in mempool: %v", err)
72227222
}
@@ -7251,7 +7251,7 @@ func testDataLossProtection(net *lntest.NetworkHarness, t *harnessTest) {
72517251

72527252
// After the Carol's output matures, she should also reclaim her funds.
72537253
mineBlocks(t, net, defaultCSV-1)
7254-
carolSweep, err := waitForTxInMempool(net.Miner.Node, 15*time.Second)
7254+
carolSweep, err := waitForTxInMempool(net.Miner.Node, minerMempoolTimeout)
72557255
if err != nil {
72567256
t.Fatalf("unable to find Carol's sweep tx in mempool: %v", err)
72577257
}
@@ -7308,7 +7308,7 @@ func testDataLossProtection(net *lntest.NetworkHarness, t *harnessTest) {
73087308
// Mine enough blocks for Carol to sweep her funds.
73097309
mineBlocks(t, net, defaultCSV)
73107310

7311-
carolSweep, err = waitForTxInMempool(net.Miner.Node, 15*time.Second)
7311+
carolSweep, err = waitForTxInMempool(net.Miner.Node, minerMempoolTimeout)
73127312
if err != nil {
73137313
t.Fatalf("unable to find Carol's sweep tx in mempool: %v", err)
73147314
}
@@ -7340,7 +7340,7 @@ func testDataLossProtection(net *lntest.NetworkHarness, t *harnessTest) {
73407340
}
73417341

73427342
// Dave should sweep his funds.
7343-
_, err = waitForTxInMempool(net.Miner.Node, 15*time.Second)
7343+
_, err = waitForTxInMempool(net.Miner.Node, minerMempoolTimeout)
73447344
if err != nil {
73457345
t.Fatalf("unable to find Dave's sweep tx in mempool: %v", err)
73467346
}
@@ -8790,7 +8790,7 @@ func testMultiHopHtlcLocalTimeout(net *lntest.NetworkHarness, t *harnessTest) {
87908790
t.Fatalf("unable to create sha hash: %v", err)
87918791
}
87928792
assertSpendingTxInMempool(
8793-
t, net.Miner.Node, time.Second*10, wire.OutPoint{
8793+
t, net.Miner.Node, minerMempoolTimeout, wire.OutPoint{
87948794
Hash: *bobFundingTxid,
87958795
Index: bobChanPoint.OutputIndex,
87968796
},
@@ -8821,7 +8821,7 @@ func testMultiHopHtlcLocalTimeout(net *lntest.NetworkHarness, t *harnessTest) {
88218821
t.Fatalf("unable to generate blocks: %v", err)
88228822
}
88238823

8824-
_, err = waitForTxInMempool(net.Miner.Node, 10*time.Second)
8824+
_, err = waitForTxInMempool(net.Miner.Node, minerMempoolTimeout)
88258825
if err != nil {
88268826
t.Fatalf("unable to find bob's funding output sweep tx: %v", err)
88278827
}
@@ -8834,7 +8834,7 @@ func testMultiHopHtlcLocalTimeout(net *lntest.NetworkHarness, t *harnessTest) {
88348834

88358835
// The second layer HTLC timeout transaction should now have been
88368836
// broadcast on-chain.
8837-
secondLayerHash, err := waitForTxInMempool(net.Miner.Node, time.Second*10)
8837+
secondLayerHash, err := waitForTxInMempool(net.Miner.Node, minerMempoolTimeout)
88388838
if err != nil {
88398839
t.Fatalf("unable to find bob's second layer transaction")
88408840
}
@@ -8895,7 +8895,7 @@ func testMultiHopHtlcLocalTimeout(net *lntest.NetworkHarness, t *harnessTest) {
88958895
if _, err := net.Miner.Node.Generate(4); err != nil {
88968896
t.Fatalf("unable to generate blocks: %v", err)
88978897
}
8898-
_, err = waitForTxInMempool(net.Miner.Node, time.Second*10)
8898+
_, err = waitForTxInMempool(net.Miner.Node, minerMempoolTimeout)
88998899
if err != nil {
89008900
t.Fatalf("unable to find bob's sweeping transaction: %v", err)
89018901
}
@@ -9000,7 +9000,7 @@ func testMultiHopReceiverChainClaim(net *lntest.NetworkHarness, t *harnessTest)
90009000

90019001
// At this point, Carol should broadcast her active commitment
90029002
// transaction in order to go to the chain and sweep her HTLC.
9003-
txids, err := waitForNTxsInMempool(net.Miner.Node, 1, time.Second*20)
9003+
txids, err := waitForNTxsInMempool(net.Miner.Node, 1, minerMempoolTimeout)
90049004
if err != nil {
90059005
t.Fatalf("expected transaction not found in mempool: %v", err)
90069006
}
@@ -9043,7 +9043,7 @@ func testMultiHopReceiverChainClaim(net *lntest.NetworkHarness, t *harnessTest)
90439043
// second level transaction in the mempool, he will extract the
90449044
// preimage and settle the HTLC back off-chain.
90459045
secondLevelHashes, err := waitForNTxsInMempool(net.Miner.Node, 2,
9046-
time.Second*15)
9046+
minerMempoolTimeout)
90479047
if err != nil {
90489048
t.Fatalf("transactions not found in mempool: %v", err)
90499049
}
@@ -9124,7 +9124,7 @@ func testMultiHopReceiverChainClaim(net *lntest.NetworkHarness, t *harnessTest)
91249124
}
91259125

91269126
// We should have a new transaction in the mempool.
9127-
_, err = waitForTxInMempool(net.Miner.Node, time.Second*10)
9127+
_, err = waitForTxInMempool(net.Miner.Node, minerMempoolTimeout)
91289128
if err != nil {
91299129
t.Fatalf("unable to find bob's sweeping transaction: %v", err)
91309130
}
@@ -9262,7 +9262,7 @@ func testMultiHopLocalForceCloseOnChainHtlcTimeout(net *lntest.NetworkHarness,
92629262
t.Fatalf("unable to generate blocks: %v", err)
92639263
}
92649264

9265-
_, err = waitForTxInMempool(net.Miner.Node, 10*time.Second)
9265+
_, err = waitForTxInMempool(net.Miner.Node, minerMempoolTimeout)
92669266
if err != nil {
92679267
t.Fatalf("unable to find bob's funding output sweep tx: %v", err)
92689268
}
@@ -9311,7 +9311,7 @@ func testMultiHopLocalForceCloseOnChainHtlcTimeout(net *lntest.NetworkHarness,
93119311

93129312
// We should also now find a transaction in the mempool, as Bob should
93139313
// have broadcast his second layer timeout transaction.
9314-
timeoutTx, err := waitForTxInMempool(net.Miner.Node, 10*time.Second)
9314+
timeoutTx, err := waitForTxInMempool(net.Miner.Node, minerMempoolTimeout)
93159315
if err != nil {
93169316
t.Fatalf("unable to find bob's htlc timeout tx: %v", err)
93179317
}
@@ -9378,7 +9378,7 @@ func testMultiHopLocalForceCloseOnChainHtlcTimeout(net *lntest.NetworkHarness,
93789378
t.Fatalf("unable to mine blocks: %v", err)
93799379
}
93809380

9381-
sweepTx, err := waitForTxInMempool(net.Miner.Node, 10*time.Second)
9381+
sweepTx, err := waitForTxInMempool(net.Miner.Node, minerMempoolTimeout)
93829382
if err != nil {
93839383
t.Fatalf("unable to find bob's htlc sweep tx: %v", err)
93849384
}
@@ -9506,7 +9506,7 @@ func testMultiHopRemoteForceCloseOnChainHtlcTimeout(net *lntest.NetworkHarness,
95069506
}
95079507

95089508
// Bob can sweep his output immediately.
9509-
_, err = waitForTxInMempool(net.Miner.Node, 20*time.Second)
9509+
_, err = waitForTxInMempool(net.Miner.Node, minerMempoolTimeout)
95109510
if err != nil {
95119511
t.Fatalf("unable to find bob's funding output sweep tx: %v",
95129512
err)
@@ -9558,7 +9558,7 @@ func testMultiHopRemoteForceCloseOnChainHtlcTimeout(net *lntest.NetworkHarness,
95589558

95599559
// Bob's sweeping transaction should now be found in the mempool at
95609560
// this point.
9561-
sweepTx, err := waitForTxInMempool(net.Miner.Node, time.Second*10)
9561+
sweepTx, err := waitForTxInMempool(net.Miner.Node, minerMempoolTimeout)
95629562
if err != nil {
95639563
// If Bob's transaction isn't yet in the mempool, then due to
95649564
// internal message passing and the low period between blocks
@@ -9571,7 +9571,7 @@ func testMultiHopRemoteForceCloseOnChainHtlcTimeout(net *lntest.NetworkHarness,
95719571
if _, err := net.Miner.Node.Generate(1); err != nil {
95729572
t.Fatalf("unable to generate block: %v", err)
95739573
}
9574-
sweepTx, err = waitForTxInMempool(net.Miner.Node, time.Second*10)
9574+
sweepTx, err = waitForTxInMempool(net.Miner.Node, minerMempoolTimeout)
95759575
if err != nil {
95769576
t.Fatalf("unable to find bob's sweeping transaction: "+
95779577
"%v", err)
@@ -9699,7 +9699,7 @@ func testMultiHopHtlcLocalChainClaim(net *lntest.NetworkHarness, t *harnessTest)
96999699
}
97009700

97019701
// Carol's commitment transaction should now be in the mempool.
9702-
txids, err := waitForNTxsInMempool(net.Miner.Node, 1, time.Second*15)
9702+
txids, err := waitForNTxsInMempool(net.Miner.Node, 1, minerMempoolTimeout)
97039703
if err != nil {
97049704
t.Fatalf("transactions not found in mempool: %v", err)
97059705
}
@@ -9741,7 +9741,7 @@ func testMultiHopHtlcLocalChainClaim(net *lntest.NetworkHarness, t *harnessTest)
97419741
// immediately, as the output is not timelocked since Carol was the one
97429742
// force closing.
97439743
commitSpends, err := waitForNTxsInMempool(net.Miner.Node, 2,
9744-
time.Second*20)
9744+
minerMempoolTimeout)
97459745
if err != nil {
97469746
t.Fatalf("transactions not found in mempool: %v", err)
97479747
}
@@ -9776,7 +9776,7 @@ func testMultiHopHtlcLocalChainClaim(net *lntest.NetworkHarness, t *harnessTest)
97769776
// will extract the preimage and broadcast a second level tx to claim
97779777
// the HTLC in his (already closed) channel with Alice.
97789778
bobSecondLvlTx, err := waitForTxInMempool(net.Miner.Node,
9779-
time.Second*20)
9779+
minerMempoolTimeout)
97809780
if err != nil {
97819781
t.Fatalf("transactions not found in mempool: %v", err)
97829782
}
@@ -9855,7 +9855,7 @@ func testMultiHopHtlcLocalChainClaim(net *lntest.NetworkHarness, t *harnessTest)
98559855
}
98569856
bobSecondLevelCSV -= carolSecondLevelCSV
98579857

9858-
carolSweep, err := waitForTxInMempool(net.Miner.Node, time.Second*10)
9858+
carolSweep, err := waitForTxInMempool(net.Miner.Node, minerMempoolTimeout)
98599859
if err != nil {
98609860
t.Fatalf("unable to find Carol's sweeping transaction: %v", err)
98619861
}
@@ -9865,7 +9865,7 @@ func testMultiHopHtlcLocalChainClaim(net *lntest.NetworkHarness, t *harnessTest)
98659865
block = mineBlocks(t, net, bobSecondLevelCSV)[0]
98669866
assertTxInBlock(t, block, carolSweep)
98679867

9868-
bobSweep, err := waitForTxInMempool(net.Miner.Node, time.Second*10)
9868+
bobSweep, err := waitForTxInMempool(net.Miner.Node, minerMempoolTimeout)
98699869
if err != nil {
98709870
t.Fatalf("unable to find bob's sweeping transaction")
98719871
}
@@ -10046,7 +10046,7 @@ func testMultiHopHtlcRemoteChainClaim(net *lntest.NetworkHarness, t *harnessTest
1004610046
}
1004710047

1004810048
// Carol's commitment transaction should now be in the mempool.
10049-
txids, err := waitForNTxsInMempool(net.Miner.Node, 1, time.Second*15)
10049+
txids, err := waitForNTxsInMempool(net.Miner.Node, 1, minerMempoolTimeout)
1005010050
if err != nil {
1005110051
t.Fatalf("transactions not found in mempool: %v", err)
1005210052
}
@@ -10088,7 +10088,7 @@ func testMultiHopHtlcRemoteChainClaim(net *lntest.NetworkHarness, t *harnessTest
1008810088
// immediately, as the output is not timelocked since Carol was the one
1008910089
// force closing.
1009010090
commitSpends, err := waitForNTxsInMempool(net.Miner.Node, 2,
10091-
time.Second*20)
10091+
minerMempoolTimeout)
1009210092
if err != nil {
1009310093
t.Fatalf("transactions not found in mempool: %v", err)
1009410094
}
@@ -10123,7 +10123,7 @@ func testMultiHopHtlcRemoteChainClaim(net *lntest.NetworkHarness, t *harnessTest
1012310123
// will extract the preimage and broadcast a sweep tx to directly claim
1012410124
// the HTLC in his (already closed) channel with Alice.
1012510125
bobHtlcSweep, err := waitForTxInMempool(net.Miner.Node,
10126-
time.Second*20)
10126+
minerMempoolTimeout)
1012710127
if err != nil {
1012810128
t.Fatalf("transactions not found in mempool: %v", err)
1012910129
}
@@ -10178,7 +10178,7 @@ func testMultiHopHtlcRemoteChainClaim(net *lntest.NetworkHarness, t *harnessTest
1017810178
t.Fatalf("unable to generate block: %v", err)
1017910179
}
1018010180

10181-
carolSweep, err := waitForTxInMempool(net.Miner.Node, time.Second*10)
10181+
carolSweep, err := waitForTxInMempool(net.Miner.Node, minerMempoolTimeout)
1018210182
if err != nil {
1018310183
t.Fatalf("unable to find Carol's sweeping transaction: %v", err)
1018410184
}
@@ -12169,7 +12169,7 @@ func testSendUpdateDisableChannel(net *lntest.NetworkHarness, t *harnessTest) {
1216912169
)
1217012170

1217112171
// Finally, close the channels by mining the closing transactions.
12172-
_, err = waitForNTxsInMempool(net.Miner.Node, 2, timeout)
12172+
_, err = waitForNTxsInMempool(net.Miner.Node, 2, minerMempoolTimeout)
1217312173
if err != nil {
1217412174
t.Fatalf("expected transactions not found in mempool: %v", err)
1217512175
}
@@ -12189,7 +12189,7 @@ func testSendUpdateDisableChannel(net *lntest.NetworkHarness, t *harnessTest) {
1218912189
},
1219012190
)
1219112191

12192-
_, err = waitForNTxsInMempool(net.Miner.Node, 1, timeout)
12192+
_, err = waitForNTxsInMempool(net.Miner.Node, 1, minerMempoolTimeout)
1219312193
if err != nil {
1219412194
t.Fatalf("expected transactions not found in mempool: %v", err)
1219512195
}

0 commit comments

Comments
 (0)