Skip to content

Commit 6bd8bae

Browse files
committed
lntest+itest: continue removing direct call to Miner
1 parent 976bb37 commit 6bd8bae

18 files changed

+124
-93
lines changed

itest/lnd_channel_backup_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,7 @@ func runChanRestoreScenarioCommitTypes(ht *lntest.HarnessTest,
624624

625625
var fundingShim *lnrpc.FundingShim
626626
if ct == lnrpc.CommitmentType_SCRIPT_ENFORCED_LEASE {
627-
_, minerHeight := ht.Miner.GetBestBlock()
627+
_, minerHeight := ht.GetBestBlock()
628628
thawHeight := uint32(minerHeight + thawHeightDelta)
629629

630630
fundingShim, _ = deriveFundingShim(

itest/lnd_channel_force_close_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ func channelForceClosureTest(ht *lntest.HarnessTest,
160160

161161
// Fetch starting height of this test so we can compute the block
162162
// heights we expect certain events to take place.
163-
_, curHeight := ht.Miner.GetBestBlock()
163+
_, curHeight := ht.GetBestBlock()
164164

165165
// Using the current height of the chain, derive the relevant heights
166166
// for incubating two-stage htlcs.
@@ -214,7 +214,7 @@ func channelForceClosureTest(ht *lntest.HarnessTest,
214214
ht.AssertNumUTXOs(alice, expectedUtxos)
215215

216216
// We expect to see Alice's force close tx in the mempool.
217-
ht.Miner.GetNumTxsFromMempool(1)
217+
ht.GetNumTxsFromMempool(1)
218218

219219
// Mine a block which should confirm the commitment transaction
220220
// broadcast as a result of the force closure. Once mined, we also
@@ -278,7 +278,7 @@ func channelForceClosureTest(ht *lntest.HarnessTest,
278278

279279
// Carol's sweep tx should be in the mempool already, as her output is
280280
// not timelocked.
281-
carolTx := ht.Miner.GetNumTxsFromMempool(1)[0]
281+
carolTx := ht.GetNumTxsFromMempool(1)[0]
282282

283283
// Carol's sweeping tx should have 2-input-1-output shape.
284284
require.Len(ht, carolTx.TxIn, 2)
@@ -431,7 +431,7 @@ func channelForceClosureTest(ht *lntest.HarnessTest,
431431
ht.MineBlocksAndAssertNumTxes(1, 1)
432432

433433
// Update current height
434-
_, curHeight = ht.Miner.GetBestBlock()
434+
_, curHeight = ht.GetBestBlock()
435435

436436
// checkForceClosedChannelNumHtlcs verifies that a force closed channel
437437
// has the proper number of htlcs.
@@ -485,7 +485,7 @@ func channelForceClosureTest(ht *lntest.HarnessTest,
485485
// number of blocks we have generated since adding it to the nursery,
486486
// and take an additional block off so that we end up one block shy of
487487
// the expiry height, and add the block padding.
488-
_, currentHeight := ht.Miner.GetBestBlock()
488+
_, currentHeight := ht.GetBestBlock()
489489
cltvHeightDelta := int(htlcExpiryHeight - uint32(currentHeight) - 1)
490490

491491
// Advance the blockchain until just before the CLTV expires, nothing
@@ -662,7 +662,7 @@ func channelForceClosureTest(ht *lntest.HarnessTest,
662662

663663
// Advance the chain until just before the 2nd-layer CSV delays expire.
664664
// For anchor channels this is one block earlier.
665-
_, currentHeight = ht.Miner.GetBestBlock()
665+
_, currentHeight = ht.GetBestBlock()
666666
ht.Logf("current height: %v, htlcCsvMaturityHeight=%v", currentHeight,
667667
htlcCsvMaturityHeight)
668668
numBlocks := int(htlcCsvMaturityHeight - uint32(currentHeight) - 2)

itest/lnd_channel_graph_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ func testGraphTopologyNtfns(ht *lntest.HarnessTest, pinned bool) {
316316
ht.AssertNumNodeAnns(alice, alice.PubKeyStr, 1)
317317
ht.AssertNumNodeAnns(alice, bob.PubKeyStr, 1)
318318

319-
_, blockHeight := ht.Miner.GetBestBlock()
319+
_, blockHeight := ht.GetBestBlock()
320320

321321
// Now we'll test that updates are properly sent after channels are
322322
// closed within the network.

itest/lnd_coop_close_with_htlcs_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ func coopCloseWithHTLCs(ht *lntest.HarnessTest) {
117117
)
118118

119119
// Wait for the close tx to be in the Mempool.
120-
ht.Miner.AssertTxInMempool(&closeTxid)
120+
ht.AssertTxInMempool(&closeTxid)
121121

122122
// Wait for it to get mined and finish tearing down.
123123
ht.AssertStreamChannelCoopClosed(alice, chanPoint, false, closeClient)

itest/lnd_funding_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -862,7 +862,7 @@ func testChannelFundingPersistence(ht *lntest.HarnessTest) {
862862
ht.AssertTxInBlock(block, fundingTxID)
863863

864864
// Get the height that our transaction confirmed at.
865-
_, height := ht.Miner.GetBestBlock()
865+
_, height := ht.GetBestBlock()
866866

867867
// Restart both nodes to test that the appropriate state has been
868868
// persisted and that both nodes recover gracefully.

itest/lnd_hold_invoice_force_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ func testHoldInvoiceForceClose(ht *lntest.HarnessTest) {
5959
require.Len(ht, channel.PendingHtlcs, 1)
6060
activeHtlc := channel.PendingHtlcs[0]
6161

62-
_, currentHeight := ht.Miner.GetBestBlock()
62+
_, currentHeight := ht.GetBestBlock()
6363

6464
// Now we will mine blocks until the htlc expires, and wait for each
6565
// node to sync to our latest height. Sanity check that we won't

itest/lnd_multi-hop_test.go

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ func runMultiHopHtlcLocalTimeout(ht *lntest.HarnessTest,
248248
// Bob's force close transaction should now be found in the mempool.
249249
ht.AssertNumTxsInMempool(1)
250250
op := ht.OutPointFromChannelPoint(bobChanPoint)
251-
closeTx := ht.Miner.AssertOutpointInMempool(op)
251+
closeTx := ht.AssertOutpointInMempool(op)
252252

253253
// Bob's anchor output should be offered to his sweep since Bob has
254254
// time-sensitive HTLCs - we expect both anchors are offered.
@@ -280,7 +280,7 @@ func runMultiHopHtlcLocalTimeout(ht *lntest.HarnessTest,
280280

281281
htlcOutpoint := wire.OutPoint{Hash: closeTx.TxHash(), Index: 2}
282282
commitOutpoint := wire.OutPoint{Hash: closeTx.TxHash(), Index: 3}
283-
htlcTimeoutTxid := ht.Miner.AssertOutpointInMempool(
283+
htlcTimeoutTxid := ht.AssertOutpointInMempool(
284284
htlcOutpoint,
285285
).TxHash()
286286

@@ -330,7 +330,7 @@ func runMultiHopHtlcLocalTimeout(ht *lntest.HarnessTest,
330330
ht.AssertNumPendingSweeps(bob, 2)
331331

332332
// Assert that the HTLC timeout tx is now in the mempool.
333-
ht.Miner.AssertOutpointInMempool(htlcTimeoutOutpoint)
333+
ht.AssertOutpointInMempool(htlcTimeoutOutpoint)
334334

335335
// We now wait for 30 seconds to overcome the flake - there's a
336336
// block race between contractcourt and sweeper, causing the
@@ -363,7 +363,7 @@ func runMultiHopHtlcLocalTimeout(ht *lntest.HarnessTest,
363363
pendingChanResp := bob.RPC.PendingChannels()
364364
if len(pendingChanResp.PendingForceClosingChannels) != 0 {
365365
// Check that the sweep spends the expected inputs.
366-
ht.Miner.AssertOutpointInMempool(commitOutpoint)
366+
ht.AssertOutpointInMempool(commitOutpoint)
367367
ht.MineBlocksAndAssertNumTxes(1, 1)
368368
}
369369
} else {
@@ -381,14 +381,14 @@ func runMultiHopHtlcLocalTimeout(ht *lntest.HarnessTest,
381381
ht.MineEmptyBlocks(1)
382382

383383
// Check that the sweep spends from the mined commitment.
384-
ht.Miner.AssertOutpointInMempool(commitOutpoint)
384+
ht.AssertOutpointInMempool(commitOutpoint)
385385

386386
// Mine one more block to trigger the timeout path.
387387
ht.MineBlocksAndAssertNumTxes(1, 1)
388388

389389
// Bob's sweeper should now broadcast his second layer sweep
390390
// due to the CSV on the HTLC timeout output.
391-
ht.Miner.AssertOutpointInMempool(htlcTimeoutOutpoint)
391+
ht.AssertOutpointInMempool(htlcTimeoutOutpoint)
392392

393393
// Next, we'll mine a final block that should confirm the
394394
// sweeping transactions left.
@@ -503,7 +503,7 @@ func runMultiHopReceiverChainClaim(ht *lntest.HarnessTest,
503503
// transaction in order to go to the chain and sweep her HTLC.
504504
ht.AssertNumTxsInMempool(1)
505505

506-
closingTx := ht.Miner.AssertOutpointInMempool(
506+
closingTx := ht.AssertOutpointInMempool(
507507
ht.OutPointFromChannelPoint(bobChanPoint),
508508
)
509509
closingTxid := closingTx.TxHash()
@@ -572,7 +572,7 @@ func runMultiHopReceiverChainClaim(ht *lntest.HarnessTest,
572572
ht.MineEmptyBlocks(1)
573573

574574
// All transactions should be spending from the commitment transaction.
575-
txes := ht.Miner.GetNumTxsFromMempool(expectedTxes)
575+
txes := ht.GetNumTxsFromMempool(expectedTxes)
576576
ht.AssertAllTxesSpendFrom(txes, closingTxid)
577577

578578
// We'll now mine an additional block which should confirm both the
@@ -644,7 +644,7 @@ func runMultiHopReceiverChainClaim(ht *lntest.HarnessTest,
644644
ht.MineEmptyBlocks(1)
645645

646646
commitOutpoint := wire.OutPoint{Hash: closingTxid, Index: 3}
647-
ht.Miner.AssertOutpointInMempool(commitOutpoint)
647+
ht.AssertOutpointInMempool(commitOutpoint)
648648
ht.MineBlocksAndAssertNumTxes(1, 1)
649649
}
650650

@@ -756,7 +756,7 @@ func runMultiHopLocalForceCloseOnChainHtlcTimeout(ht *lntest.HarnessTest,
756756
ht.MineEmptyBlocks(1)
757757
blocksMined++
758758

759-
commitSweepTx := ht.Miner.AssertOutpointInMempool(
759+
commitSweepTx := ht.AssertOutpointInMempool(
760760
bobCommitOutpoint,
761761
)
762762
txid := commitSweepTx.TxHash()
@@ -784,7 +784,7 @@ func runMultiHopLocalForceCloseOnChainHtlcTimeout(ht *lntest.HarnessTest,
784784

785785
// We should also now find a transaction in the mempool, as Bob should
786786
// have broadcast his second layer timeout transaction.
787-
timeoutTx := ht.Miner.AssertOutpointInMempool(htlcOutpoint).TxHash()
787+
timeoutTx := ht.AssertOutpointInMempool(htlcOutpoint).TxHash()
788788

789789
// Next, we'll mine an additional block. This should serve to confirm
790790
// the second layer timeout transaction.
@@ -837,7 +837,7 @@ func runMultiHopLocalForceCloseOnChainHtlcTimeout(ht *lntest.HarnessTest,
837837

838838
// Assert the sweeping tx is found in the mempool.
839839
htlcTimeoutOutpoint := wire.OutPoint{Hash: timeoutTx, Index: 0}
840-
ht.Miner.AssertOutpointInMempool(htlcTimeoutOutpoint)
840+
ht.AssertOutpointInMempool(htlcTimeoutOutpoint)
841841

842842
// Mine a block to confirm the sweep.
843843
ht.MineBlocksAndAssertNumTxes(1, numExpected)
@@ -1042,7 +1042,7 @@ func runMultiHopRemoteForceCloseOnChainHtlcTimeout(ht *lntest.HarnessTest,
10421042
ht.MineEmptyBlocks(1)
10431043

10441044
bobCommitOutpoint := wire.OutPoint{Hash: *closeTx, Index: 3}
1045-
bobCommitSweep := ht.Miner.AssertOutpointInMempool(
1045+
bobCommitSweep := ht.AssertOutpointInMempool(
10461046
bobCommitOutpoint,
10471047
)
10481048
bobCommitSweepTxid := bobCommitSweep.TxHash()
@@ -1219,7 +1219,7 @@ func runMultiHopHtlcLocalChainClaim(ht *lntest.HarnessTest,
12191219

12201220
// Look up the closing transaction. It should be spending from the
12211221
// funding transaction,
1222-
closingTx := ht.Miner.AssertOutpointInMempool(
1222+
closingTx := ht.AssertOutpointInMempool(
12231223
ht.OutPointFromChannelPoint(bobChanPoint),
12241224
)
12251225
closingTxid := closingTx.TxHash()
@@ -1300,7 +1300,7 @@ func runMultiHopHtlcLocalChainClaim(ht *lntest.HarnessTest,
13001300
carolSecondLevelCSV--
13011301

13021302
// Check Bob's second level tx.
1303-
bobSecondLvlTx := ht.Miner.GetNumTxsFromMempool(1)[0]
1303+
bobSecondLvlTx := ht.GetNumTxsFromMempool(1)[0]
13041304

13051305
// It should spend from the commitment in the channel with Alice.
13061306
ht.AssertTxSpendFrom(bobSecondLvlTx, *bobForceClose)
@@ -1355,7 +1355,7 @@ func runMultiHopHtlcLocalChainClaim(ht *lntest.HarnessTest,
13551355
block = ht.MineBlocksAndAssertNumTxes(bobSecondLevelCSV, 1)[0]
13561356
ht.AssertTxInBlock(block, carolSweep)
13571357

1358-
bobSweep := ht.Miner.GetNumTxsFromMempool(1)[0]
1358+
bobSweep := ht.GetNumTxsFromMempool(1)[0]
13591359
bobSweepTxid := bobSweep.TxHash()
13601360

13611361
// When we mine one additional block, that will confirm Bob's sweep.
@@ -1399,11 +1399,11 @@ func runMultiHopHtlcLocalChainClaim(ht *lntest.HarnessTest,
13991399
aliceCommitOutpoint := wire.OutPoint{
14001400
Hash: *bobForceClose, Index: 3,
14011401
}
1402-
ht.Miner.AssertOutpointInMempool(
1402+
ht.AssertOutpointInMempool(
14031403
aliceCommitOutpoint,
14041404
).TxHash()
14051405
bobCommitOutpoint := wire.OutPoint{Hash: closingTxid, Index: 3}
1406-
ht.Miner.AssertOutpointInMempool(
1406+
ht.AssertOutpointInMempool(
14071407
bobCommitOutpoint,
14081408
).TxHash()
14091409

@@ -1562,7 +1562,7 @@ func runMultiHopHtlcRemoteChainClaim(ht *lntest.HarnessTest,
15621562

15631563
// The closing transaction should be spending from the funding
15641564
// transaction.
1565-
closingTx := ht.Miner.AssertOutpointInMempool(
1565+
closingTx := ht.AssertOutpointInMempool(
15661566
ht.OutPointFromChannelPoint(bobChanPoint),
15671567
)
15681568
closingTxid := closingTx.TxHash()
@@ -1624,7 +1624,7 @@ func runMultiHopHtlcRemoteChainClaim(ht *lntest.HarnessTest,
16241624
// NOTE: after Bob is restarted, the sweeping of the direct preimage
16251625
// spent will happen immediately so we don't need to mine a block to
16261626
// trigger Bob's sweeper to sweep it.
1627-
bobHtlcSweep := ht.Miner.GetNumTxsFromMempool(1)[0]
1627+
bobHtlcSweep := ht.GetNumTxsFromMempool(1)[0]
16281628
bobHtlcSweepTxid := bobHtlcSweep.TxHash()
16291629

16301630
// It should spend from the commitment in the channel with Alice.
@@ -1692,9 +1692,9 @@ func runMultiHopHtlcRemoteChainClaim(ht *lntest.HarnessTest,
16921692
aliceCommitOutpoint := wire.OutPoint{
16931693
Hash: *aliceForceClose, Index: 3,
16941694
}
1695-
ht.Miner.AssertOutpointInMempool(aliceCommitOutpoint)
1695+
ht.AssertOutpointInMempool(aliceCommitOutpoint)
16961696
bobCommitOutpoint := wire.OutPoint{Hash: closingTxid, Index: 3}
1697-
ht.Miner.AssertOutpointInMempool(bobCommitOutpoint)
1697+
ht.AssertOutpointInMempool(bobCommitOutpoint)
16981698

16991699
// Confirm their sweeps.
17001700
ht.MineBlocksAndAssertNumTxes(1, 2)
@@ -1887,7 +1887,7 @@ func runMultiHopHtlcAggregation(ht *lntest.HarnessTest,
18871887
// other for local.
18881888
ht.AssertNumPendingSweeps(bob, 2)
18891889

1890-
closeTx := ht.Miner.AssertOutpointInMempool(
1890+
closeTx := ht.AssertOutpointInMempool(
18911891
ht.OutPointFromChannelPoint(bobChanPoint),
18921892
)
18931893
closeTxid := closeTx.TxHash()
@@ -1977,7 +1977,7 @@ func runMultiHopHtlcAggregation(ht *lntest.HarnessTest,
19771977
ht.MineBlocksAndAssertNumTxes(1, 1)
19781978

19791979
// Assert the sweeping txns are found in the mempool.
1980-
txes := ht.Miner.GetNumTxsFromMempool(expectedTxes)
1980+
txes := ht.GetNumTxsFromMempool(expectedTxes)
19811981

19821982
// Since Bob can aggregate the transactions, we expect a single
19831983
// transaction, that have multiple spends from the commitment.
@@ -2048,7 +2048,7 @@ func runMultiHopHtlcAggregation(ht *lntest.HarnessTest,
20482048
ht.MineEmptyBlocks(1)
20492049

20502050
// Find the commitment sweep.
2051-
bobCommitSweep := ht.Miner.GetNumTxsFromMempool(1)[0]
2051+
bobCommitSweep := ht.GetNumTxsFromMempool(1)[0]
20522052
ht.AssertTxSpendFrom(bobCommitSweep, closeTxid)
20532053

20542054
// Also ensure it is not spending from any of the HTLC output.
@@ -2092,7 +2092,7 @@ func runMultiHopHtlcAggregation(ht *lntest.HarnessTest,
20922092
numBlocks := uint32(forceCloseChan.BlocksTilMaturity)
20932093

20942094
// Add debug log.
2095-
_, height := ht.Miner.GetBestBlock()
2095+
_, height := ht.GetBestBlock()
20962096
bob.AddToLogf("itest: now mine %d blocks at height %d",
20972097
numBlocks, height)
20982098
ht.MineEmptyBlocks(int(numBlocks) - 1)
@@ -2135,7 +2135,7 @@ func runMultiHopHtlcAggregation(ht *lntest.HarnessTest,
21352135
ht.Logf("Checking mempool got: %v", err)
21362136

21372137
// Make sure it spends from the second level tx.
2138-
secondLevelSweep := ht.Miner.GetNumTxsFromMempool(numExpected)[0]
2138+
secondLevelSweep := ht.GetNumTxsFromMempool(numExpected)[0]
21392139
bobSweep := secondLevelSweep.TxHash()
21402140

21412141
// It should be sweeping all the second-level outputs.
@@ -2232,7 +2232,7 @@ func createThreeHopNetwork(ht *lntest.HarnessTest,
22322232
var aliceFundingShim *lnrpc.FundingShim
22332233
var thawHeight uint32
22342234
if c == lnrpc.CommitmentType_SCRIPT_ENFORCED_LEASE {
2235-
_, minerHeight := ht.Miner.GetBestBlock()
2235+
_, minerHeight := ht.GetBestBlock()
22362236
thawHeight = uint32(minerHeight + thawHeightDelta)
22372237
aliceFundingShim, _ = deriveFundingShim(
22382238
ht, alice, bob, chanAmt, thawHeight, true, c,
@@ -2449,7 +2449,7 @@ func runExtraPreimageFromRemoteCommit(ht *lntest.HarnessTest,
24492449

24502450
// Get the current height to compute number of blocks to mine to
24512451
// trigger the htlc timeout resolver from Bob.
2452-
_, height := ht.Miner.GetBestBlock()
2452+
_, height := ht.GetBestBlock()
24532453

24542454
// We'll now mine enough blocks to trigger Bob's timeout resolver.
24552455
numBlocks = htlc.ExpirationHeight - uint32(height) -
@@ -2680,7 +2680,7 @@ func runExtraPreimageFromLocalCommit(ht *lntest.HarnessTest,
26802680

26812681
// Get the current height to compute number of blocks to mine to
26822682
// trigger the timeout resolver from Bob.
2683-
_, height := ht.Miner.GetBestBlock()
2683+
_, height := ht.GetBestBlock()
26842684

26852685
// We'll now mine enough blocks to trigger Bob's htlc timeout resolver
26862686
// to act. Once his timeout resolver starts, it will extract the
@@ -2701,7 +2701,7 @@ func runExtraPreimageFromLocalCommit(ht *lntest.HarnessTest,
27012701
// preimage from the blocks.
27022702
if ht.IsNeutrinoBackend() {
27032703
// Make sure the direct spend tx is still in the mempool.
2704-
ht.Miner.AssertOutpointInMempool(htlcOutpoint)
2704+
ht.AssertOutpointInMempool(htlcOutpoint)
27052705

27062706
// Mine a block to confirm Carol's direct spend tx.
27072707
ht.MineBlocks(1)

0 commit comments

Comments
 (0)