Skip to content

Commit be4dba5

Browse files
committed
lntest+itest: finalize moving miner methods
1 parent 6bd8bae commit be4dba5

18 files changed

+129
-55
lines changed

itest/lnd_channel_force_close_test.go

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

394394
// Fetch the sweep transaction, all input it's spending should be from
395395
// the commitment transaction which was broadcast on-chain.
396-
sweepTx := ht.Miner.GetRawTransaction(sweepingTXID)
396+
sweepTx := ht.GetRawTransaction(sweepingTXID)
397397
for _, txIn := range sweepTx.MsgTx().TxIn {
398398
require.Equal(ht, &txIn.PreviousOutPoint.Hash, closingTxID,
399399
"sweep transaction not spending from commit")
@@ -567,7 +567,7 @@ func channelForceClosureTest(ht *lntest.HarnessTest,
567567
// on-chain. In case of an anchor type channel, we expect one
568568
// extra input that is not spending from the commitment, that
569569
// is added for fees.
570-
htlcTx := ht.Miner.GetRawTransaction(htlcTxID)
570+
htlcTx := ht.GetRawTransaction(htlcTxID)
571571

572572
// Ensure the htlc transaction has the expected number of
573573
// inputs.
@@ -736,7 +736,7 @@ func channelForceClosureTest(ht *lntest.HarnessTest,
736736
htlcSweepTxID := ht.AssertNumTxsInMempool(1)[0]
737737

738738
// Fetch the htlc sweep transaction from the mempool.
739-
htlcSweepTx := ht.Miner.GetRawTransaction(htlcSweepTxID)
739+
htlcSweepTx := ht.GetRawTransaction(htlcSweepTxID)
740740

741741
// Ensure the htlc sweep transaction only has one input for each htlc
742742
// Alice extended before force closing.

itest/lnd_channel_funding_fund_max_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import (
1515
"github.com/lightningnetwork/lnd/lnwallet"
1616
"github.com/lightningnetwork/lnd/lnwallet/chainfee"
1717
"github.com/lightningnetwork/lnd/lnwire"
18-
"github.com/stretchr/testify/require"
1918
)
2019

2120
type chanFundMaxTestCase struct {
@@ -317,8 +316,7 @@ func fundingFee(numInput int, change bool) btcutil.Amount {
317316
// sweepNodeWalletAndAssert sweeps funds from a node wallet.
318317
func sweepNodeWalletAndAssert(ht *lntest.HarnessTest, node *node.HarnessNode) {
319318
// New miner address we will sweep all funds to.
320-
minerAddr, err := ht.Miner.NewAddress()
321-
require.NoError(ht, err)
319+
minerAddr := ht.NewMinerAddress()
322320

323321
// Send all funds back to the miner node.
324322
node.RPC.SendCoins(&lnrpc.SendCoinsRequest{

itest/lnd_funding_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1053,7 +1053,7 @@ func testBatchChanFunding(ht *lntest.HarnessTest) {
10531053
ht.AssertTopologyChannelOpen(alice, chanPoint3)
10541054

10551055
// Check if the change type from the batch_open_channel funding is P2TR.
1056-
rawTx := ht.Miner.GetRawTransaction(txHash)
1056+
rawTx := ht.GetRawTransaction(txHash)
10571057
require.Len(ht, rawTx.MsgTx().TxOut, 5)
10581058

10591059
// For calculating the change output index we use the formula for the
@@ -1182,9 +1182,9 @@ func deriveFundingShim(ht *lntest.HarnessTest, carol, dave *node.HarnessNode,
11821182
var txid *chainhash.Hash
11831183
targetOutputs := []*wire.TxOut{fundingOutput}
11841184
if publish {
1185-
txid = ht.Miner.SendOutputsWithoutChange(targetOutputs, 5)
1185+
txid = ht.SendOutputsWithoutChange(targetOutputs, 5)
11861186
} else {
1187-
tx := ht.Miner.CreateTransaction(targetOutputs, 5)
1187+
tx := ht.CreateTransaction(targetOutputs, 5)
11881188

11891189
txHash := tx.TxHash()
11901190
txid = &txHash

itest/lnd_misc_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -823,14 +823,14 @@ func testSweepAllCoins(ht *lntest.HarnessTest) {
823823
// Send coins to a compatible address without specifying fee rate or
824824
// conf target.
825825
// ainz.RPC.SendCoinsAssertErr(&lnrpc.SendCoinsRequest{
826-
// Addr: ht.Miner.NewMinerAddress().String(),
826+
// Addr: ht.NewMinerAddress().String(),
827827
// SendAll: true,
828828
// Label: sendCoinsLabel,
829829
// })
830830

831831
// Send coins to a compatible address.
832832
ainz.RPC.SendCoins(&lnrpc.SendCoinsRequest{
833-
Addr: ht.Miner.NewMinerAddress().String(),
833+
Addr: ht.NewMinerAddress().String(),
834834
SendAll: true,
835835
Label: sendCoinsLabel,
836836
TargetConf: 6,
@@ -930,7 +930,7 @@ func testSweepAllCoins(ht *lntest.HarnessTest) {
930930
// If we try again, but this time specifying an amount, then the call
931931
// should fail.
932932
ainz.RPC.SendCoinsAssertErr(&lnrpc.SendCoinsRequest{
933-
Addr: ht.Miner.NewMinerAddress().String(),
933+
Addr: ht.NewMinerAddress().String(),
934934
Amount: 10000,
935935
SendAll: true,
936936
Label: sendCoinsLabel,

itest/lnd_multi-hop_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ func runMultiHopHtlcLocalTimeout(ht *lntest.HarnessTest,
339339
// TODO(yy): remove this once `blockbeat` is in place.
340340
numExpected := 1
341341
err := wait.NoError(func() error {
342-
mem := ht.Miner.GetRawMempool()
342+
mem := ht.GetRawMempool()
343343
if len(mem) == 2 {
344344
numExpected = 2
345345
return nil
@@ -2120,7 +2120,7 @@ func runMultiHopHtlcAggregation(ht *lntest.HarnessTest,
21202120
// TODO(yy): remove this once `blockbeat` is in place.
21212121
numExpected := 1
21222122
err := wait.NoError(func() error {
2123-
mem := ht.Miner.GetRawMempool()
2123+
mem := ht.GetRawMempool()
21242124
if len(mem) == numExpected {
21252125
return nil
21262126
}

itest/lnd_nonstd_sweep_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ func testNonStdSweepInner(ht *lntest.HarnessTest, address string) {
9797

9898
// Fetch the txid so we can grab the raw transaction.
9999
txid := ht.AssertNumTxsInMempool(1)[0]
100-
tx := ht.Miner.GetRawTransaction(txid)
100+
tx := ht.GetRawTransaction(txid)
101101

102102
msgTx := tx.MsgTx()
103103

@@ -111,7 +111,7 @@ func testNonStdSweepInner(ht *lntest.HarnessTest, address string) {
111111
for _, inp := range msgTx.TxIn {
112112
// Fetch the previous outpoint's value.
113113
prevOut := inp.PreviousOutPoint
114-
ptx := ht.Miner.GetRawTransaction(&prevOut.Hash)
114+
ptx := ht.GetRawTransaction(&prevOut.Hash)
115115

116116
pout := ptx.MsgTx().TxOut[prevOut.Index]
117117
inputVal += int(pout.Value)

itest/lnd_onchain_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ func testAnchorReservedValue(ht *lntest.HarnessTest) {
321321

322322
// Alice tries to send all funds to an external address, the reserved
323323
// value must stay in her wallet.
324-
minerAddr := ht.Miner.NewMinerAddress()
324+
minerAddr := ht.NewMinerAddress()
325325

326326
sweepReq = &lnrpc.SendCoinsRequest{
327327
Addr: minerAddr.String(),
@@ -544,7 +544,7 @@ func testAnchorThirdPartySpend(ht *lntest.HarnessTest) {
544544
// With the anchor output located, and the main commitment mined we'll
545545
// instruct the wallet to send all coins in the wallet to a new address
546546
// (to the miner), including unconfirmed change.
547-
minerAddr := ht.Miner.NewMinerAddress()
547+
minerAddr := ht.NewMinerAddress()
548548
sweepReq := &lnrpc.SendCoinsRequest{
549549
Addr: minerAddr.String(),
550550
SendAll: true,
@@ -574,7 +574,7 @@ func testAnchorThirdPartySpend(ht *lntest.HarnessTest) {
574574
// mine a transaction that double spends the output.
575575
thirdPartyAnchorSweep := genAnchorSweep(ht, aliceSweep, anchor.Outpoint)
576576
ht.Logf("Third party tx=%v", thirdPartyAnchorSweep.TxHash())
577-
ht.Miner.MineBlockWithTx(thirdPartyAnchorSweep)
577+
ht.MineBlockWithTx(thirdPartyAnchorSweep)
578578

579579
// At this point, we should no longer find Alice's transaction that
580580
// tried to sweep the anchor in her wallet.
@@ -673,7 +673,7 @@ func genAnchorSweep(ht *lntest.HarnessTest, aliceSweep *wire.MsgTx,
673673
aliceAnchorTxIn.Witness[0] = nil
674674
aliceAnchorTxIn.Sequence = 16
675675

676-
minerAddr := ht.Miner.NewMinerAddress()
676+
minerAddr := ht.NewMinerAddress()
677677
addrScript, err := txscript.PayToAddrScript(minerAddr)
678678
require.NoError(ht, err, "unable to gen addr script")
679679

@@ -766,7 +766,7 @@ func testRemoveTx(ht *lntest.HarnessTest) {
766766
// Mine a block and make sure the transaction previously broadcasted
767767
// shows up in alice's wallet although we removed the transaction from
768768
// the wallet when it was unconfirmed.
769-
block := ht.Miner.MineBlocks(1)[0]
769+
block := ht.MineBlocksAndAssertNumTxes(1, 1)[0]
770770
ht.AssertTxInBlock(block, txID)
771771

772772
// Verify that alice has 2 confirmed unspent utxos in her default

itest/lnd_open_channel_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func testOpenChannelAfterReorg(ht *lntest.HarnessTest) {
3030
}
3131

3232
// Create a temp miner.
33-
tempMiner := ht.Miner.SpawnTempMiner()
33+
tempMiner := ht.SpawnTempMiner()
3434

3535
miner := ht.Miner
3636
alice, bob := ht.Alice, ht.Bob

itest/lnd_psbt_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ func runPsbtChanFundingExternal(ht *lntest.HarnessTest, carol,
464464
require.NoError(ht, err)
465465

466466
txHash := finalTx.TxHash()
467-
_, err = ht.Miner.Client.SendRawTransaction(&finalTx, false)
467+
_, err = ht.SendRawTransaction(&finalTx, false)
468468
require.NoError(ht, err)
469469

470470
// Now we can mine a block to get the transaction confirmed, then wait

itest/lnd_recovery_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ func testOnchainFundRecovery(ht *lntest.HarnessTest) {
252252
promptChangeAddr := func(node *node.HarnessNode) {
253253
ht.Helper()
254254

255-
minerAddr := ht.Miner.NewMinerAddress()
255+
minerAddr := ht.NewMinerAddress()
256256
req := &lnrpc.SendCoinsRequest{
257257
Addr: minerAddr.String(),
258258
Amount: minerAmt,

0 commit comments

Comments
 (0)