diff --git a/itest/lnd_channel_force_close_test.go b/itest/lnd_channel_force_close_test.go index 7284a315e..529622645 100644 --- a/itest/lnd_channel_force_close_test.go +++ b/itest/lnd_channel_force_close_test.go @@ -393,7 +393,7 @@ func channelForceClosureTest(ht *lntest.HarnessTest, // Fetch the sweep transaction, all input it's spending should be from // the commitment transaction which was broadcast on-chain. - sweepTx := ht.Miner.GetRawTransaction(sweepingTXID) + sweepTx := ht.GetRawTransaction(sweepingTXID) for _, txIn := range sweepTx.MsgTx().TxIn { require.Equal(ht, &txIn.PreviousOutPoint.Hash, closingTxID, "sweep transaction not spending from commit") @@ -567,7 +567,7 @@ func channelForceClosureTest(ht *lntest.HarnessTest, // on-chain. In case of an anchor type channel, we expect one // extra input that is not spending from the commitment, that // is added for fees. - htlcTx := ht.Miner.GetRawTransaction(htlcTxID) + htlcTx := ht.GetRawTransaction(htlcTxID) // Ensure the htlc transaction has the expected number of // inputs. @@ -736,7 +736,7 @@ func channelForceClosureTest(ht *lntest.HarnessTest, htlcSweepTxID := ht.AssertNumTxsInMempool(1)[0] // Fetch the htlc sweep transaction from the mempool. - htlcSweepTx := ht.Miner.GetRawTransaction(htlcSweepTxID) + htlcSweepTx := ht.GetRawTransaction(htlcSweepTxID) // Ensure the htlc sweep transaction only has one input for each htlc // Alice extended before force closing. diff --git a/itest/lnd_channel_funding_fund_max_test.go b/itest/lnd_channel_funding_fund_max_test.go index fb1987705..b836bdf62 100644 --- a/itest/lnd_channel_funding_fund_max_test.go +++ b/itest/lnd_channel_funding_fund_max_test.go @@ -15,7 +15,6 @@ import ( "github.com/lightningnetwork/lnd/lnwallet" "github.com/lightningnetwork/lnd/lnwallet/chainfee" "github.com/lightningnetwork/lnd/lnwire" - "github.com/stretchr/testify/require" ) type chanFundMaxTestCase struct { @@ -317,8 +316,7 @@ func fundingFee(numInput int, change bool) btcutil.Amount { // sweepNodeWalletAndAssert sweeps funds from a node wallet. func sweepNodeWalletAndAssert(ht *lntest.HarnessTest, node *node.HarnessNode) { // New miner address we will sweep all funds to. - minerAddr, err := ht.Miner.NewAddress() - require.NoError(ht, err) + minerAddr := ht.NewMinerAddress() // Send all funds back to the miner node. node.RPC.SendCoins(&lnrpc.SendCoinsRequest{ diff --git a/itest/lnd_funding_test.go b/itest/lnd_funding_test.go index de785c455..8b19b1c16 100644 --- a/itest/lnd_funding_test.go +++ b/itest/lnd_funding_test.go @@ -1053,7 +1053,7 @@ func testBatchChanFunding(ht *lntest.HarnessTest) { ht.AssertTopologyChannelOpen(alice, chanPoint3) // Check if the change type from the batch_open_channel funding is P2TR. - rawTx := ht.Miner.GetRawTransaction(txHash) + rawTx := ht.GetRawTransaction(txHash) require.Len(ht, rawTx.MsgTx().TxOut, 5) // 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, var txid *chainhash.Hash targetOutputs := []*wire.TxOut{fundingOutput} if publish { - txid = ht.Miner.SendOutputsWithoutChange(targetOutputs, 5) + txid = ht.SendOutputsWithoutChange(targetOutputs, 5) } else { - tx := ht.Miner.CreateTransaction(targetOutputs, 5) + tx := ht.CreateTransaction(targetOutputs, 5) txHash := tx.TxHash() txid = &txHash diff --git a/itest/lnd_misc_test.go b/itest/lnd_misc_test.go index ba242ac8e..cf3220eab 100644 --- a/itest/lnd_misc_test.go +++ b/itest/lnd_misc_test.go @@ -823,14 +823,14 @@ func testSweepAllCoins(ht *lntest.HarnessTest) { // Send coins to a compatible address without specifying fee rate or // conf target. // ainz.RPC.SendCoinsAssertErr(&lnrpc.SendCoinsRequest{ - // Addr: ht.Miner.NewMinerAddress().String(), + // Addr: ht.NewMinerAddress().String(), // SendAll: true, // Label: sendCoinsLabel, // }) // Send coins to a compatible address. ainz.RPC.SendCoins(&lnrpc.SendCoinsRequest{ - Addr: ht.Miner.NewMinerAddress().String(), + Addr: ht.NewMinerAddress().String(), SendAll: true, Label: sendCoinsLabel, TargetConf: 6, @@ -930,7 +930,7 @@ func testSweepAllCoins(ht *lntest.HarnessTest) { // If we try again, but this time specifying an amount, then the call // should fail. ainz.RPC.SendCoinsAssertErr(&lnrpc.SendCoinsRequest{ - Addr: ht.Miner.NewMinerAddress().String(), + Addr: ht.NewMinerAddress().String(), Amount: 10000, SendAll: true, Label: sendCoinsLabel, diff --git a/itest/lnd_multi-hop_test.go b/itest/lnd_multi-hop_test.go index 39d7672a9..9c5959efd 100644 --- a/itest/lnd_multi-hop_test.go +++ b/itest/lnd_multi-hop_test.go @@ -339,7 +339,7 @@ func runMultiHopHtlcLocalTimeout(ht *lntest.HarnessTest, // TODO(yy): remove this once `blockbeat` is in place. numExpected := 1 err := wait.NoError(func() error { - mem := ht.Miner.GetRawMempool() + mem := ht.GetRawMempool() if len(mem) == 2 { numExpected = 2 return nil @@ -2120,7 +2120,7 @@ func runMultiHopHtlcAggregation(ht *lntest.HarnessTest, // TODO(yy): remove this once `blockbeat` is in place. numExpected := 1 err := wait.NoError(func() error { - mem := ht.Miner.GetRawMempool() + mem := ht.GetRawMempool() if len(mem) == numExpected { return nil } diff --git a/itest/lnd_nonstd_sweep_test.go b/itest/lnd_nonstd_sweep_test.go index 6285fbdd6..6626766d7 100644 --- a/itest/lnd_nonstd_sweep_test.go +++ b/itest/lnd_nonstd_sweep_test.go @@ -97,7 +97,7 @@ func testNonStdSweepInner(ht *lntest.HarnessTest, address string) { // Fetch the txid so we can grab the raw transaction. txid := ht.AssertNumTxsInMempool(1)[0] - tx := ht.Miner.GetRawTransaction(txid) + tx := ht.GetRawTransaction(txid) msgTx := tx.MsgTx() @@ -111,7 +111,7 @@ func testNonStdSweepInner(ht *lntest.HarnessTest, address string) { for _, inp := range msgTx.TxIn { // Fetch the previous outpoint's value. prevOut := inp.PreviousOutPoint - ptx := ht.Miner.GetRawTransaction(&prevOut.Hash) + ptx := ht.GetRawTransaction(&prevOut.Hash) pout := ptx.MsgTx().TxOut[prevOut.Index] inputVal += int(pout.Value) diff --git a/itest/lnd_onchain_test.go b/itest/lnd_onchain_test.go index 15aececd9..11abbdbb7 100644 --- a/itest/lnd_onchain_test.go +++ b/itest/lnd_onchain_test.go @@ -321,7 +321,7 @@ func testAnchorReservedValue(ht *lntest.HarnessTest) { // Alice tries to send all funds to an external address, the reserved // value must stay in her wallet. - minerAddr := ht.Miner.NewMinerAddress() + minerAddr := ht.NewMinerAddress() sweepReq = &lnrpc.SendCoinsRequest{ Addr: minerAddr.String(), @@ -544,7 +544,7 @@ func testAnchorThirdPartySpend(ht *lntest.HarnessTest) { // With the anchor output located, and the main commitment mined we'll // instruct the wallet to send all coins in the wallet to a new address // (to the miner), including unconfirmed change. - minerAddr := ht.Miner.NewMinerAddress() + minerAddr := ht.NewMinerAddress() sweepReq := &lnrpc.SendCoinsRequest{ Addr: minerAddr.String(), SendAll: true, @@ -574,7 +574,7 @@ func testAnchorThirdPartySpend(ht *lntest.HarnessTest) { // mine a transaction that double spends the output. thirdPartyAnchorSweep := genAnchorSweep(ht, aliceSweep, anchor.Outpoint) ht.Logf("Third party tx=%v", thirdPartyAnchorSweep.TxHash()) - ht.Miner.MineBlockWithTx(thirdPartyAnchorSweep) + ht.MineBlockWithTx(thirdPartyAnchorSweep) // At this point, we should no longer find Alice's transaction that // tried to sweep the anchor in her wallet. @@ -673,7 +673,7 @@ func genAnchorSweep(ht *lntest.HarnessTest, aliceSweep *wire.MsgTx, aliceAnchorTxIn.Witness[0] = nil aliceAnchorTxIn.Sequence = 16 - minerAddr := ht.Miner.NewMinerAddress() + minerAddr := ht.NewMinerAddress() addrScript, err := txscript.PayToAddrScript(minerAddr) require.NoError(ht, err, "unable to gen addr script") @@ -766,7 +766,7 @@ func testRemoveTx(ht *lntest.HarnessTest) { // Mine a block and make sure the transaction previously broadcasted // shows up in alice's wallet although we removed the transaction from // the wallet when it was unconfirmed. - block := ht.Miner.MineBlocks(1)[0] + block := ht.MineBlocksAndAssertNumTxes(1, 1)[0] ht.AssertTxInBlock(block, txID) // Verify that alice has 2 confirmed unspent utxos in her default diff --git a/itest/lnd_open_channel_test.go b/itest/lnd_open_channel_test.go index 04179d1cf..1ebc9fbf4 100644 --- a/itest/lnd_open_channel_test.go +++ b/itest/lnd_open_channel_test.go @@ -30,7 +30,7 @@ func testOpenChannelAfterReorg(ht *lntest.HarnessTest) { } // Create a temp miner. - tempMiner := ht.Miner.SpawnTempMiner() + tempMiner := ht.SpawnTempMiner() miner := ht.Miner alice, bob := ht.Alice, ht.Bob diff --git a/itest/lnd_psbt_test.go b/itest/lnd_psbt_test.go index fe3e3a1d6..9ed729524 100644 --- a/itest/lnd_psbt_test.go +++ b/itest/lnd_psbt_test.go @@ -464,7 +464,7 @@ func runPsbtChanFundingExternal(ht *lntest.HarnessTest, carol, require.NoError(ht, err) txHash := finalTx.TxHash() - _, err = ht.Miner.Client.SendRawTransaction(&finalTx, false) + _, err = ht.SendRawTransaction(&finalTx, false) require.NoError(ht, err) // Now we can mine a block to get the transaction confirmed, then wait diff --git a/itest/lnd_recovery_test.go b/itest/lnd_recovery_test.go index 1bb3eded7..ccc5f90af 100644 --- a/itest/lnd_recovery_test.go +++ b/itest/lnd_recovery_test.go @@ -252,7 +252,7 @@ func testOnchainFundRecovery(ht *lntest.HarnessTest) { promptChangeAddr := func(node *node.HarnessNode) { ht.Helper() - minerAddr := ht.Miner.NewMinerAddress() + minerAddr := ht.NewMinerAddress() req := &lnrpc.SendCoinsRequest{ Addr: minerAddr.String(), Amount: minerAmt, diff --git a/itest/lnd_revocation_test.go b/itest/lnd_revocation_test.go index 4b6f457ca..f5d07b492 100644 --- a/itest/lnd_revocation_test.go +++ b/itest/lnd_revocation_test.go @@ -570,13 +570,13 @@ func revokedCloseRetributionRemoteHodlCase(ht *lntest.HarnessTest, var justiceTxid *chainhash.Hash errNotFound := errors.New("justice tx not found") findJusticeTx := func() (*chainhash.Hash, error) { - mempool := ht.Miner.GetRawMempool() + mempool := ht.GetRawMempool() for _, txid := range mempool { // Check that the justice tx has the appropriate number // of inputs. // - // NOTE: We don't use `ht.Miner.GetRawTransaction` + // NOTE: We don't use `ht.GetRawTransaction` // which asserts a txid must be found as the HTLC // spending txes might be aggregated. tx, err := ht.Miner.Client.GetRawTransaction(txid) @@ -626,14 +626,14 @@ func revokedCloseRetributionRemoteHodlCase(ht *lntest.HarnessTest, } require.NoError(ht, err, "timeout finding justice tx") - justiceTx := ht.Miner.GetRawTransaction(justiceTxid) + justiceTx := ht.GetRawTransaction(justiceTxid) // isSecondLevelSpend checks that the passed secondLevelTxid is a // potentitial second level spend spending from the commit tx. isSecondLevelSpend := func(commitTxid, secondLevelTxid *chainhash.Hash) bool { - secondLevel := ht.Miner.GetRawTransaction(secondLevelTxid) + secondLevel := ht.GetRawTransaction(secondLevelTxid) // A second level spend should have only one input, and one // output. diff --git a/itest/lnd_route_blinding_test.go b/itest/lnd_route_blinding_test.go index d4e4faab0..a2899657b 100644 --- a/itest/lnd_route_blinding_test.go +++ b/itest/lnd_route_blinding_test.go @@ -1010,7 +1010,7 @@ func testErrorHandlingOnChainFailure(ht *lntest.HarnessTest) { ht.MineBlocks(node.DefaultCSV - 1) ht.AssertNumPendingSweeps(ht.Bob, 1) ht.MineEmptyBlocks(1) - ht.Miner.MineBlocksAndAssertNumTxes(1, 1) + ht.MineBlocksAndAssertNumTxes(1, 1) // Restart bob so that we can test that he's able to recover everything // he needs to claim a blinded HTLC. @@ -1026,8 +1026,8 @@ func testErrorHandlingOnChainFailure(ht *lntest.HarnessTest) { // Wait for Bob's timeout transaction in the mempool, since we've // suspended Carol we don't need to account for her commitment output // claim. - ht.Miner.MineBlocksAndAssertNumTxes(1, 1) ht.AssertNumPendingSweeps(ht.Bob, 0) + ht.MineBlocksAndAssertNumTxes(1, 1) // Assert that the HTLC has cleared. ht.WaitForBlockchainSync(ht.Bob) @@ -1049,7 +1049,7 @@ func testErrorHandlingOnChainFailure(ht *lntest.HarnessTest) { // Clean up the rest of our force close: mine blocks so that Bob's CSV // expires plus one block to trigger his sweep and then mine it. ht.MineBlocks(node.DefaultCSV + 1) - ht.Miner.MineBlocksAndAssertNumTxes(1, 1) + ht.MineBlocksAndAssertNumTxes(1, 1) // Bring carol back up so that we can close out the rest of our // channels cooperatively. She requires an interceptor to start up diff --git a/itest/lnd_sweep_test.go b/itest/lnd_sweep_test.go index 950b5e460..7a648ec4e 100644 --- a/itest/lnd_sweep_test.go +++ b/itest/lnd_sweep_test.go @@ -168,7 +168,7 @@ func testSweepCPFPAnchorOutgoingTimeout(ht *lntest.HarnessTest) { ht.MineEmptyBlocks(int(numBlocks)) // Assert Bob's force closing tx has been broadcast. - closeTxid := ht.Miner.AssertNumTxsInMempool(1)[0] + closeTxid := ht.AssertNumTxsInMempool(1)[0] // Remember the force close height so we can calculate the deadline // height. @@ -517,7 +517,7 @@ func testSweepCPFPAnchorIncomingTimeout(ht *lntest.HarnessTest) { ht.MineEmptyBlocks(int(numBlocks)) // Assert Bob's force closing tx has been broadcast. - closeTxid := ht.Miner.AssertNumTxsInMempool(1)[0] + closeTxid := ht.AssertNumTxsInMempool(1)[0] // Bob should have two pending sweeps, // - anchor sweeping from his local commitment. @@ -546,7 +546,7 @@ func testSweepCPFPAnchorIncomingTimeout(ht *lntest.HarnessTest) { // // We should see Bob's anchor sweeping tx triggered by the above // block, along with his force close tx. - txns := ht.Miner.GetNumTxsFromMempool(2) + txns := ht.GetNumTxsFromMempool(2) // Find the sweeping tx. sweepTx := ht.FindSweepingTxns(txns, 1, *closeTxid)[0] @@ -598,12 +598,12 @@ func testSweepCPFPAnchorIncomingTimeout(ht *lntest.HarnessTest) { // Make sure Bob's old sweeping tx has been removed from the // mempool. - ht.Miner.AssertTxNotInMempool(sweepTx.TxHash()) + ht.AssertTxNotInMempool(sweepTx.TxHash()) // We expect to see two txns in the mempool, // - Bob's force close tx. // - Bob's anchor sweep tx. - ht.Miner.AssertNumTxsInMempool(2) + ht.AssertNumTxsInMempool(2) // We expect the fees to increase by i*delta. expectedFee := startFeeAnchor + feeDelta.MulF64(float64(i)) @@ -613,7 +613,7 @@ func testSweepCPFPAnchorIncomingTimeout(ht *lntest.HarnessTest) { // We should see Bob's anchor sweeping tx being fee bumped // since it's not confirmed, along with his force close tx. - txns = ht.Miner.GetNumTxsFromMempool(2) + txns = ht.GetNumTxsFromMempool(2) // Find the sweeping tx. sweepTx = ht.FindSweepingTxns(txns, 1, *closeTxid)[0] @@ -648,11 +648,11 @@ func testSweepCPFPAnchorIncomingTimeout(ht *lntest.HarnessTest) { ht.MineEmptyBlocks(1) // Make sure Bob's old sweeping tx has been removed from the mempool. - ht.Miner.AssertTxNotInMempool(sweepTx.TxHash()) + ht.AssertTxNotInMempool(sweepTx.TxHash()) // Get the last sweeping tx - we should see two txns here, Bob's anchor // sweeping tx and his force close tx. - txns = ht.Miner.GetNumTxsFromMempool(2) + txns = ht.GetNumTxsFromMempool(2) // Find the sweeping tx. sweepTx = ht.FindSweepingTxns(txns, 1, *closeTxid)[0] @@ -673,7 +673,7 @@ func testSweepCPFPAnchorIncomingTimeout(ht *lntest.HarnessTest) { // // We expect two txns here, one for the anchor sweeping, the other for // the force close tx. - txns = ht.Miner.GetNumTxsFromMempool(2) + txns = ht.GetNumTxsFromMempool(2) // Find the sweeping tx. currentSweepTx := ht.FindSweepingTxns(txns, 1, *closeTxid)[0] @@ -1029,7 +1029,7 @@ func testSweepHTLCs(ht *lntest.HarnessTest) { // We don't care the behavior of the anchor sweep in this test, so we // mine the force close tx to trigger Bob's contractcourt to offer his // incoming HTLC to his sweeper. - ht.Miner.MineBlockWithTx(closeTx) + ht.MineBlockWithTx(closeTx) // Update Bob's fee function position. outgoingFuncPosition++ @@ -1088,7 +1088,7 @@ func testSweepHTLCs(ht *lntest.HarnessTest) { incomingFuncPosition := int32(0) // Mine the anchor sweeping tx to reduce noise in this test. - ht.Miner.MineBlockWithTxes([]*btcutil.Tx{btcutil.NewTx(anchorSweep)}) + ht.MineBlockWithTx(anchorSweep) // Update the fee function's positions. outgoingFuncPosition++ @@ -1456,7 +1456,7 @@ func testSweepCommitOutputAndAnchor(ht *lntest.HarnessTest) { aliceStartPosition := 0 var aliceFirstSweepTx *wire.MsgTx err := wait.NoError(func() error { - mem := ht.Miner.GetRawMempool() + mem := ht.GetRawMempool() if len(mem) != 2 { return fmt.Errorf("want 2, got %v in mempool: %v", len(mem), mem) @@ -1486,7 +1486,7 @@ func testSweepCommitOutputAndAnchor(ht *lntest.HarnessTest) { // block would trigger an RBF. We now need to assert the mempool has // removed the replaced tx. if aliceFirstSweepTx != nil { - ht.Miner.AssertTxNotInMempool(aliceFirstSweepTx.TxHash()) + ht.AssertTxNotInMempool(aliceFirstSweepTx.TxHash()) } // We also remember the positions of fee functions used by Alice and @@ -1604,7 +1604,7 @@ func testSweepCommitOutputAndAnchor(ht *lntest.HarnessTest) { // Make sure Alice's old sweeping tx has been removed from the // mempool. - ht.Miner.AssertTxNotInMempool(aliceSweepTx.TxHash()) + ht.AssertTxNotInMempool(aliceSweepTx.TxHash()) // We should see two txns in the mempool: // - Alice's sweeping tx, which sweeps both her anchor and diff --git a/itest/lnd_taproot_test.go b/itest/lnd_taproot_test.go index 7dc5f4ad1..cea9ca833 100644 --- a/itest/lnd_taproot_test.go +++ b/itest/lnd_taproot_test.go @@ -1850,7 +1850,7 @@ func testTaprootCoopClose(ht *lntest.HarnessTest) { // assertTaprootDeliveryUsed returns true if a Taproot addr was used in // the co-op close transaction. assertTaprootDeliveryUsed := func(closingTxid *chainhash.Hash) bool { - tx := ht.Miner.GetRawTransaction(closingTxid) + tx := ht.GetRawTransaction(closingTxid) for _, txOut := range tx.MsgTx().TxOut { if !txscript.IsPayToTaproot(txOut.PkScript) { return false diff --git a/itest/lnd_watchtower_test.go b/itest/lnd_watchtower_test.go index ab724c0b6..4fee5d6c4 100644 --- a/itest/lnd_watchtower_test.go +++ b/itest/lnd_watchtower_test.go @@ -86,7 +86,7 @@ func testTowerClientTowerAndSessionManagement(ht *lntest.HarnessTest) { } if mineOnFail { - ht.Miner.MineBlocksSlow(1) + ht.MineBlocks(1) } return fmt.Errorf("expected %d sessions, got %d", @@ -515,7 +515,7 @@ func testRevokedCloseRetributionAltruistWatchtowerCase(ht *lntest.HarnessTest, // Query for the mempool transaction found above. Then assert that all // the inputs of this transaction are spending outputs generated by // Carol's breach transaction above. - justiceTx := ht.Miner.GetRawTransaction(justiceTXID) + justiceTx := ht.GetRawTransaction(justiceTXID) for _, txIn := range justiceTx.MsgTx().TxIn { require.Equal(ht, breachTXID[:], txIn.PreviousOutPoint.Hash[:], "justice tx not spending commitment utxo") @@ -702,7 +702,7 @@ func assertNumBackups(ht *lntest.HarnessTest, node *rpc.HarnessRPC, } if mineOnFail { - ht.Miner.MineBlocksSlow(1) + ht.MineBlocks(1) } return fmt.Errorf("expected %d backups, got %d", diff --git a/itest/lnd_zero_conf_test.go b/itest/lnd_zero_conf_test.go index 85e5a91ee..9af8b9703 100644 --- a/itest/lnd_zero_conf_test.go +++ b/itest/lnd_zero_conf_test.go @@ -950,7 +950,7 @@ func testZeroConfReorg(ht *lntest.HarnessTest) { // exists in the graph. // // First, we'll setup a new miner that we can use to cause a reorg. - tempMiner := ht.Miner.SpawnTempMiner() + tempMiner := ht.SpawnTempMiner() // We now cause a fork, by letting our original miner mine 1 block and // our new miner will mine 2. We also expect the funding transition to @@ -959,7 +959,7 @@ func testZeroConfReorg(ht *lntest.HarnessTest) { tempMiner.MineEmptyBlocks(2) // Ensure the temp miner is one block ahead. - ht.Miner.AssertMinerBlockHeightDelta(tempMiner, 1) + ht.AssertMinerBlockHeightDelta(tempMiner, 1) // Wait for Carol to sync to the original miner's chain. _, minerHeight := ht.GetBestBlock() @@ -972,14 +972,14 @@ func testZeroConfReorg(ht *lntest.HarnessTest) { // Connecting to the temporary miner should cause the original miner to // reorg to the longer chain. - ht.Miner.ConnectMiner(tempMiner) + ht.ConnectToMiner(tempMiner) // They should now be on the same chain. - ht.Miner.AssertMinerBlockHeightDelta(tempMiner, 0) + ht.AssertMinerBlockHeightDelta(tempMiner, 0) // Now we disconnect the two miners and reconnect our original chain // backend. - ht.Miner.DisconnectMiner(tempMiner) + ht.DisconnectFromMiner(tempMiner) ht.ConnectMiner() diff --git a/lntest/harness_miner.go b/lntest/harness_miner.go index 1148ea663..3ed782df6 100644 --- a/lntest/harness_miner.go +++ b/lntest/harness_miner.go @@ -4,8 +4,10 @@ import ( "fmt" "github.com/btcsuite/btcd/blockchain" + "github.com/btcsuite/btcd/btcutil" "github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/wire" + "github.com/lightningnetwork/lnd/lntest/miner" "github.com/lightningnetwork/lnd/lntest/node" "github.com/lightningnetwork/lnd/lntest/wait" "github.com/stretchr/testify/require" @@ -223,3 +225,77 @@ func (h *HarnessTest) GetNumTxsFromMempool(n int) []*wire.MsgTx { func (h *HarnessTest) GetBestBlock() (*chainhash.Hash, int32) { return h.Miner.GetBestBlock() } + +// MineBlockWithTx mines a single block to include the specifies tx only. +func (h *HarnessTest) MineBlockWithTx(tx *wire.MsgTx) *wire.MsgBlock { + return h.Miner.MineBlockWithTx(tx) +} + +// ConnectToMiner connects the miner to a temp miner. +func (h *HarnessTest) ConnectToMiner(tempMiner *miner.HarnessMiner) { + h.Miner.ConnectMiner(tempMiner) +} + +// DisconnectFromMiner disconnects the miner from the temp miner. +func (h *HarnessTest) DisconnectFromMiner(tempMiner *miner.HarnessMiner) { + h.Miner.DisconnectMiner(tempMiner) +} + +// GetRawMempool makes a RPC call to the miner's GetRawMempool and +// asserts. +func (h *HarnessTest) GetRawMempool() []*chainhash.Hash { + return h.Miner.GetRawMempool() +} + +// GetRawTransaction makes a RPC call to the miner's GetRawTransaction and +// asserts. +func (h *HarnessTest) GetRawTransaction(txid *chainhash.Hash) *btcutil.Tx { + return h.Miner.GetRawTransaction(txid) +} + +// NewMinerAddress creates a new address for the miner and asserts. +func (h *HarnessTest) NewMinerAddress() btcutil.Address { + return h.Miner.NewMinerAddress() +} + +// SpawnTempMiner creates a temp miner and syncs it with the current miner. +// Once miners are synced, the temp miner is disconnected from the original +// miner and returned. +func (h *HarnessTest) SpawnTempMiner() *miner.HarnessMiner { + return h.Miner.SpawnTempMiner() +} + +// CreateTransaction uses the miner to create a transaction using the given +// outputs using the specified fee rate and returns the transaction. +func (h *HarnessTest) CreateTransaction(outputs []*wire.TxOut, + feeRate btcutil.Amount) *wire.MsgTx { + + return h.Miner.CreateTransaction(outputs, feeRate) +} + +// SendOutputsWithoutChange uses the miner to send the given outputs using the +// specified fee rate and returns the txid. +func (h *HarnessTest) SendOutputsWithoutChange(outputs []*wire.TxOut, + feeRate btcutil.Amount) *chainhash.Hash { + + return h.Miner.SendOutputsWithoutChange(outputs, feeRate) +} + +// AssertMinerBlockHeightDelta ensures that tempMiner is 'delta' blocks ahead +// of miner. +func (h *HarnessTest) AssertMinerBlockHeightDelta( + tempMiner *miner.HarnessMiner, delta int32) { + + h.Miner.AssertMinerBlockHeightDelta(tempMiner, delta) +} + +// SendRawTransaction submits the encoded transaction to the server which will +// then relay it to the network. +func (h *HarnessTest) SendRawTransaction(tx *wire.MsgTx, + allowHighFees bool) (chainhash.Hash, error) { + + txid, err := h.Miner.Client.SendRawTransaction(tx, allowHighFees) + require.NoError(h, err) + + return *txid, nil +} diff --git a/lntest/miner/miner.go b/lntest/miner/miner.go index 0a81a07af..bc05f542f 100644 --- a/lntest/miner/miner.go +++ b/lntest/miner/miner.go @@ -410,7 +410,7 @@ func (h *HarnessMiner) AssertOutpointInMempool(op wire.OutPoint) *wire.MsgTx { } for _, txid := range mempool { - // We don't use `ht.Miner.GetRawTransaction` which + // We don't use `ht.GetRawTransaction` which // asserts a txid must be found. While iterating here, // the actual mempool state might have been changed, // causing a given txid being removed and cannot be