Skip to content

Commit 14e7b13

Browse files
committed
lntest+itest: make Miner a private instance
1 parent be4dba5 commit 14e7b13

File tree

9 files changed

+61
-51
lines changed

9 files changed

+61
-51
lines changed

itest/lnd_channel_force_close_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,7 @@ func channelForceClosureTest(ht *lntest.HarnessTest,
709709
// NOTE: we don't check `len(mempool) == 1` because it will
710710
// give us false positive.
711711
err := wait.NoError(func() error {
712-
mempool := ht.Miner.GetRawMempool()
712+
mempool := ht.Miner().GetRawMempool()
713713
if len(mempool) == 2 {
714714
return nil
715715
}

itest/lnd_nonstd_sweep_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ func testNonStdSweepInner(ht *lntest.HarnessTest, address string) {
125125

126126
// Fetch the vsize of the transaction so we can determine if the
127127
// transaction pays >= 1 sat/vbyte.
128-
rawTx := ht.Miner.GetRawTransactionVerbose(txid)
128+
rawTx := ht.Miner().GetRawTransactionVerbose(txid)
129129

130130
// Require fee >= vbytes.
131131
require.True(ht, fee >= int(rawTx.Vsize))

itest/lnd_open_channel_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func testOpenChannelAfterReorg(ht *lntest.HarnessTest) {
3232
// Create a temp miner.
3333
tempMiner := ht.SpawnTempMiner()
3434

35-
miner := ht.Miner
35+
miner := ht.Miner()
3636
alice, bob := ht.Alice, ht.Bob
3737

3838
// Create a new channel that requires 1 confs before it's considered

itest/lnd_rest_api_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ func wsTestCaseSubscription(ht *lntest.HarnessTest) {
296296
}()
297297

298298
// Mine a block and make sure we get a message for it.
299-
blockHashes := ht.Miner.GenerateBlocks(1)
299+
blockHashes := ht.Miner().GenerateBlocks(1)
300300
select {
301301
case msg := <-msgChan:
302302
require.Equal(
@@ -388,7 +388,7 @@ func wsTestCaseSubscriptionMacaroon(ht *lntest.HarnessTest) {
388388
}()
389389

390390
// Mine a block and make sure we get a message for it.
391-
blockHashes := ht.Miner.GenerateBlocks(1)
391+
blockHashes := ht.Miner().GenerateBlocks(1)
392392
select {
393393
case msg := <-msgChan:
394394
require.Equal(

itest/lnd_revocation_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,7 @@ func revokedCloseRetributionRemoteHodlCase(ht *lntest.HarnessTest,
579579
// NOTE: We don't use `ht.GetRawTransaction`
580580
// which asserts a txid must be found as the HTLC
581581
// spending txes might be aggregated.
582-
tx, err := ht.Miner.Client.GetRawTransaction(txid)
582+
tx, err := ht.Miner().Client.GetRawTransaction(txid)
583583
if err != nil {
584584
return nil, err
585585
}

itest/lnd_sweep_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ func testSweepCPFPAnchorOutgoingTimeout(ht *lntest.HarnessTest) {
172172

173173
// Remember the force close height so we can calculate the deadline
174174
// height.
175-
_, forceCloseHeight := ht.Miner.GetBestBlock()
175+
_, forceCloseHeight := ht.GetBestBlock()
176176

177177
// Bob should have two pending sweeps,
178178
// - anchor sweeping from his local commitment.
@@ -304,7 +304,7 @@ func testSweepCPFPAnchorOutgoingTimeout(ht *lntest.HarnessTest) {
304304
//
305305
// Once out of the above loop, we expect to be 2 blocks before the CPFP
306306
// deadline.
307-
_, currentHeight := ht.Miner.GetBestBlock()
307+
_, currentHeight := ht.GetBestBlock()
308308
require.Equal(ht, int(anchorDeadline-2), int(currentHeight))
309309

310310
// Mine one more block, we'd use up all the CPFP budget.
@@ -512,7 +512,7 @@ func testSweepCPFPAnchorIncomingTimeout(ht *lntest.HarnessTest) {
512512
forceCloseHeight := htlc.ExpirationHeight - goToChainDelta
513513

514514
// Mine till the goToChainHeight is reached.
515-
_, currentHeight := ht.Miner.GetBestBlock()
515+
_, currentHeight := ht.GetBestBlock()
516516
numBlocks := forceCloseHeight - uint32(currentHeight)
517517
ht.MineEmptyBlocks(int(numBlocks))
518518

@@ -641,7 +641,7 @@ func testSweepCPFPAnchorIncomingTimeout(ht *lntest.HarnessTest) {
641641
//
642642
// Once out of the above loop, we expect to be 2 blocks before the CPFP
643643
// deadline.
644-
_, currentHeight = ht.Miner.GetBestBlock()
644+
_, currentHeight = ht.GetBestBlock()
645645
require.Equal(ht, int(anchorDeadline-2), int(currentHeight))
646646

647647
// Mine one more block, we'd use up all the CPFP budget.
@@ -1380,7 +1380,7 @@ func testSweepCommitOutputAndAnchor(ht *lntest.HarnessTest) {
13801380
//
13811381
// TODO(yy): assert they are equal once blocks are synced via
13821382
// `blockbeat`.
1383-
_, currentHeight := ht.Miner.GetBestBlock()
1383+
_, currentHeight := ht.GetBestBlock()
13841384
actualDeadline := int32(pendingSweepBob.DeadlineHeight) - currentHeight
13851385
if actualDeadline != int32(deadlineB) {
13861386
ht.Logf("!!! Found unsynced block between sweeper and "+
@@ -1438,7 +1438,7 @@ func testSweepCommitOutputAndAnchor(ht *lntest.HarnessTest) {
14381438
//
14391439
// TODO(yy): assert they are equal once blocks are synced via
14401440
// `blockbeat`.
1441-
_, currentHeight = ht.Miner.GetBestBlock()
1441+
_, currentHeight = ht.GetBestBlock()
14421442
actualDeadline = int32(aliceCommit.DeadlineHeight) - currentHeight
14431443
if actualDeadline != int32(deadlineA) {
14441444
ht.Logf("!!! Found unsynced block between Alice's sweeper and "+

itest/lnd_taproot_test.go

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

9797
// Assert this is a segwit v1 address that starts with bcrt1p.
9898
require.Contains(
99-
ht, p2trResp.Address, ht.Miner.ActiveNet.Bech32HRPSegwit+"1p",
99+
ht, p2trResp.Address, ht.Miner().ActiveNet.Bech32HRPSegwit+"1p",
100100
)
101101

102102
// Send the coins from Alice's wallet to her own, but to the new p2tr

lntest/harness.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,9 @@ type HarnessTest struct {
7777
// Embed the standbyNodes so we can easily access them via `ht.Alice`.
7878
standbyNodes
7979

80-
// Miner is a reference to a running full node that can be used to
80+
// miner is a reference to a running full node that can be used to
8181
// create new blocks on the network.
82-
Miner *miner.HarnessMiner
82+
miner *miner.HarnessMiner
8383

8484
// manager handles the start and stop of a given node.
8585
manager *nodeManager
@@ -188,7 +188,7 @@ func (h *HarnessTest) Start(chain node.BackendConfig,
188188
h.manager.feeServiceURL = h.feeService.URL()
189189

190190
// Assemble the miner.
191-
h.Miner = miner
191+
h.miner = miner
192192
}
193193

194194
// ChainBackendName returns the chain backend name used in the test.
@@ -254,7 +254,7 @@ func (h *HarnessTest) createAndSendOutput(target *node.HarnessNode,
254254
PkScript: addrScript,
255255
Value: int64(amt),
256256
}
257-
h.Miner.SendOutput(output, defaultMinerFeeRate)
257+
h.miner.SendOutput(output, defaultMinerFeeRate)
258258
}
259259

260260
// SetupRemoteSigningStandbyNodes starts the initial seeder nodes within the
@@ -371,7 +371,7 @@ func (h *HarnessTest) Stop() {
371371
h.stopChainBackend()
372372

373373
// Stop the miner.
374-
h.Miner.Stop()
374+
h.miner.Stop()
375375
}
376376

377377
// RunTestCase executes a harness test case. Any errors or panics will be
@@ -414,7 +414,7 @@ func (h *HarnessTest) Subtest(t *testing.T) *HarnessTest {
414414
st := &HarnessTest{
415415
T: t,
416416
manager: h.manager,
417-
Miner: h.Miner,
417+
miner: h.miner,
418418
standbyNodes: h.standbyNodes,
419419
feeService: h.feeService,
420420
lndErrorChan: make(chan error, lndErrorChanSize),
@@ -424,7 +424,7 @@ func (h *HarnessTest) Subtest(t *testing.T) *HarnessTest {
424424
st.runCtx, st.cancel = context.WithCancel(h.runCtx)
425425

426426
// Inherit the subtest for the miner.
427-
st.Miner.T = st.T
427+
st.miner.T = st.T
428428

429429
// Reset the standby nodes.
430430
st.resetStandbyNodes(t)
@@ -467,7 +467,7 @@ func (h *HarnessTest) Subtest(t *testing.T) *HarnessTest {
467467
st.shutdownNonStandbyNodes()
468468

469469
// We require the mempool to be cleaned from the test.
470-
require.Empty(st, st.Miner.GetRawMempool(), "mempool not "+
470+
require.Empty(st, st.miner.GetRawMempool(), "mempool not "+
471471
"cleaned, please mine blocks to clean them all.")
472472

473473
// Finally, cancel the run context. We have to do it here
@@ -1298,7 +1298,7 @@ func (h *HarnessTest) CloseChannelAssertPending(hn *node.HarnessNode,
12981298
pendingClose.ClosePending.Txid)
12991299

13001300
// Assert the closing tx is in the mempool.
1301-
h.Miner.AssertTxInMempool(closeTxid)
1301+
h.miner.AssertTxInMempool(closeTxid)
13021302

13031303
return stream, closeTxid
13041304
}
@@ -1396,7 +1396,7 @@ func (h *HarnessTest) fundCoins(amt btcutil.Amount, target *node.HarnessNode,
13961396
PkScript: addrScript,
13971397
Value: int64(amt),
13981398
}
1399-
h.Miner.SendOutput(output, defaultMinerFeeRate)
1399+
h.miner.SendOutput(output, defaultMinerFeeRate)
14001400

14011401
// Encode the pkScript in hex as this the format that it will be
14021402
// returned via rpc.
@@ -1903,7 +1903,7 @@ func (h *HarnessTest) CalculateTxFee(tx *wire.MsgTx) btcutil.Amount {
19031903
var balance btcutil.Amount
19041904
for _, in := range tx.TxIn {
19051905
parentHash := in.PreviousOutPoint.Hash
1906-
rawTx := h.Miner.GetRawTransaction(&parentHash)
1906+
rawTx := h.miner.GetRawTransaction(&parentHash)
19071907
parent := rawTx.MsgTx()
19081908
value := parent.TxOut[in.PreviousOutPoint.Index].Value
19091909

@@ -2121,12 +2121,12 @@ func (h *HarnessTest) ReceiveChannelEvent(
21212121
func (h *HarnessTest) GetOutputIndex(txid *chainhash.Hash, addr string) int {
21222122
// We'll then extract the raw transaction from the mempool in order to
21232123
// determine the index of the p2tr output.
2124-
tx := h.Miner.GetRawTransaction(txid)
2124+
tx := h.miner.GetRawTransaction(txid)
21252125

21262126
p2trOutputIndex := -1
21272127
for i, txOut := range tx.MsgTx().TxOut {
21282128
_, addrs, _, err := txscript.ExtractPkScriptAddrs(
2129-
txOut.PkScript, h.Miner.ActiveNet,
2129+
txOut.PkScript, h.miner.ActiveNet,
21302130
)
21312131
require.NoError(h, err)
21322132

0 commit comments

Comments
 (0)