lntest+itest: make Miner a private instance

This commit is contained in:
yyforyongyu authored and yyforyongyu committed 2024-07-23 21:30:08 +08:00
1 parent be4dba5da6
commit 14e7b134d9
9 files changed
+61 -51

No files matched your search

+1 -1
View File
@@ -709,7 +709,7 @@ func channelForceClosureTest(ht *lntest.HarnessTest,
// NOTE: we don't check `len(mempool) == 1` because it will // NOTE: we don't check `len(mempool) == 1` because it will
// give us false positive. // give us false positive.
err := wait.NoError(func() error { err := wait.NoError(func() error {
mempool := ht.Miner.GetRawMempool() mempool := ht.Miner().GetRawMempool()
if len(mempool) == 2 { if len(mempool) == 2 {
return nil return nil
} }
+1 -1
View File
@@ -125,7 +125,7 @@ func testNonStdSweepInner(ht *lntest.HarnessTest, address string) {
// Fetch the vsize of the transaction so we can determine if the // Fetch the vsize of the transaction so we can determine if the
// transaction pays >= 1 sat/vbyte. // transaction pays >= 1 sat/vbyte.
rawTx := ht.Miner.GetRawTransactionVerbose(txid) rawTx := ht.Miner().GetRawTransactionVerbose(txid)
// Require fee >= vbytes. // Require fee >= vbytes.
require.True(ht, fee >= int(rawTx.Vsize)) require.True(ht, fee >= int(rawTx.Vsize))
+1 -1
View File
@@ -32,7 +32,7 @@ func testOpenChannelAfterReorg(ht *lntest.HarnessTest) {
// Create a temp miner. // Create a temp miner.
tempMiner := ht.SpawnTempMiner() tempMiner := ht.SpawnTempMiner()
miner := ht.Miner miner := ht.Miner()
alice, bob := ht.Alice, ht.Bob alice, bob := ht.Alice, ht.Bob
// Create a new channel that requires 1 confs before it's considered // Create a new channel that requires 1 confs before it's considered
+2 -2
View File
@@ -296,7 +296,7 @@ func wsTestCaseSubscription(ht *lntest.HarnessTest) {
}() }()
// Mine a block and make sure we get a message for it. // Mine a block and make sure we get a message for it.
blockHashes := ht.Miner.GenerateBlocks(1) blockHashes := ht.Miner().GenerateBlocks(1)
select { select {
case msg := <-msgChan: case msg := <-msgChan:
require.Equal( require.Equal(
@@ -388,7 +388,7 @@ func wsTestCaseSubscriptionMacaroon(ht *lntest.HarnessTest) {
}() }()
// Mine a block and make sure we get a message for it. // Mine a block and make sure we get a message for it.
blockHashes := ht.Miner.GenerateBlocks(1) blockHashes := ht.Miner().GenerateBlocks(1)
select { select {
case msg := <-msgChan: case msg := <-msgChan:
require.Equal( require.Equal(
+1 -1
View File
@@ -579,7 +579,7 @@ func revokedCloseRetributionRemoteHodlCase(ht *lntest.HarnessTest,
// NOTE: We don't use `ht.GetRawTransaction` // NOTE: We don't use `ht.GetRawTransaction`
// which asserts a txid must be found as the HTLC // which asserts a txid must be found as the HTLC
// spending txes might be aggregated. // spending txes might be aggregated.
tx, err := ht.Miner.Client.GetRawTransaction(txid) tx, err := ht.Miner().Client.GetRawTransaction(txid)
if err != nil { if err != nil {
return nil, err return nil, err
} }
+6 -6
View File
@@ -172,7 +172,7 @@ func testSweepCPFPAnchorOutgoingTimeout(ht *lntest.HarnessTest) {
// Remember the force close height so we can calculate the deadline // Remember the force close height so we can calculate the deadline
// height. // height.
_, forceCloseHeight := ht.Miner.GetBestBlock() _, forceCloseHeight := ht.GetBestBlock()
// Bob should have two pending sweeps, // Bob should have two pending sweeps,
// - anchor sweeping from his local commitment. // - anchor sweeping from his local commitment.
@@ -304,7 +304,7 @@ func testSweepCPFPAnchorOutgoingTimeout(ht *lntest.HarnessTest) {
// //
// Once out of the above loop, we expect to be 2 blocks before the CPFP // Once out of the above loop, we expect to be 2 blocks before the CPFP
// deadline. // deadline.
_, currentHeight := ht.Miner.GetBestBlock() _, currentHeight := ht.GetBestBlock()
require.Equal(ht, int(anchorDeadline-2), int(currentHeight)) require.Equal(ht, int(anchorDeadline-2), int(currentHeight))
// Mine one more block, we'd use up all the CPFP budget. // Mine one more block, we'd use up all the CPFP budget.
@@ -512,7 +512,7 @@ func testSweepCPFPAnchorIncomingTimeout(ht *lntest.HarnessTest) {
forceCloseHeight := htlc.ExpirationHeight - goToChainDelta forceCloseHeight := htlc.ExpirationHeight - goToChainDelta
// Mine till the goToChainHeight is reached. // Mine till the goToChainHeight is reached.
_, currentHeight := ht.Miner.GetBestBlock() _, currentHeight := ht.GetBestBlock()
numBlocks := forceCloseHeight - uint32(currentHeight) numBlocks := forceCloseHeight - uint32(currentHeight)
ht.MineEmptyBlocks(int(numBlocks)) ht.MineEmptyBlocks(int(numBlocks))
@@ -641,7 +641,7 @@ func testSweepCPFPAnchorIncomingTimeout(ht *lntest.HarnessTest) {
// //
// Once out of the above loop, we expect to be 2 blocks before the CPFP // Once out of the above loop, we expect to be 2 blocks before the CPFP
// deadline. // deadline.
_, currentHeight = ht.Miner.GetBestBlock() _, currentHeight = ht.GetBestBlock()
require.Equal(ht, int(anchorDeadline-2), int(currentHeight)) require.Equal(ht, int(anchorDeadline-2), int(currentHeight))
// Mine one more block, we'd use up all the CPFP budget. // Mine one more block, we'd use up all the CPFP budget.
@@ -1380,7 +1380,7 @@ func testSweepCommitOutputAndAnchor(ht *lntest.HarnessTest) {
// //
// TODO(yy): assert they are equal once blocks are synced via // TODO(yy): assert they are equal once blocks are synced via
// `blockbeat`. // `blockbeat`.
_, currentHeight := ht.Miner.GetBestBlock() _, currentHeight := ht.GetBestBlock()
actualDeadline := int32(pendingSweepBob.DeadlineHeight) - currentHeight actualDeadline := int32(pendingSweepBob.DeadlineHeight) - currentHeight
if actualDeadline != int32(deadlineB) { if actualDeadline != int32(deadlineB) {
ht.Logf("!!! Found unsynced block between sweeper and "+ ht.Logf("!!! Found unsynced block between sweeper and "+
@@ -1438,7 +1438,7 @@ func testSweepCommitOutputAndAnchor(ht *lntest.HarnessTest) {
// //
// TODO(yy): assert they are equal once blocks are synced via // TODO(yy): assert they are equal once blocks are synced via
// `blockbeat`. // `blockbeat`.
_, currentHeight = ht.Miner.GetBestBlock() _, currentHeight = ht.GetBestBlock()
actualDeadline = int32(aliceCommit.DeadlineHeight) - currentHeight actualDeadline = int32(aliceCommit.DeadlineHeight) - currentHeight
if actualDeadline != int32(deadlineA) { if actualDeadline != int32(deadlineA) {
ht.Logf("!!! Found unsynced block between Alice's sweeper and "+ ht.Logf("!!! Found unsynced block between Alice's sweeper and "+
+1 -1
View File
@@ -96,7 +96,7 @@ func testTaprootSendCoinsKeySpendBip86(ht *lntest.HarnessTest,
// Assert this is a segwit v1 address that starts with bcrt1p. // Assert this is a segwit v1 address that starts with bcrt1p.
require.Contains( require.Contains(
ht, p2trResp.Address, ht.Miner.ActiveNet.Bech32HRPSegwit+"1p", ht, p2trResp.Address, ht.Miner().ActiveNet.Bech32HRPSegwit+"1p",
) )
// Send the coins from Alice's wallet to her own, but to the new p2tr // Send the coins from Alice's wallet to her own, but to the new p2tr
+13 -13
View File
@@ -77,9 +77,9 @@ type HarnessTest struct {
// Embed the standbyNodes so we can easily access them via `ht.Alice`. // Embed the standbyNodes so we can easily access them via `ht.Alice`.
standbyNodes standbyNodes
// Miner is a reference to a running full node that can be used to // miner is a reference to a running full node that can be used to
// create new blocks on the network. // create new blocks on the network.
Miner *miner.HarnessMiner miner *miner.HarnessMiner
// manager handles the start and stop of a given node. // manager handles the start and stop of a given node.
manager *nodeManager manager *nodeManager
@@ -188,7 +188,7 @@ func (h *HarnessTest) Start(chain node.BackendConfig,
h.manager.feeServiceURL = h.feeService.URL() h.manager.feeServiceURL = h.feeService.URL()
// Assemble the miner. // Assemble the miner.
h.Miner = miner h.miner = miner
} }
// ChainBackendName returns the chain backend name used in the test. // ChainBackendName returns the chain backend name used in the test.
@@ -254,7 +254,7 @@ func (h *HarnessTest) createAndSendOutput(target *node.HarnessNode,
PkScript: addrScript, PkScript: addrScript,
Value: int64(amt), Value: int64(amt),
} }
h.Miner.SendOutput(output, defaultMinerFeeRate) h.miner.SendOutput(output, defaultMinerFeeRate)
} }
// SetupRemoteSigningStandbyNodes starts the initial seeder nodes within the // SetupRemoteSigningStandbyNodes starts the initial seeder nodes within the
@@ -371,7 +371,7 @@ func (h *HarnessTest) Stop() {
h.stopChainBackend() h.stopChainBackend()
// Stop the miner. // Stop the miner.
h.Miner.Stop() h.miner.Stop()
} }
// RunTestCase executes a harness test case. Any errors or panics will be // RunTestCase executes a harness test case. Any errors or panics will be
@@ -414,7 +414,7 @@ func (h *HarnessTest) Subtest(t *testing.T) *HarnessTest {
st := &HarnessTest{ st := &HarnessTest{
T: t, T: t,
manager: h.manager, manager: h.manager,
Miner: h.Miner, miner: h.miner,
standbyNodes: h.standbyNodes, standbyNodes: h.standbyNodes,
feeService: h.feeService, feeService: h.feeService,
lndErrorChan: make(chan error, lndErrorChanSize), lndErrorChan: make(chan error, lndErrorChanSize),
@@ -424,7 +424,7 @@ func (h *HarnessTest) Subtest(t *testing.T) *HarnessTest {
st.runCtx, st.cancel = context.WithCancel(h.runCtx) st.runCtx, st.cancel = context.WithCancel(h.runCtx)
// Inherit the subtest for the miner. // Inherit the subtest for the miner.
st.Miner.T = st.T st.miner.T = st.T
// Reset the standby nodes. // Reset the standby nodes.
st.resetStandbyNodes(t) st.resetStandbyNodes(t)
@@ -467,7 +467,7 @@ func (h *HarnessTest) Subtest(t *testing.T) *HarnessTest {
st.shutdownNonStandbyNodes() st.shutdownNonStandbyNodes()
// We require the mempool to be cleaned from the test. // We require the mempool to be cleaned from the test.
require.Empty(st, st.Miner.GetRawMempool(), "mempool not "+ require.Empty(st, st.miner.GetRawMempool(), "mempool not "+
"cleaned, please mine blocks to clean them all.") "cleaned, please mine blocks to clean them all.")
// Finally, cancel the run context. We have to do it here // Finally, cancel the run context. We have to do it here
@@ -1298,7 +1298,7 @@ func (h *HarnessTest) CloseChannelAssertPending(hn *node.HarnessNode,
pendingClose.ClosePending.Txid) pendingClose.ClosePending.Txid)
// Assert the closing tx is in the mempool. // Assert the closing tx is in the mempool.
h.Miner.AssertTxInMempool(closeTxid) h.miner.AssertTxInMempool(closeTxid)
return stream, closeTxid return stream, closeTxid
} }
@@ -1396,7 +1396,7 @@ func (h *HarnessTest) fundCoins(amt btcutil.Amount, target *node.HarnessNode,
PkScript: addrScript, PkScript: addrScript,
Value: int64(amt), Value: int64(amt),
} }
h.Miner.SendOutput(output, defaultMinerFeeRate) h.miner.SendOutput(output, defaultMinerFeeRate)
// Encode the pkScript in hex as this the format that it will be // Encode the pkScript in hex as this the format that it will be
// returned via rpc. // returned via rpc.
@@ -1903,7 +1903,7 @@ func (h *HarnessTest) CalculateTxFee(tx *wire.MsgTx) btcutil.Amount {
var balance btcutil.Amount var balance btcutil.Amount
for _, in := range tx.TxIn { for _, in := range tx.TxIn {
parentHash := in.PreviousOutPoint.Hash parentHash := in.PreviousOutPoint.Hash
rawTx := h.Miner.GetRawTransaction(&parentHash) rawTx := h.miner.GetRawTransaction(&parentHash)
parent := rawTx.MsgTx() parent := rawTx.MsgTx()
value := parent.TxOut[in.PreviousOutPoint.Index].Value value := parent.TxOut[in.PreviousOutPoint.Index].Value
@@ -2121,12 +2121,12 @@ func (h *HarnessTest) ReceiveChannelEvent(
func (h *HarnessTest) GetOutputIndex(txid *chainhash.Hash, addr string) int { func (h *HarnessTest) GetOutputIndex(txid *chainhash.Hash, addr string) int {
// We'll then extract the raw transaction from the mempool in order to // We'll then extract the raw transaction from the mempool in order to
// determine the index of the p2tr output. // determine the index of the p2tr output.
tx := h.Miner.GetRawTransaction(txid) tx := h.miner.GetRawTransaction(txid)
p2trOutputIndex := -1 p2trOutputIndex := -1
for i, txOut := range tx.MsgTx().TxOut { for i, txOut := range tx.MsgTx().TxOut {
_, addrs, _, err := txscript.ExtractPkScriptAddrs( _, addrs, _, err := txscript.ExtractPkScriptAddrs(
txOut.PkScript, h.Miner.ActiveNet, txOut.PkScript, h.miner.ActiveNet,
) )
require.NoError(h, err) require.NoError(h, err)
+35 -25
View File
@@ -13,6 +13,16 @@ import (
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )
// Miner returns the miner instance.
//
// NOTE: Caller should keep in mind that when using this private instance,
// certain states won't be managed by the HarnessTest anymore. For instance,
// when mining directly, the nodes managed by the HarnessTest can be out of
// sync, and the `HarnessTest.CurrentHeight()` won't be accurate.
func (h *HarnessTest) Miner() *miner.HarnessMiner {
return h.miner
}
// MineBlocks mines blocks and asserts all active nodes have synced to the // MineBlocks mines blocks and asserts all active nodes have synced to the
// chain. It assumes no txns are expected in the blocks. // chain. It assumes no txns are expected in the blocks.
// //
@@ -23,7 +33,7 @@ func (h *HarnessTest) MineBlocks(num int) {
// Mine num of blocks. // Mine num of blocks.
for i := 0; i < num; i++ { for i := 0; i < num; i++ {
block := h.Miner.MineBlocks(1)[0] block := h.miner.MineBlocks(1)[0]
// Check the block doesn't have any txns except the coinbase. // Check the block doesn't have any txns except the coinbase.
if len(block.Transactions) <= 1 { if len(block.Transactions) <= 1 {
@@ -63,7 +73,7 @@ func (h *HarnessTest) MineBlocks(num int) {
func (h *HarnessTest) MineEmptyBlocks(num int) []*wire.MsgBlock { func (h *HarnessTest) MineEmptyBlocks(num int) []*wire.MsgBlock {
require.Less(h, num, maxBlocksAllowed, "too many blocks to mine") require.Less(h, num, maxBlocksAllowed, "too many blocks to mine")
blocks := h.Miner.MineEmptyBlocks(num) blocks := h.miner.MineEmptyBlocks(num)
// Finally, make sure all the active nodes are synced. // Finally, make sure all the active nodes are synced.
h.AssertActiveNodesSynced() h.AssertActiveNodesSynced()
@@ -85,16 +95,16 @@ func (h *HarnessTest) MineBlocksAndAssertNumTxes(num uint32,
txids := h.AssertNumTxsInMempool(numTxs) txids := h.AssertNumTxsInMempool(numTxs)
// Mine blocks. // Mine blocks.
blocks := h.Miner.MineBlocksSlow(num) blocks := h.miner.MineBlocksSlow(num)
// Assert that all the transactions were included in the first block. // Assert that all the transactions were included in the first block.
for _, txid := range txids { for _, txid := range txids {
h.Miner.AssertTxInBlock(blocks[0], txid) h.miner.AssertTxInBlock(blocks[0], txid)
} }
// Make sure the mempool has been updated. // Make sure the mempool has been updated.
for _, txid := range txids { for _, txid := range txids {
h.Miner.AssertTxNotInMempool(*txid) h.miner.AssertTxNotInMempool(*txid)
} }
// Finally, make sure all the active nodes are synced. // Finally, make sure all the active nodes are synced.
@@ -126,7 +136,7 @@ func (h *HarnessTest) cleanMempool() {
var bestBlock *wire.MsgBlock var bestBlock *wire.MsgBlock
err := wait.NoError(func() error { err := wait.NoError(func() error {
// If mempool is empty, exit. // If mempool is empty, exit.
mem := h.Miner.GetRawMempool() mem := h.miner.GetRawMempool()
if len(mem) == 0 { if len(mem) == 0 {
_, height := h.GetBestBlock() _, height := h.GetBestBlock()
h.Logf("Mined %d blocks when cleanup the mempool", h.Logf("Mined %d blocks when cleanup the mempool",
@@ -136,7 +146,7 @@ func (h *HarnessTest) cleanMempool() {
} }
// Otherwise mine a block. // Otherwise mine a block.
blocks := h.Miner.MineBlocksSlow(1) blocks := h.miner.MineBlocksSlow(1)
bestBlock = blocks[len(blocks)-1] bestBlock = blocks[len(blocks)-1]
// Make sure all the active nodes are synced. // Make sure all the active nodes are synced.
@@ -183,7 +193,7 @@ func (h *HarnessTest) mineTillForceCloseResolved(hn *node.HarnessNode) {
// AssertTxInMempool asserts a given transaction can be found in the mempool. // AssertTxInMempool asserts a given transaction can be found in the mempool.
func (h *HarnessTest) AssertTxInMempool(txid *chainhash.Hash) *wire.MsgTx { func (h *HarnessTest) AssertTxInMempool(txid *chainhash.Hash) *wire.MsgTx {
return h.Miner.AssertTxInMempool(txid) return h.miner.AssertTxInMempool(txid)
} }
// AssertTxNotInMempool asserts a given transaction cannot be found in the // AssertTxNotInMempool asserts a given transaction cannot be found in the
@@ -193,76 +203,76 @@ func (h *HarnessTest) AssertTxInMempool(txid *chainhash.Hash) *wire.MsgTx {
// entered the mempool before. Otherwise it might give false positive and the // entered the mempool before. Otherwise it might give false positive and the
// tx may enter the mempool after the check. // tx may enter the mempool after the check.
func (h *HarnessTest) AssertTxNotInMempool(txid chainhash.Hash) *wire.MsgTx { func (h *HarnessTest) AssertTxNotInMempool(txid chainhash.Hash) *wire.MsgTx {
return h.Miner.AssertTxNotInMempool(txid) return h.miner.AssertTxNotInMempool(txid)
} }
// AssertNumTxsInMempool polls until finding the desired number of transactions // AssertNumTxsInMempool polls until finding the desired number of transactions
// in the provided miner's mempool. It will asserrt if this number is not met // in the provided miner's mempool. It will asserrt if this number is not met
// after the given timeout. // after the given timeout.
func (h *HarnessTest) AssertNumTxsInMempool(n int) []*chainhash.Hash { func (h *HarnessTest) AssertNumTxsInMempool(n int) []*chainhash.Hash {
return h.Miner.AssertNumTxsInMempool(n) return h.miner.AssertNumTxsInMempool(n)
} }
// AssertOutpointInMempool asserts a given outpoint can be found in the mempool. // AssertOutpointInMempool asserts a given outpoint can be found in the mempool.
func (h *HarnessTest) AssertOutpointInMempool(op wire.OutPoint) *wire.MsgTx { func (h *HarnessTest) AssertOutpointInMempool(op wire.OutPoint) *wire.MsgTx {
return h.Miner.AssertOutpointInMempool(op) return h.miner.AssertOutpointInMempool(op)
} }
// AssertTxInBlock asserts that a given txid can be found in the passed block. // AssertTxInBlock asserts that a given txid can be found in the passed block.
func (h *HarnessTest) AssertTxInBlock(block *wire.MsgBlock, func (h *HarnessTest) AssertTxInBlock(block *wire.MsgBlock,
txid *chainhash.Hash) { txid *chainhash.Hash) {
h.Miner.AssertTxInBlock(block, txid) h.miner.AssertTxInBlock(block, txid)
} }
// GetNumTxsFromMempool polls until finding the desired number of transactions // GetNumTxsFromMempool polls until finding the desired number of transactions
// in the miner's mempool and returns the full transactions to the caller. // in the miner's mempool and returns the full transactions to the caller.
func (h *HarnessTest) GetNumTxsFromMempool(n int) []*wire.MsgTx { func (h *HarnessTest) GetNumTxsFromMempool(n int) []*wire.MsgTx {
return h.Miner.GetNumTxsFromMempool(n) return h.miner.GetNumTxsFromMempool(n)
} }
// GetBestBlock makes a RPC request to miner and asserts. // GetBestBlock makes a RPC request to miner and asserts.
func (h *HarnessTest) GetBestBlock() (*chainhash.Hash, int32) { func (h *HarnessTest) GetBestBlock() (*chainhash.Hash, int32) {
return h.Miner.GetBestBlock() return h.miner.GetBestBlock()
} }
// MineBlockWithTx mines a single block to include the specifies tx only. // MineBlockWithTx mines a single block to include the specifies tx only.
func (h *HarnessTest) MineBlockWithTx(tx *wire.MsgTx) *wire.MsgBlock { func (h *HarnessTest) MineBlockWithTx(tx *wire.MsgTx) *wire.MsgBlock {
return h.Miner.MineBlockWithTx(tx) return h.miner.MineBlockWithTx(tx)
} }
// ConnectToMiner connects the miner to a temp miner. // ConnectToMiner connects the miner to a temp miner.
func (h *HarnessTest) ConnectToMiner(tempMiner *miner.HarnessMiner) { func (h *HarnessTest) ConnectToMiner(tempMiner *miner.HarnessMiner) {
h.Miner.ConnectMiner(tempMiner) h.miner.ConnectMiner(tempMiner)
} }
// DisconnectFromMiner disconnects the miner from the temp miner. // DisconnectFromMiner disconnects the miner from the temp miner.
func (h *HarnessTest) DisconnectFromMiner(tempMiner *miner.HarnessMiner) { func (h *HarnessTest) DisconnectFromMiner(tempMiner *miner.HarnessMiner) {
h.Miner.DisconnectMiner(tempMiner) h.miner.DisconnectMiner(tempMiner)
} }
// GetRawMempool makes a RPC call to the miner's GetRawMempool and // GetRawMempool makes a RPC call to the miner's GetRawMempool and
// asserts. // asserts.
func (h *HarnessTest) GetRawMempool() []*chainhash.Hash { func (h *HarnessTest) GetRawMempool() []*chainhash.Hash {
return h.Miner.GetRawMempool() return h.miner.GetRawMempool()
} }
// GetRawTransaction makes a RPC call to the miner's GetRawTransaction and // GetRawTransaction makes a RPC call to the miner's GetRawTransaction and
// asserts. // asserts.
func (h *HarnessTest) GetRawTransaction(txid *chainhash.Hash) *btcutil.Tx { func (h *HarnessTest) GetRawTransaction(txid *chainhash.Hash) *btcutil.Tx {
return h.Miner.GetRawTransaction(txid) return h.miner.GetRawTransaction(txid)
} }
// NewMinerAddress creates a new address for the miner and asserts. // NewMinerAddress creates a new address for the miner and asserts.
func (h *HarnessTest) NewMinerAddress() btcutil.Address { func (h *HarnessTest) NewMinerAddress() btcutil.Address {
return h.Miner.NewMinerAddress() return h.miner.NewMinerAddress()
} }
// SpawnTempMiner creates a temp miner and syncs it with the current miner. // SpawnTempMiner creates a temp miner and syncs it with the current miner.
// Once miners are synced, the temp miner is disconnected from the original // Once miners are synced, the temp miner is disconnected from the original
// miner and returned. // miner and returned.
func (h *HarnessTest) SpawnTempMiner() *miner.HarnessMiner { func (h *HarnessTest) SpawnTempMiner() *miner.HarnessMiner {
return h.Miner.SpawnTempMiner() return h.miner.SpawnTempMiner()
} }
// CreateTransaction uses the miner to create a transaction using the given // CreateTransaction uses the miner to create a transaction using the given
@@ -270,7 +280,7 @@ func (h *HarnessTest) SpawnTempMiner() *miner.HarnessMiner {
func (h *HarnessTest) CreateTransaction(outputs []*wire.TxOut, func (h *HarnessTest) CreateTransaction(outputs []*wire.TxOut,
feeRate btcutil.Amount) *wire.MsgTx { feeRate btcutil.Amount) *wire.MsgTx {
return h.Miner.CreateTransaction(outputs, feeRate) return h.miner.CreateTransaction(outputs, feeRate)
} }
// SendOutputsWithoutChange uses the miner to send the given outputs using the // SendOutputsWithoutChange uses the miner to send the given outputs using the
@@ -278,7 +288,7 @@ func (h *HarnessTest) CreateTransaction(outputs []*wire.TxOut,
func (h *HarnessTest) SendOutputsWithoutChange(outputs []*wire.TxOut, func (h *HarnessTest) SendOutputsWithoutChange(outputs []*wire.TxOut,
feeRate btcutil.Amount) *chainhash.Hash { feeRate btcutil.Amount) *chainhash.Hash {
return h.Miner.SendOutputsWithoutChange(outputs, feeRate) return h.miner.SendOutputsWithoutChange(outputs, feeRate)
} }
// AssertMinerBlockHeightDelta ensures that tempMiner is 'delta' blocks ahead // AssertMinerBlockHeightDelta ensures that tempMiner is 'delta' blocks ahead
@@ -286,7 +296,7 @@ func (h *HarnessTest) SendOutputsWithoutChange(outputs []*wire.TxOut,
func (h *HarnessTest) AssertMinerBlockHeightDelta( func (h *HarnessTest) AssertMinerBlockHeightDelta(
tempMiner *miner.HarnessMiner, delta int32) { tempMiner *miner.HarnessMiner, delta int32) {
h.Miner.AssertMinerBlockHeightDelta(tempMiner, delta) h.miner.AssertMinerBlockHeightDelta(tempMiner, delta)
} }
// SendRawTransaction submits the encoded transaction to the server which will // SendRawTransaction submits the encoded transaction to the server which will
@@ -294,7 +304,7 @@ func (h *HarnessTest) AssertMinerBlockHeightDelta(
func (h *HarnessTest) SendRawTransaction(tx *wire.MsgTx, func (h *HarnessTest) SendRawTransaction(tx *wire.MsgTx,
allowHighFees bool) (chainhash.Hash, error) { allowHighFees bool) (chainhash.Hash, error) {
txid, err := h.Miner.Client.SendRawTransaction(tx, allowHighFees) txid, err := h.miner.Client.SendRawTransaction(tx, allowHighFees)
require.NoError(h, err) require.NoError(h, err)
return *txid, nil return *txid, nil