lntemp+lntest: always wait for nodes sync after mining blocks
In this commit, we introduce two mining methods, `MineBlocks` and `MineBlocksAndAssertNumTxes`, to `HarnessTest`. These methods are different from the miner's methods as they would 1) mine the blocks slowly and 2) assert all active nodes have synced. The miner's methods are kept for future tests such as mining blocks really fast and see the behavior of `lnd`.
This commit is contained in:
5 files changed
+125
-95
No files matched your search
+43
-21
@@ -194,7 +194,7 @@ func (h *HarnessTest) SetupStandbyNodes() {
|
|||||||
|
|
||||||
// We generate several blocks in order to give the outputs created
|
// We generate several blocks in order to give the outputs created
|
||||||
// above a good number of confirmations.
|
// above a good number of confirmations.
|
||||||
h.Miner.MineBlocks(2)
|
h.MineBlocks(2)
|
||||||
|
|
||||||
// Now we want to wait for the nodes to catch up.
|
// Now we want to wait for the nodes to catch up.
|
||||||
h.WaitForBlockchainSync(h.Alice)
|
h.WaitForBlockchainSync(h.Alice)
|
||||||
@@ -749,7 +749,7 @@ func (h *HarnessTest) OpenChannel(alice, bob *node.HarnessNode,
|
|||||||
// channel has been opened. The funding transaction should be found
|
// channel has been opened. The funding transaction should be found
|
||||||
// within the first newly mined block. We mine 6 blocks so that in the
|
// within the first newly mined block. We mine 6 blocks so that in the
|
||||||
// case that the channel is public, it is announced to the network.
|
// case that the channel is public, it is announced to the network.
|
||||||
block := h.Miner.MineBlocksAndAssertNumTxes(6, 1)[0]
|
block := h.MineBlocksAndAssertNumTxes(6, 1)[0]
|
||||||
|
|
||||||
// Wait for the channel open event.
|
// Wait for the channel open event.
|
||||||
fundingChanPoint := h.WaitForChannelOpenEvent(chanOpenUpdate)
|
fundingChanPoint := h.WaitForChannelOpenEvent(chanOpenUpdate)
|
||||||
@@ -938,7 +938,7 @@ func (h *HarnessTest) fundCoins(amt btcutil.Amount, target *node.HarnessNode,
|
|||||||
// Otherwise, we'll generate 1 new blocks to ensure the output gains a
|
// Otherwise, we'll generate 1 new blocks to ensure the output gains a
|
||||||
// sufficient number of confirmations and wait for the balance to
|
// sufficient number of confirmations and wait for the balance to
|
||||||
// reflect what's expected.
|
// reflect what's expected.
|
||||||
h.Miner.MineBlocks(1)
|
h.MineBlocks(1)
|
||||||
|
|
||||||
expectedBalance := btcutil.Amount(initialBalance.ConfirmedBalance) + amt
|
expectedBalance := btcutil.Amount(initialBalance.ConfirmedBalance) + amt
|
||||||
h.WaitForBalanceConfirmed(target, expectedBalance)
|
h.WaitForBalanceConfirmed(target, expectedBalance)
|
||||||
@@ -1091,11 +1091,11 @@ func (h *HarnessTest) CleanupForceClose(hn *node.HarnessNode,
|
|||||||
//
|
//
|
||||||
// The commit sweep resolver is able to broadcast the sweep tx up to
|
// The commit sweep resolver is able to broadcast the sweep tx up to
|
||||||
// one block before the CSV elapses, so wait until defaulCSV-1.
|
// one block before the CSV elapses, so wait until defaulCSV-1.
|
||||||
h.Miner.MineBlocks(lntest.DefaultCSV - 1)
|
h.MineBlocks(lntest.DefaultCSV - 1)
|
||||||
|
|
||||||
// The node should now sweep the funds, clean up by mining the sweeping
|
// The node should now sweep the funds, clean up by mining the sweeping
|
||||||
// tx.
|
// tx.
|
||||||
h.Miner.MineBlocksAndAssertNumTxes(1, 1)
|
h.MineBlocksAndAssertNumTxes(1, 1)
|
||||||
|
|
||||||
// Mine blocks to get any second level HTLC resolved. If there are no
|
// Mine blocks to get any second level HTLC resolved. If there are no
|
||||||
// HTLCs, this will behave like h.AssertNumPendingCloseChannels.
|
// HTLCs, this will behave like h.AssertNumPendingCloseChannels.
|
||||||
@@ -1120,7 +1120,7 @@ func (h *HarnessTest) mineTillForceCloseResolved(hn *node.HarnessNode) {
|
|||||||
resp := hn.RPC.PendingChannels()
|
resp := hn.RPC.PendingChannels()
|
||||||
total := len(resp.PendingForceClosingChannels)
|
total := len(resp.PendingForceClosingChannels)
|
||||||
if total != 0 {
|
if total != 0 {
|
||||||
h.Miner.MineBlocksSlow(1)
|
h.MineBlocks(1)
|
||||||
|
|
||||||
return fmt.Errorf("expected num of pending force " +
|
return fmt.Errorf("expected num of pending force " +
|
||||||
"close channel to be zero")
|
"close channel to be zero")
|
||||||
@@ -1191,22 +1191,44 @@ func (h *HarnessTest) RestartNodeAndRestoreDB(hn *node.HarnessNode) {
|
|||||||
h.WaitForBlockchainSync(hn)
|
h.WaitForBlockchainSync(hn)
|
||||||
}
|
}
|
||||||
|
|
||||||
// MineBlocksAssertNodesSync mines blocks and asserts all active nodes have
|
// MineBlocks mines blocks and asserts all active nodes have synced to the
|
||||||
// synced to the chain. Use this method when more than 3 blocks are mined to
|
// chain.
|
||||||
// make sure the nodes stay synced.
|
|
||||||
//
|
//
|
||||||
// TODO(yy): replace directly mining with this one.
|
// NOTE: this differs from miner's `MineBlocks` as it requires the nodes to be
|
||||||
func (h *HarnessTest) MineBlocksAssertNodesSync(num uint32) {
|
// synced.
|
||||||
// If we are mining more than 3 blocks, use the slow mining.
|
func (h *HarnessTest) MineBlocks(num uint32) []*wire.MsgBlock {
|
||||||
if num > 3 {
|
// Mining the blocks slow to give `lnd` more time to sync.
|
||||||
h.Miner.MineBlocksSlow(num)
|
blocks := h.Miner.MineBlocksSlow(num)
|
||||||
} else {
|
|
||||||
// Mine the blocks.
|
|
||||||
h.Miner.MineBlocks(num)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Make sure all the active nodes are synced.
|
// Make sure all the active nodes are synced.
|
||||||
for _, node := range h.manager.activeNodes {
|
h.AssertActiveNodesSynced()
|
||||||
h.WaitForBlockchainSync(node)
|
|
||||||
}
|
return blocks
|
||||||
|
}
|
||||||
|
|
||||||
|
// MineBlocksAndAssertNumTxes mines blocks and asserts the number of
|
||||||
|
// transactions are found in the first block. It also asserts all active nodes
|
||||||
|
// have synced to the chain.
|
||||||
|
//
|
||||||
|
// NOTE: this differs from miner's `MineBlocks` as it requires the nodes to be
|
||||||
|
// synced.
|
||||||
|
func (h *HarnessTest) MineBlocksAndAssertNumTxes(num uint32,
|
||||||
|
numTxs int) []*wire.MsgBlock {
|
||||||
|
|
||||||
|
// If we expect transactions to be included in the blocks we'll mine,
|
||||||
|
// we wait here until they are seen in the miner's mempool.
|
||||||
|
txids := h.Miner.AssertNumTxsInMempool(numTxs)
|
||||||
|
|
||||||
|
// Mine blocks.
|
||||||
|
blocks := h.Miner.MineBlocksSlow(num)
|
||||||
|
|
||||||
|
// Assert that all the transactions were included in the first block.
|
||||||
|
for _, txid := range txids {
|
||||||
|
h.Miner.AssertTxInBlock(blocks[0], txid)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Finally, make sure all the active nodes are synced.
|
||||||
|
h.AssertActiveNodesSynced()
|
||||||
|
|
||||||
|
return blocks
|
||||||
}
|
}
|
||||||
@@ -498,7 +498,7 @@ func (h *HarnessTest) AssertStreamChannelCoopClosed(hn *node.HarnessNode,
|
|||||||
if anchors {
|
if anchors {
|
||||||
expectedTxes = 2
|
expectedTxes = 2
|
||||||
}
|
}
|
||||||
block := h.Miner.MineBlocksAndAssertNumTxes(1, expectedTxes)[0]
|
block := h.MineBlocksAndAssertNumTxes(1, expectedTxes)[0]
|
||||||
|
|
||||||
// Consume one close event and assert the closing txid can be found in
|
// Consume one close event and assert the closing txid can be found in
|
||||||
// the block.
|
// the block.
|
||||||
@@ -542,7 +542,7 @@ func (h *HarnessTest) AssertStreamChannelForceClosed(hn *node.HarnessNode,
|
|||||||
if anchors {
|
if anchors {
|
||||||
expectedTxes = 2
|
expectedTxes = 2
|
||||||
}
|
}
|
||||||
block := h.Miner.MineBlocksAndAssertNumTxes(1, expectedTxes)[0]
|
block := h.MineBlocksAndAssertNumTxes(1, expectedTxes)[0]
|
||||||
|
|
||||||
// Consume one close event and assert the closing txid can be found in
|
// Consume one close event and assert the closing txid can be found in
|
||||||
// the block.
|
// the block.
|
||||||
@@ -1287,3 +1287,10 @@ func (h *HarnessTest) AssertPaymentStatus(hn *node.HarnessNode,
|
|||||||
|
|
||||||
return target
|
return target
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AssertActiveNodesSynced asserts all active nodes have synced to the chain.
|
||||||
|
func (h *HarnessTest) AssertActiveNodesSynced() {
|
||||||
|
for _, node := range h.manager.activeNodes {
|
||||||
|
h.WaitForBlockchainSync(node)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -29,7 +29,8 @@ const (
|
|||||||
// minerLogDir is the default log dir for the miner node.
|
// minerLogDir is the default log dir for the miner node.
|
||||||
minerLogDir = ".minerlogs"
|
minerLogDir = ".minerlogs"
|
||||||
|
|
||||||
slowMineDelay = 20 * time.Millisecond
|
// slowMineDelay defines a wait period between mining new blocks.
|
||||||
|
slowMineDelay = 100 * time.Millisecond
|
||||||
)
|
)
|
||||||
|
|
||||||
var harnessNetParams = &chaincfg.RegressionNetParams
|
var harnessNetParams = &chaincfg.RegressionNetParams
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ func newChanRestoreScenario(ht *lntemp.HarnessTest, ct lnrpc.CommitmentType,
|
|||||||
ht.FundCoinsUnconfirmed(btcutil.SatoshiPerBitcoin, dave)
|
ht.FundCoinsUnconfirmed(btcutil.SatoshiPerBitcoin, dave)
|
||||||
|
|
||||||
// Mine a block to confirm the funds.
|
// Mine a block to confirm the funds.
|
||||||
ht.MineBlocksAssertNodesSync(1)
|
ht.MineBlocks(1)
|
||||||
|
|
||||||
// For the anchor output case we need two UTXOs for Carol so she can
|
// For the anchor output case we need two UTXOs for Carol so she can
|
||||||
// sweep both the local and remote anchor.
|
// sweep both the local and remote anchor.
|
||||||
@@ -510,7 +510,7 @@ func runChanRestoreScenarioUnConfirmed(ht *lntemp.HarnessTest, useFile bool) {
|
|||||||
// the only backup we have. We should still be able to restore it. To
|
// the only backup we have. We should still be able to restore it. To
|
||||||
// simulate time passing, we mine some blocks to get the channel
|
// simulate time passing, we mine some blocks to get the channel
|
||||||
// confirmed _after_ we saved the backup.
|
// confirmed _after_ we saved the backup.
|
||||||
ht.Miner.MineBlocksAndAssertNumTxes(6, 1)
|
ht.MineBlocksAndAssertNumTxes(6, 1)
|
||||||
|
|
||||||
// In our nodeRestorer function, we'll restore the node from seed, then
|
// In our nodeRestorer function, we'll restore the node from seed, then
|
||||||
// manually recover the channel backup.
|
// manually recover the channel backup.
|
||||||
@@ -759,7 +759,7 @@ func runChanRestoreScenarioForceClose(ht *lntemp.HarnessTest, zeroConf bool) {
|
|||||||
ht.Shutdown(dave)
|
ht.Shutdown(dave)
|
||||||
|
|
||||||
// Mine a block to confirm the closing tx from Dave.
|
// Mine a block to confirm the closing tx from Dave.
|
||||||
ht.Miner.MineBlocksAndAssertNumTxes(1, 2)
|
ht.MineBlocksAndAssertNumTxes(1, 2)
|
||||||
|
|
||||||
// To make sure the channel state is advanced correctly if the channel
|
// To make sure the channel state is advanced correctly if the channel
|
||||||
// peer is not online at first, we also shutdown Carol.
|
// peer is not online at first, we also shutdown Carol.
|
||||||
@@ -1274,7 +1274,7 @@ func testDataLossProtection(ht *lntemp.HarnessTest) {
|
|||||||
|
|
||||||
// Mine a block to confirm the sweep, and make sure Dave got his
|
// Mine a block to confirm the sweep, and make sure Dave got his
|
||||||
// balance back.
|
// balance back.
|
||||||
ht.Miner.MineBlocksAndAssertNumTxes(1, 1)
|
ht.MineBlocksAndAssertNumTxes(1, 1)
|
||||||
ht.AssertNodeNumChannels(dave, 0)
|
ht.AssertNodeNumChannels(dave, 0)
|
||||||
|
|
||||||
err := wait.NoError(func() error {
|
err := wait.NoError(func() error {
|
||||||
@@ -1376,7 +1376,7 @@ func createLegacyRevocationChannel(ht *lntemp.HarnessTest,
|
|||||||
OutputIndex: upd.ChanPending.OutputIndex,
|
OutputIndex: upd.ChanPending.OutputIndex,
|
||||||
}
|
}
|
||||||
|
|
||||||
ht.Miner.MineBlocksAndAssertNumTxes(6, 1)
|
ht.MineBlocksAndAssertNumTxes(6, 1)
|
||||||
ht.AssertTopologyChannelOpen(from, chanPoint)
|
ht.AssertTopologyChannelOpen(from, chanPoint)
|
||||||
ht.AssertTopologyChannelOpen(to, chanPoint)
|
ht.AssertTopologyChannelOpen(to, chanPoint)
|
||||||
}
|
}
|
||||||
@@ -1449,7 +1449,7 @@ func assertTimeLockSwept(ht *lntemp.HarnessTest, carol, dave *node.HarnessNode,
|
|||||||
ht.AssertNumPendingForceClose(dave, 1)
|
ht.AssertNumPendingForceClose(dave, 1)
|
||||||
|
|
||||||
// Mine the sweep (and anchor) tx(ns).
|
// Mine the sweep (and anchor) tx(ns).
|
||||||
ht.Miner.MineBlocksAndAssertNumTxes(1, expectedTxes)
|
ht.MineBlocksAndAssertNumTxes(1, expectedTxes)
|
||||||
|
|
||||||
// Now Carol should consider the channel fully closed.
|
// Now Carol should consider the channel fully closed.
|
||||||
ht.AssertNumPendingForceClose(carol, 0)
|
ht.AssertNumPendingForceClose(carol, 0)
|
||||||
@@ -1467,9 +1467,9 @@ func assertTimeLockSwept(ht *lntemp.HarnessTest, carol, dave *node.HarnessNode,
|
|||||||
// The commit sweep resolver publishes the sweep tx at defaultCSV-1 and
|
// The commit sweep resolver publishes the sweep tx at defaultCSV-1 and
|
||||||
// we already mined one block after the commitment was published, so
|
// we already mined one block after the commitment was published, so
|
||||||
// take that into account.
|
// take that into account.
|
||||||
ht.MineBlocksAssertNodesSync(defaultCSV - 1 - 1)
|
ht.MineBlocks(defaultCSV - 1 - 1)
|
||||||
daveSweep := ht.Miner.AssertNumTxsInMempool(1)[0]
|
daveSweep := ht.Miner.AssertNumTxsInMempool(1)[0]
|
||||||
block := ht.Miner.MineBlocksAndAssertNumTxes(1, 1)[0]
|
block := ht.MineBlocksAndAssertNumTxes(1, 1)[0]
|
||||||
ht.Miner.AssertTxInBlock(block, daveSweep)
|
ht.Miner.AssertTxInBlock(block, daveSweep)
|
||||||
|
|
||||||
// Now the channel should be fully closed also from Dave's POV.
|
// Now the channel should be fully closed also from Dave's POV.
|
||||||
@@ -1534,7 +1534,7 @@ func assertDLPExecuted(ht *lntemp.HarnessTest,
|
|||||||
ht.RestartNode(dave)
|
ht.RestartNode(dave)
|
||||||
|
|
||||||
// Generate a single block, which should confirm the closing tx.
|
// Generate a single block, which should confirm the closing tx.
|
||||||
ht.Miner.MineBlocksAndAssertNumTxes(1, expectedTxes)
|
ht.MineBlocksAndAssertNumTxes(1, expectedTxes)
|
||||||
|
|
||||||
// Dave should consider the channel pending force close (since he is
|
// Dave should consider the channel pending force close (since he is
|
||||||
// waiting for his sweep to confirm).
|
// waiting for his sweep to confirm).
|
||||||
@@ -1550,7 +1550,7 @@ func assertDLPExecuted(ht *lntemp.HarnessTest,
|
|||||||
ht.Miner.AssertNumTxsInMempool(1)
|
ht.Miner.AssertNumTxsInMempool(1)
|
||||||
|
|
||||||
// Mine Dave's anchor sweep tx.
|
// Mine Dave's anchor sweep tx.
|
||||||
ht.Miner.MineBlocksAndAssertNumTxes(1, 1)
|
ht.MineBlocksAndAssertNumTxes(1, 1)
|
||||||
|
|
||||||
// After Carol's output matures, she should also reclaim her
|
// After Carol's output matures, she should also reclaim her
|
||||||
// funds.
|
// funds.
|
||||||
@@ -1558,8 +1558,8 @@ func assertDLPExecuted(ht *lntemp.HarnessTest,
|
|||||||
// The commit sweep resolver publishes the sweep tx at
|
// The commit sweep resolver publishes the sweep tx at
|
||||||
// defaultCSV-1 and we already mined one block after the
|
// defaultCSV-1 and we already mined one block after the
|
||||||
// commitmment was published, so take that into account.
|
// commitmment was published, so take that into account.
|
||||||
ht.Miner.MineBlocks(defaultCSV - 1 - 1)
|
ht.MineBlocks(defaultCSV - 1 - 1)
|
||||||
ht.Miner.MineBlocksAndAssertNumTxes(1, 1)
|
ht.MineBlocksAndAssertNumTxes(1, 1)
|
||||||
|
|
||||||
// Now the channel should be fully closed also from Carol's POV.
|
// Now the channel should be fully closed also from Carol's POV.
|
||||||
ht.AssertNumPendingForceClose(carol, 0)
|
ht.AssertNumPendingForceClose(carol, 0)
|
||||||
@@ -1571,8 +1571,8 @@ func assertDLPExecuted(ht *lntemp.HarnessTest,
|
|||||||
resp.PendingForceClosingChannels[0].BlocksTilMaturity
|
resp.PendingForceClosingChannels[0].BlocksTilMaturity
|
||||||
require.Positive(ht, blocksTilMaturity)
|
require.Positive(ht, blocksTilMaturity)
|
||||||
|
|
||||||
ht.Miner.MineBlocks(uint32(blocksTilMaturity))
|
ht.MineBlocks(uint32(blocksTilMaturity))
|
||||||
ht.Miner.MineBlocksAndAssertNumTxes(1, 1)
|
ht.MineBlocksAndAssertNumTxes(1, 1)
|
||||||
|
|
||||||
// Now Dave should consider the channel fully closed.
|
// Now Dave should consider the channel fully closed.
|
||||||
ht.AssertNumPendingForceClose(dave, 0)
|
ht.AssertNumPendingForceClose(dave, 0)
|
||||||
@@ -1583,7 +1583,7 @@ func assertDLPExecuted(ht *lntemp.HarnessTest,
|
|||||||
ht.Miner.AssertNumTxsInMempool(expectedTxes)
|
ht.Miner.AssertNumTxsInMempool(expectedTxes)
|
||||||
|
|
||||||
// Mine the sweep tx.
|
// Mine the sweep tx.
|
||||||
ht.Miner.MineBlocksAndAssertNumTxes(1, expectedTxes)
|
ht.MineBlocksAndAssertNumTxes(1, expectedTxes)
|
||||||
|
|
||||||
// Now Dave should consider the channel fully closed.
|
// Now Dave should consider the channel fully closed.
|
||||||
ht.AssertNumPendingForceClose(dave, 0)
|
ht.AssertNumPendingForceClose(dave, 0)
|
||||||
@@ -1594,8 +1594,8 @@ func assertDLPExecuted(ht *lntemp.HarnessTest,
|
|||||||
// The commit sweep resolver publishes the sweep tx at
|
// The commit sweep resolver publishes the sweep tx at
|
||||||
// defaultCSV-1 and we already mined one block after the
|
// defaultCSV-1 and we already mined one block after the
|
||||||
// commitmment was published, so take that into account.
|
// commitmment was published, so take that into account.
|
||||||
ht.Miner.MineBlocks(defaultCSV - 1 - 1)
|
ht.MineBlocks(defaultCSV - 1 - 1)
|
||||||
ht.Miner.MineBlocksAndAssertNumTxes(1, 1)
|
ht.MineBlocksAndAssertNumTxes(1, 1)
|
||||||
|
|
||||||
// Now the channel should be fully closed also from Carol's
|
// Now the channel should be fully closed also from Carol's
|
||||||
// POV.
|
// POV.
|
||||||
|
|||||||
@@ -264,7 +264,7 @@ func runMultiHopHtlcLocalTimeout(ht *lntemp.HarnessTest,
|
|||||||
numBlocks := padCLTV(
|
numBlocks := padCLTV(
|
||||||
uint32(finalCltvDelta - lncfg.DefaultOutgoingBroadcastDelta),
|
uint32(finalCltvDelta - lncfg.DefaultOutgoingBroadcastDelta),
|
||||||
)
|
)
|
||||||
ht.MineBlocksAssertNodesSync(numBlocks)
|
ht.MineBlocks(numBlocks)
|
||||||
|
|
||||||
// Bob's force close transaction should now be found in the mempool. If
|
// Bob's force close transaction should now be found in the mempool. If
|
||||||
// there are anchors, we also expect Bob's anchor sweep.
|
// there are anchors, we also expect Bob's anchor sweep.
|
||||||
@@ -279,7 +279,7 @@ func runMultiHopHtlcLocalTimeout(ht *lntemp.HarnessTest,
|
|||||||
closeTx := ht.Miner.AssertOutpointInMempool(op)
|
closeTx := ht.Miner.AssertOutpointInMempool(op)
|
||||||
|
|
||||||
// Mine a block to confirm the closing transaction.
|
// Mine a block to confirm the closing transaction.
|
||||||
ht.Miner.MineBlocksAndAssertNumTxes(1, expectedTxes)
|
ht.MineBlocksAndAssertNumTxes(1, expectedTxes)
|
||||||
|
|
||||||
// At this point, Bob should have canceled backwards the dust HTLC
|
// At this point, Bob should have canceled backwards the dust HTLC
|
||||||
// that we sent earlier. This means Alice should now only have a single
|
// that we sent earlier. This means Alice should now only have a single
|
||||||
@@ -303,7 +303,7 @@ func runMultiHopHtlcLocalTimeout(ht *lntemp.HarnessTest,
|
|||||||
).TxHash()
|
).TxHash()
|
||||||
|
|
||||||
// Mine a block to confirm the expected transactions.
|
// Mine a block to confirm the expected transactions.
|
||||||
ht.Miner.MineBlocksAndAssertNumTxes(1, expectedTxes)
|
ht.MineBlocksAndAssertNumTxes(1, expectedTxes)
|
||||||
|
|
||||||
// With Bob's HTLC timeout transaction confirmed, there should be no
|
// With Bob's HTLC timeout transaction confirmed, there should be no
|
||||||
// active HTLC's on the commitment transaction from Alice -> Bob.
|
// active HTLC's on the commitment transaction from Alice -> Bob.
|
||||||
@@ -326,7 +326,7 @@ func runMultiHopHtlcLocalTimeout(ht *lntemp.HarnessTest,
|
|||||||
// CLTV on top of the usual CSV delay on any outputs that he can
|
// CLTV on top of the usual CSV delay on any outputs that he can
|
||||||
// sweep back to his wallet.
|
// sweep back to his wallet.
|
||||||
blocksTilMaturity := uint32(forceCloseChan.BlocksTilMaturity)
|
blocksTilMaturity := uint32(forceCloseChan.BlocksTilMaturity)
|
||||||
ht.MineBlocksAssertNodesSync(blocksTilMaturity)
|
ht.MineBlocks(blocksTilMaturity)
|
||||||
|
|
||||||
// Check that the sweep spends the expected inputs.
|
// Check that the sweep spends the expected inputs.
|
||||||
ht.Miner.AssertOutpointInMempool(commitOutpoint)
|
ht.Miner.AssertOutpointInMempool(commitOutpoint)
|
||||||
@@ -337,24 +337,24 @@ func runMultiHopHtlcLocalTimeout(ht *lntemp.HarnessTest,
|
|||||||
// sweep back to his wallet. We'll subtract one block from our
|
// sweep back to his wallet. We'll subtract one block from our
|
||||||
// current maturity period to assert on the mempool.
|
// current maturity period to assert on the mempool.
|
||||||
numBlocks := uint32(forceCloseChan.BlocksTilMaturity - 1)
|
numBlocks := uint32(forceCloseChan.BlocksTilMaturity - 1)
|
||||||
ht.MineBlocksAssertNodesSync(numBlocks)
|
ht.MineBlocks(numBlocks)
|
||||||
|
|
||||||
// Check that the sweep spends from the mined commitment.
|
// Check that the sweep spends from the mined commitment.
|
||||||
ht.Miner.AssertOutpointInMempool(commitOutpoint)
|
ht.Miner.AssertOutpointInMempool(commitOutpoint)
|
||||||
|
|
||||||
// Mine a block to confirm Bob's commit sweep tx and assert it
|
// Mine a block to confirm Bob's commit sweep tx and assert it
|
||||||
// was in fact mined.
|
// was in fact mined.
|
||||||
ht.Miner.MineBlocksAndAssertNumTxes(1, 1)
|
ht.MineBlocksAndAssertNumTxes(1, 1)
|
||||||
|
|
||||||
// Mine an additional block to prompt Bob to broadcast their
|
// Mine an additional block to prompt Bob to broadcast their
|
||||||
// second layer sweep due to the CSV on the HTLC timeout output.
|
// second layer sweep due to the CSV on the HTLC timeout output.
|
||||||
ht.Miner.MineBlocksAndAssertNumTxes(1, 0)
|
ht.MineBlocksAndAssertNumTxes(1, 0)
|
||||||
ht.Miner.AssertOutpointInMempool(htlcTimeoutOutpoint)
|
ht.Miner.AssertOutpointInMempool(htlcTimeoutOutpoint)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Next, we'll mine a final block that should confirm the sweeping
|
// Next, we'll mine a final block that should confirm the sweeping
|
||||||
// transactions left.
|
// transactions left.
|
||||||
ht.MineBlocksAssertNodesSync(1)
|
ht.MineBlocks(1)
|
||||||
|
|
||||||
// Once this transaction has been confirmed, Bob should detect that he
|
// Once this transaction has been confirmed, Bob should detect that he
|
||||||
// no longer has any pending channels.
|
// no longer has any pending channels.
|
||||||
@@ -440,7 +440,7 @@ func runMultiHopReceiverChainClaim(ht *lntemp.HarnessTest,
|
|||||||
numBlocks := padCLTV(uint32(
|
numBlocks := padCLTV(uint32(
|
||||||
invoiceReq.CltvExpiry - lncfg.DefaultIncomingBroadcastDelta,
|
invoiceReq.CltvExpiry - lncfg.DefaultIncomingBroadcastDelta,
|
||||||
))
|
))
|
||||||
ht.MineBlocksAssertNodesSync(numBlocks)
|
ht.MineBlocks(numBlocks)
|
||||||
|
|
||||||
// At this point, Carol should broadcast her active commitment
|
// At this point, Carol should broadcast her active commitment
|
||||||
// transaction in order to go to the chain and sweep her HTLC. If there
|
// transaction in order to go to the chain and sweep her HTLC. If there
|
||||||
@@ -458,7 +458,7 @@ func runMultiHopReceiverChainClaim(ht *lntemp.HarnessTest,
|
|||||||
closingTxid := closingTx.TxHash()
|
closingTxid := closingTx.TxHash()
|
||||||
|
|
||||||
// Confirm the commitment.
|
// Confirm the commitment.
|
||||||
ht.Miner.MineBlocksAndAssertNumTxes(1, expectedTxes)
|
ht.MineBlocksAndAssertNumTxes(1, expectedTxes)
|
||||||
|
|
||||||
// Restart bob again.
|
// Restart bob again.
|
||||||
require.NoError(ht, restartBob())
|
require.NoError(ht, restartBob())
|
||||||
@@ -497,7 +497,7 @@ func runMultiHopReceiverChainClaim(ht *lntemp.HarnessTest,
|
|||||||
|
|
||||||
// We'll now mine an additional block which should confirm both the
|
// We'll now mine an additional block which should confirm both the
|
||||||
// second layer transactions.
|
// second layer transactions.
|
||||||
ht.MineBlocksAssertNodesSync(1)
|
ht.MineBlocks(1)
|
||||||
|
|
||||||
// Carol's pending channel report should now show two outputs under
|
// Carol's pending channel report should now show two outputs under
|
||||||
// limbo: her commitment output, as well as the second-layer claim
|
// limbo: her commitment output, as well as the second-layer claim
|
||||||
@@ -511,7 +511,7 @@ func runMultiHopReceiverChainClaim(ht *lntemp.HarnessTest,
|
|||||||
|
|
||||||
// If we mine 4 additional blocks, then Carol can sweep the second level
|
// If we mine 4 additional blocks, then Carol can sweep the second level
|
||||||
// HTLC output.
|
// HTLC output.
|
||||||
ht.MineBlocksAssertNodesSync(defaultCSV)
|
ht.MineBlocks(defaultCSV)
|
||||||
|
|
||||||
// We should have a new transaction in the mempool.
|
// We should have a new transaction in the mempool.
|
||||||
ht.Miner.AssertNumTxsInMempool(1)
|
ht.Miner.AssertNumTxsInMempool(1)
|
||||||
@@ -519,7 +519,7 @@ func runMultiHopReceiverChainClaim(ht *lntemp.HarnessTest,
|
|||||||
// Finally, if we mine an additional block to confirm these two sweep
|
// Finally, if we mine an additional block to confirm these two sweep
|
||||||
// transactions, Carol should not show a pending channel in her report
|
// transactions, Carol should not show a pending channel in her report
|
||||||
// afterwards.
|
// afterwards.
|
||||||
ht.MineBlocksAssertNodesSync(1)
|
ht.MineBlocks(1)
|
||||||
ht.AssertNumPendingForceClose(carol, 0)
|
ht.AssertNumPendingForceClose(carol, 0)
|
||||||
|
|
||||||
// The invoice should show as settled for Carol, indicating that it was
|
// The invoice should show as settled for Carol, indicating that it was
|
||||||
@@ -550,10 +550,10 @@ func runMultiHopReceiverChainClaim(ht *lntemp.HarnessTest,
|
|||||||
// Mine enough blocks for Bob's commit output's CLTV to expire
|
// Mine enough blocks for Bob's commit output's CLTV to expire
|
||||||
// and sweep it.
|
// and sweep it.
|
||||||
numBlocks := uint32(forceCloseChan.BlocksTilMaturity)
|
numBlocks := uint32(forceCloseChan.BlocksTilMaturity)
|
||||||
ht.MineBlocksAssertNodesSync(numBlocks)
|
ht.MineBlocks(numBlocks)
|
||||||
commitOutpoint := wire.OutPoint{Hash: closingTxid, Index: 3}
|
commitOutpoint := wire.OutPoint{Hash: closingTxid, Index: 3}
|
||||||
ht.Miner.AssertOutpointInMempool(commitOutpoint)
|
ht.Miner.AssertOutpointInMempool(commitOutpoint)
|
||||||
ht.MineBlocksAssertNodesSync(1)
|
ht.MineBlocks(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
ht.AssertNumPendingForceClose(bob, 0)
|
ht.AssertNumPendingForceClose(bob, 0)
|
||||||
@@ -644,13 +644,13 @@ func runMultiHopLocalForceCloseOnChainHtlcTimeout(ht *lntemp.HarnessTest,
|
|||||||
// CSV expires and the commitment was already mined inside
|
// CSV expires and the commitment was already mined inside
|
||||||
// AssertStreamChannelForceClosed(), so mine one block less
|
// AssertStreamChannelForceClosed(), so mine one block less
|
||||||
// than defaultCSV in order to perform mempool assertions.
|
// than defaultCSV in order to perform mempool assertions.
|
||||||
ht.MineBlocksAssertNodesSync(defaultCSV - blocksMined)
|
ht.MineBlocks(defaultCSV - blocksMined)
|
||||||
|
|
||||||
commitSweepTx := ht.Miner.AssertOutpointInMempool(
|
commitSweepTx := ht.Miner.AssertOutpointInMempool(
|
||||||
bobCommitOutpoint,
|
bobCommitOutpoint,
|
||||||
)
|
)
|
||||||
txid := commitSweepTx.TxHash()
|
txid := commitSweepTx.TxHash()
|
||||||
block := ht.Miner.MineBlocksAndAssertNumTxes(1, 1)[0]
|
block := ht.MineBlocksAndAssertNumTxes(1, 1)[0]
|
||||||
ht.Miner.AssertTxInBlock(block, &txid)
|
ht.Miner.AssertTxInBlock(block, &txid)
|
||||||
|
|
||||||
blocksMined = defaultCSV + 1
|
blocksMined = defaultCSV + 1
|
||||||
@@ -659,7 +659,7 @@ func runMultiHopLocalForceCloseOnChainHtlcTimeout(ht *lntemp.HarnessTest,
|
|||||||
// We'll now mine enough blocks for the HTLC to expire. After this, Bob
|
// We'll now mine enough blocks for the HTLC to expire. After this, Bob
|
||||||
// should hand off the now expired HTLC output to the utxo nursery.
|
// should hand off the now expired HTLC output to the utxo nursery.
|
||||||
numBlocks := padCLTV(finalCltvDelta)
|
numBlocks := padCLTV(finalCltvDelta)
|
||||||
ht.MineBlocksAssertNodesSync(numBlocks - blocksMined)
|
ht.MineBlocks(numBlocks - blocksMined)
|
||||||
|
|
||||||
// Bob's pending channel report should show that he has a single HTLC
|
// Bob's pending channel report should show that he has a single HTLC
|
||||||
// that's now in stage one.
|
// that's now in stage one.
|
||||||
@@ -671,7 +671,7 @@ func runMultiHopLocalForceCloseOnChainHtlcTimeout(ht *lntemp.HarnessTest,
|
|||||||
|
|
||||||
// Next, we'll mine an additional block. This should serve to confirm
|
// Next, we'll mine an additional block. This should serve to confirm
|
||||||
// the second layer timeout transaction.
|
// the second layer timeout transaction.
|
||||||
block := ht.Miner.MineBlocksAndAssertNumTxes(1, 1)[0]
|
block := ht.MineBlocksAndAssertNumTxes(1, 1)[0]
|
||||||
ht.Miner.AssertTxInBlock(block, &timeoutTx)
|
ht.Miner.AssertTxInBlock(block, &timeoutTx)
|
||||||
|
|
||||||
// With the second layer timeout transaction confirmed, Bob should have
|
// With the second layer timeout transaction confirmed, Bob should have
|
||||||
@@ -694,7 +694,7 @@ func runMultiHopLocalForceCloseOnChainHtlcTimeout(ht *lntemp.HarnessTest,
|
|||||||
require.Positive(ht, pendingHtlc.BlocksTilMaturity)
|
require.Positive(ht, pendingHtlc.BlocksTilMaturity)
|
||||||
numBlocks = uint32(pendingHtlc.BlocksTilMaturity)
|
numBlocks = uint32(pendingHtlc.BlocksTilMaturity)
|
||||||
|
|
||||||
ht.MineBlocksAssertNodesSync(numBlocks)
|
ht.MineBlocks(numBlocks)
|
||||||
|
|
||||||
// Now that the CSV/CLTV timelock has expired, the transaction should
|
// Now that the CSV/CLTV timelock has expired, the transaction should
|
||||||
// either only sweep the HTLC timeout transaction, or sweep both the
|
// either only sweep the HTLC timeout transaction, or sweep both the
|
||||||
@@ -708,7 +708,7 @@ func runMultiHopLocalForceCloseOnChainHtlcTimeout(ht *lntemp.HarnessTest,
|
|||||||
ht.Miner.AssertOutpointInMempool(bobCommitOutpoint)
|
ht.Miner.AssertOutpointInMempool(bobCommitOutpoint)
|
||||||
}
|
}
|
||||||
|
|
||||||
block = ht.Miner.MineBlocksAndAssertNumTxes(1, 1)[0]
|
block = ht.MineBlocksAndAssertNumTxes(1, 1)[0]
|
||||||
ht.Miner.AssertTxInBlock(block, &sweepTx)
|
ht.Miner.AssertTxInBlock(block, &sweepTx)
|
||||||
|
|
||||||
// At this point, Bob should no longer show any channels as pending
|
// At this point, Bob should no longer show any channels as pending
|
||||||
@@ -818,7 +818,7 @@ func runMultiHopRemoteForceCloseOnChainHtlcTimeout(ht *lntemp.HarnessTest,
|
|||||||
// point, Bob should hand off the output to his internal utxo nursery,
|
// point, Bob should hand off the output to his internal utxo nursery,
|
||||||
// which will broadcast a sweep transaction.
|
// which will broadcast a sweep transaction.
|
||||||
numBlocks := padCLTV(finalCltvDelta - 1)
|
numBlocks := padCLTV(finalCltvDelta - 1)
|
||||||
ht.MineBlocksAssertNodesSync(numBlocks)
|
ht.MineBlocks(numBlocks)
|
||||||
|
|
||||||
// If we check Bob's pending channel report, it should show that he has
|
// If we check Bob's pending channel report, it should show that he has
|
||||||
// a single HTLC that's now in the second stage, as skip the initial
|
// a single HTLC that's now in the second stage, as skip the initial
|
||||||
@@ -826,7 +826,7 @@ func runMultiHopRemoteForceCloseOnChainHtlcTimeout(ht *lntemp.HarnessTest,
|
|||||||
ht.AssertNumHTLCsAndStage(bob, bobChanPoint, 1, 2)
|
ht.AssertNumHTLCsAndStage(bob, bobChanPoint, 1, 2)
|
||||||
|
|
||||||
// We need to generate an additional block to trigger the sweep.
|
// We need to generate an additional block to trigger the sweep.
|
||||||
ht.MineBlocksAssertNodesSync(1)
|
ht.MineBlocks(1)
|
||||||
|
|
||||||
// Bob's sweeping transaction should now be found in the mempool at
|
// Bob's sweeping transaction should now be found in the mempool at
|
||||||
// this point.
|
// this point.
|
||||||
@@ -834,7 +834,7 @@ func runMultiHopRemoteForceCloseOnChainHtlcTimeout(ht *lntemp.HarnessTest,
|
|||||||
|
|
||||||
// If we mine an additional block, then this should confirm Bob's
|
// If we mine an additional block, then this should confirm Bob's
|
||||||
// transaction which sweeps the direct HTLC output.
|
// transaction which sweeps the direct HTLC output.
|
||||||
block := ht.Miner.MineBlocksAndAssertNumTxes(1, 1)[0]
|
block := ht.MineBlocksAndAssertNumTxes(1, 1)[0]
|
||||||
ht.Miner.AssertTxInBlock(block, sweepTx)
|
ht.Miner.AssertTxInBlock(block, sweepTx)
|
||||||
|
|
||||||
// Now that the sweeping transaction has been confirmed, Bob should
|
// Now that the sweeping transaction has been confirmed, Bob should
|
||||||
@@ -854,14 +854,14 @@ func runMultiHopRemoteForceCloseOnChainHtlcTimeout(ht *lntemp.HarnessTest,
|
|||||||
require.Positive(ht, forceCloseChan.BlocksTilMaturity)
|
require.Positive(ht, forceCloseChan.BlocksTilMaturity)
|
||||||
|
|
||||||
numBlocks := uint32(forceCloseChan.BlocksTilMaturity)
|
numBlocks := uint32(forceCloseChan.BlocksTilMaturity)
|
||||||
ht.MineBlocksAssertNodesSync(numBlocks)
|
ht.MineBlocks(numBlocks)
|
||||||
|
|
||||||
bobCommitOutpoint := wire.OutPoint{Hash: *closeTx, Index: 3}
|
bobCommitOutpoint := wire.OutPoint{Hash: *closeTx, Index: 3}
|
||||||
bobCommitSweep := ht.Miner.AssertOutpointInMempool(
|
bobCommitSweep := ht.Miner.AssertOutpointInMempool(
|
||||||
bobCommitOutpoint,
|
bobCommitOutpoint,
|
||||||
)
|
)
|
||||||
bobCommitSweepTxid := bobCommitSweep.TxHash()
|
bobCommitSweepTxid := bobCommitSweep.TxHash()
|
||||||
block := ht.Miner.MineBlocksAndAssertNumTxes(1, 1)[0]
|
block := ht.MineBlocksAndAssertNumTxes(1, 1)[0]
|
||||||
ht.Miner.AssertTxInBlock(block, &bobCommitSweepTxid)
|
ht.Miner.AssertTxInBlock(block, &bobCommitSweepTxid)
|
||||||
}
|
}
|
||||||
ht.AssertNumPendingForceClose(bob, 0)
|
ht.AssertNumPendingForceClose(bob, 0)
|
||||||
@@ -981,8 +981,8 @@ func runMultiHopHtlcLocalChainClaim(ht *lntemp.HarnessTest,
|
|||||||
// We'll now mine enough blocks so Carol decides that she needs to go
|
// We'll now mine enough blocks so Carol decides that she needs to go
|
||||||
// on-chain to claim the HTLC as Bob has been inactive.
|
// on-chain to claim the HTLC as Bob has been inactive.
|
||||||
numBlocks := padCLTV(uint32(invoiceReq.CltvExpiry-
|
numBlocks := padCLTV(uint32(invoiceReq.CltvExpiry-
|
||||||
lncfg.DefaultIncomingBroadcastDelta)) - 1
|
lncfg.DefaultIncomingBroadcastDelta) - 1)
|
||||||
ht.MineBlocksAssertNodesSync(numBlocks)
|
ht.MineBlocks(numBlocks)
|
||||||
|
|
||||||
// Carol's commitment transaction should now be in the mempool. If
|
// Carol's commitment transaction should now be in the mempool. If
|
||||||
// there is an anchor, Carol will sweep that too.
|
// there is an anchor, Carol will sweep that too.
|
||||||
@@ -1000,7 +1000,7 @@ func runMultiHopHtlcLocalChainClaim(ht *lntemp.HarnessTest,
|
|||||||
|
|
||||||
// Mine a block that should confirm the commit tx, the anchor if
|
// Mine a block that should confirm the commit tx, the anchor if
|
||||||
// present and the coinbase.
|
// present and the coinbase.
|
||||||
block := ht.Miner.MineBlocksAndAssertNumTxes(1, expectedTxes)[0]
|
block := ht.MineBlocksAndAssertNumTxes(1, expectedTxes)[0]
|
||||||
ht.Miner.AssertTxInBlock(block, &closingTxid)
|
ht.Miner.AssertTxInBlock(block, &closingTxid)
|
||||||
|
|
||||||
// Restart bob again.
|
// Restart bob again.
|
||||||
@@ -1041,7 +1041,7 @@ func runMultiHopHtlcLocalChainClaim(ht *lntemp.HarnessTest,
|
|||||||
restartAlice := ht.SuspendNode(alice)
|
restartAlice := ht.SuspendNode(alice)
|
||||||
|
|
||||||
// Mine a block to confirm the expected transactions (+ the coinbase).
|
// Mine a block to confirm the expected transactions (+ the coinbase).
|
||||||
block = ht.Miner.MineBlocksAndAssertNumTxes(1, expectedTxes)[0]
|
block = ht.MineBlocksAndAssertNumTxes(1, expectedTxes)[0]
|
||||||
require.Len(ht, block.Transactions, expectedTxes+1)
|
require.Len(ht, block.Transactions, expectedTxes+1)
|
||||||
|
|
||||||
// For non-anchor channel types, the nursery will handle sweeping the
|
// For non-anchor channel types, the nursery will handle sweeping the
|
||||||
@@ -1083,7 +1083,7 @@ func runMultiHopHtlcLocalChainClaim(ht *lntemp.HarnessTest,
|
|||||||
|
|
||||||
// We'll now mine a block which should confirm Bob's second layer
|
// We'll now mine a block which should confirm Bob's second layer
|
||||||
// transaction.
|
// transaction.
|
||||||
block = ht.Miner.MineBlocksAndAssertNumTxes(1, 1)[0]
|
block = ht.MineBlocksAndAssertNumTxes(1, 1)[0]
|
||||||
bobSecondLvlTxid := bobSecondLvlTx.TxHash()
|
bobSecondLvlTxid := bobSecondLvlTx.TxHash()
|
||||||
ht.Miner.AssertTxInBlock(block, &bobSecondLvlTxid)
|
ht.Miner.AssertTxInBlock(block, &bobSecondLvlTxid)
|
||||||
|
|
||||||
@@ -1098,13 +1098,13 @@ func runMultiHopHtlcLocalChainClaim(ht *lntemp.HarnessTest,
|
|||||||
|
|
||||||
// If we then mine 3 additional blocks, Carol's second level tx should
|
// If we then mine 3 additional blocks, Carol's second level tx should
|
||||||
// mature, and she can pull the funds from it with a sweep tx.
|
// mature, and she can pull the funds from it with a sweep tx.
|
||||||
ht.MineBlocksAssertNodesSync(carolSecondLevelCSV)
|
ht.MineBlocks(carolSecondLevelCSV)
|
||||||
carolSweep := ht.Miner.AssertNumTxsInMempool(1)[0]
|
carolSweep := ht.Miner.AssertNumTxsInMempool(1)[0]
|
||||||
|
|
||||||
// Mining one additional block, Bob's second level tx is mature, and he
|
// Mining one additional block, Bob's second level tx is mature, and he
|
||||||
// can sweep the output.
|
// can sweep the output.
|
||||||
bobSecondLevelCSV -= carolSecondLevelCSV
|
bobSecondLevelCSV -= carolSecondLevelCSV
|
||||||
block = ht.Miner.MineBlocksAndAssertNumTxes(bobSecondLevelCSV, 1)[0]
|
block = ht.MineBlocksAndAssertNumTxes(bobSecondLevelCSV, 1)[0]
|
||||||
ht.Miner.AssertTxInBlock(block, carolSweep)
|
ht.Miner.AssertTxInBlock(block, carolSweep)
|
||||||
|
|
||||||
bobSweep := ht.Miner.GetNumTxsFromMempool(1)[0]
|
bobSweep := ht.Miner.GetNumTxsFromMempool(1)[0]
|
||||||
@@ -1116,7 +1116,7 @@ func runMultiHopHtlcLocalChainClaim(ht *lntemp.HarnessTest,
|
|||||||
// When we mine one additional block, that will confirm Bob's sweep.
|
// When we mine one additional block, that will confirm Bob's sweep.
|
||||||
// Now Bob should have no pending channels anymore, as this just
|
// Now Bob should have no pending channels anymore, as this just
|
||||||
// resolved it by the confirmation of the sweep transaction.
|
// resolved it by the confirmation of the sweep transaction.
|
||||||
block = ht.Miner.MineBlocksAndAssertNumTxes(1, 1)[0]
|
block = ht.MineBlocksAndAssertNumTxes(1, 1)[0]
|
||||||
ht.Miner.AssertTxInBlock(block, &bobSweepTxid)
|
ht.Miner.AssertTxInBlock(block, &bobSweepTxid)
|
||||||
|
|
||||||
// With the script-enforced lease commitment type, Alice and Bob still
|
// With the script-enforced lease commitment type, Alice and Bob still
|
||||||
@@ -1138,7 +1138,7 @@ func runMultiHopHtlcLocalChainClaim(ht *lntemp.HarnessTest,
|
|||||||
|
|
||||||
// Mine enough blocks for the timelock to expire.
|
// Mine enough blocks for the timelock to expire.
|
||||||
numBlocks := uint32(forceCloseChan.BlocksTilMaturity)
|
numBlocks := uint32(forceCloseChan.BlocksTilMaturity)
|
||||||
ht.MineBlocksAssertNodesSync(numBlocks)
|
ht.MineBlocks(numBlocks)
|
||||||
|
|
||||||
// Both Alice and Bob show broadcast their commit sweeps.
|
// Both Alice and Bob show broadcast their commit sweeps.
|
||||||
aliceCommitOutpoint := wire.OutPoint{
|
aliceCommitOutpoint := wire.OutPoint{
|
||||||
@@ -1153,7 +1153,7 @@ func runMultiHopHtlcLocalChainClaim(ht *lntemp.HarnessTest,
|
|||||||
).TxHash()
|
).TxHash()
|
||||||
|
|
||||||
// Confirm their sweeps.
|
// Confirm their sweeps.
|
||||||
block := ht.Miner.MineBlocksAndAssertNumTxes(1, 2)[0]
|
block := ht.MineBlocksAndAssertNumTxes(1, 2)[0]
|
||||||
ht.Miner.AssertTxInBlock(block, &aliceCommitSweep)
|
ht.Miner.AssertTxInBlock(block, &aliceCommitSweep)
|
||||||
ht.Miner.AssertTxInBlock(block, &bobCommitSweep)
|
ht.Miner.AssertTxInBlock(block, &bobCommitSweep)
|
||||||
}
|
}
|
||||||
@@ -1262,7 +1262,7 @@ func runMultiHopHtlcRemoteChainClaim(ht *lntemp.HarnessTest,
|
|||||||
// commit sweep tx will be broadcast immediately before it can
|
// commit sweep tx will be broadcast immediately before it can
|
||||||
// be included in a block, so mine one less than defaultCSV in
|
// be included in a block, so mine one less than defaultCSV in
|
||||||
// order to perform mempool assertions.
|
// order to perform mempool assertions.
|
||||||
ht.MineBlocksAssertNodesSync(defaultCSV - blocksMined)
|
ht.MineBlocks(defaultCSV - blocksMined)
|
||||||
blocksMined = defaultCSV
|
blocksMined = defaultCSV
|
||||||
|
|
||||||
// Alice should now sweep her funds.
|
// Alice should now sweep her funds.
|
||||||
@@ -1284,7 +1284,7 @@ func runMultiHopHtlcRemoteChainClaim(ht *lntemp.HarnessTest,
|
|||||||
numBlocks := padCLTV(uint32(
|
numBlocks := padCLTV(uint32(
|
||||||
invoiceReq.CltvExpiry - lncfg.DefaultIncomingBroadcastDelta,
|
invoiceReq.CltvExpiry - lncfg.DefaultIncomingBroadcastDelta,
|
||||||
))
|
))
|
||||||
ht.MineBlocksAssertNodesSync(numBlocks - blocksMined)
|
ht.MineBlocks(numBlocks - blocksMined)
|
||||||
|
|
||||||
expectedTxes := 1
|
expectedTxes := 1
|
||||||
if hasAnchors {
|
if hasAnchors {
|
||||||
@@ -1304,7 +1304,7 @@ func runMultiHopHtlcRemoteChainClaim(ht *lntemp.HarnessTest,
|
|||||||
|
|
||||||
// Mine a block, which should contain: the commitment, possibly an
|
// Mine a block, which should contain: the commitment, possibly an
|
||||||
// anchor sweep and the coinbase tx.
|
// anchor sweep and the coinbase tx.
|
||||||
block := ht.Miner.MineBlocksAndAssertNumTxes(1, expectedTxes)[0]
|
block := ht.MineBlocksAndAssertNumTxes(1, expectedTxes)[0]
|
||||||
ht.Miner.AssertTxInBlock(block, &closingTxid)
|
ht.Miner.AssertTxInBlock(block, &closingTxid)
|
||||||
|
|
||||||
// Restart bob again.
|
// Restart bob again.
|
||||||
@@ -1342,7 +1342,7 @@ func runMultiHopHtlcRemoteChainClaim(ht *lntemp.HarnessTest,
|
|||||||
ht.AssertAllTxesSpendFrom(txes, closingTxid)
|
ht.AssertAllTxesSpendFrom(txes, closingTxid)
|
||||||
|
|
||||||
// Mine a block to confirm the two transactions (+ coinbase).
|
// Mine a block to confirm the two transactions (+ coinbase).
|
||||||
ht.Miner.MineBlocksAndAssertNumTxes(1, expectedTxes)
|
ht.MineBlocksAndAssertNumTxes(1, expectedTxes)
|
||||||
|
|
||||||
// Keep track of the second level tx maturity.
|
// Keep track of the second level tx maturity.
|
||||||
carolSecondLevelCSV := uint32(defaultCSV)
|
carolSecondLevelCSV := uint32(defaultCSV)
|
||||||
@@ -1358,7 +1358,7 @@ func runMultiHopHtlcRemoteChainClaim(ht *lntemp.HarnessTest,
|
|||||||
|
|
||||||
// We'll now mine a block which should confirm Bob's HTLC sweep
|
// We'll now mine a block which should confirm Bob's HTLC sweep
|
||||||
// transaction.
|
// transaction.
|
||||||
block = ht.Miner.MineBlocksAndAssertNumTxes(1, 1)[0]
|
block = ht.MineBlocksAndAssertNumTxes(1, 1)[0]
|
||||||
ht.Miner.AssertTxInBlock(block, &bobHtlcSweepTxid)
|
ht.Miner.AssertTxInBlock(block, &bobHtlcSweepTxid)
|
||||||
carolSecondLevelCSV--
|
carolSecondLevelCSV--
|
||||||
|
|
||||||
@@ -1377,12 +1377,12 @@ func runMultiHopHtlcRemoteChainClaim(ht *lntemp.HarnessTest,
|
|||||||
|
|
||||||
// If we then mine 3 additional blocks, Carol's second level tx will
|
// If we then mine 3 additional blocks, Carol's second level tx will
|
||||||
// mature, and she should pull the funds.
|
// mature, and she should pull the funds.
|
||||||
ht.MineBlocksAssertNodesSync(carolSecondLevelCSV)
|
ht.MineBlocks(carolSecondLevelCSV)
|
||||||
carolSweep := ht.Miner.AssertNumTxsInMempool(1)[0]
|
carolSweep := ht.Miner.AssertNumTxsInMempool(1)[0]
|
||||||
|
|
||||||
// When Carol's sweep gets confirmed, she should have no more pending
|
// When Carol's sweep gets confirmed, she should have no more pending
|
||||||
// channels.
|
// channels.
|
||||||
block = ht.Miner.MineBlocksAndAssertNumTxes(1, 1)[0]
|
block = ht.MineBlocksAndAssertNumTxes(1, 1)[0]
|
||||||
ht.Miner.AssertTxInBlock(block, carolSweep)
|
ht.Miner.AssertTxInBlock(block, carolSweep)
|
||||||
ht.AssertNumPendingForceClose(carol, 0)
|
ht.AssertNumPendingForceClose(carol, 0)
|
||||||
|
|
||||||
@@ -1401,7 +1401,7 @@ func runMultiHopHtlcRemoteChainClaim(ht *lntemp.HarnessTest,
|
|||||||
|
|
||||||
// Mine enough blocks for the timelock to expire.
|
// Mine enough blocks for the timelock to expire.
|
||||||
numBlocks := uint32(forceCloseChan.BlocksTilMaturity)
|
numBlocks := uint32(forceCloseChan.BlocksTilMaturity)
|
||||||
ht.MineBlocksAssertNodesSync(numBlocks)
|
ht.MineBlocks(numBlocks)
|
||||||
|
|
||||||
// Both Alice and Bob show broadcast their commit sweeps.
|
// Both Alice and Bob show broadcast their commit sweeps.
|
||||||
aliceCommitOutpoint := wire.OutPoint{
|
aliceCommitOutpoint := wire.OutPoint{
|
||||||
@@ -1418,7 +1418,7 @@ func runMultiHopHtlcRemoteChainClaim(ht *lntemp.HarnessTest,
|
|||||||
bobCommitSweepTxid := bobCommitSweep.TxHash()
|
bobCommitSweepTxid := bobCommitSweep.TxHash()
|
||||||
|
|
||||||
// Confirm their sweeps.
|
// Confirm their sweeps.
|
||||||
block := ht.Miner.MineBlocksAndAssertNumTxes(1, 2)[0]
|
block := ht.MineBlocksAndAssertNumTxes(1, 2)[0]
|
||||||
ht.Miner.AssertTxInBlock(block, &aliceCommitSweepTxid)
|
ht.Miner.AssertTxInBlock(block, &aliceCommitSweepTxid)
|
||||||
ht.Miner.AssertTxInBlock(block, &bobCommitSweepTxid)
|
ht.Miner.AssertTxInBlock(block, &bobCommitSweepTxid)
|
||||||
|
|
||||||
@@ -1583,7 +1583,7 @@ func runMultiHopHtlcAggregation(ht *lntemp.HarnessTest,
|
|||||||
numBlocks := padCLTV(
|
numBlocks := padCLTV(
|
||||||
uint32(finalCltvDelta - lncfg.DefaultOutgoingBroadcastDelta),
|
uint32(finalCltvDelta - lncfg.DefaultOutgoingBroadcastDelta),
|
||||||
)
|
)
|
||||||
ht.MineBlocksAssertNodesSync(numBlocks)
|
ht.MineBlocks(numBlocks)
|
||||||
|
|
||||||
// Bob's force close transaction should now be found in the mempool. If
|
// Bob's force close transaction should now be found in the mempool. If
|
||||||
// there are anchors, we also expect Bob's anchor sweep.
|
// there are anchors, we also expect Bob's anchor sweep.
|
||||||
@@ -1635,7 +1635,7 @@ func runMultiHopHtlcAggregation(ht *lntemp.HarnessTest,
|
|||||||
require.NoError(ht, restartCarol())
|
require.NoError(ht, restartCarol())
|
||||||
|
|
||||||
// Mine a block to confirm the closing transaction.
|
// Mine a block to confirm the closing transaction.
|
||||||
ht.Miner.MineBlocksAndAssertNumTxes(1, expectedTxes)
|
ht.MineBlocksAndAssertNumTxes(1, expectedTxes)
|
||||||
|
|
||||||
// Let Alice settle her invoices. When Bob now gets the preimages, he
|
// Let Alice settle her invoices. When Bob now gets the preimages, he
|
||||||
// has no other option than to broadcast his second-level transactions
|
// has no other option than to broadcast his second-level transactions
|
||||||
@@ -1709,7 +1709,7 @@ func runMultiHopHtlcAggregation(ht *lntemp.HarnessTest,
|
|||||||
// Mine a block to confirm the all the transactions, including Carol's
|
// Mine a block to confirm the all the transactions, including Carol's
|
||||||
// commitment tx, anchor tx(optional), and the second-level timeout and
|
// commitment tx, anchor tx(optional), and the second-level timeout and
|
||||||
// success txes.
|
// success txes.
|
||||||
ht.Miner.MineBlocksAndAssertNumTxes(1, expectedTxes)
|
ht.MineBlocksAndAssertNumTxes(1, expectedTxes)
|
||||||
|
|
||||||
// At this point, Bob should have broadcast his second layer success
|
// At this point, Bob should have broadcast his second layer success
|
||||||
// transaction, and should have sent it to the nursery for incubation,
|
// transaction, and should have sent it to the nursery for incubation,
|
||||||
@@ -1723,7 +1723,7 @@ func runMultiHopHtlcAggregation(ht *lntemp.HarnessTest,
|
|||||||
if c != lnrpc.CommitmentType_SCRIPT_ENFORCED_LEASE {
|
if c != lnrpc.CommitmentType_SCRIPT_ENFORCED_LEASE {
|
||||||
// If we then mine additional blocks, Bob can sweep his
|
// If we then mine additional blocks, Bob can sweep his
|
||||||
// commitment output.
|
// commitment output.
|
||||||
ht.MineBlocksAssertNodesSync(defaultCSV - 2)
|
ht.MineBlocks(defaultCSV - 2)
|
||||||
|
|
||||||
// Find the commitment sweep.
|
// Find the commitment sweep.
|
||||||
bobCommitSweep := ht.Miner.GetNumTxsFromMempool(1)[0]
|
bobCommitSweep := ht.Miner.GetNumTxsFromMempool(1)[0]
|
||||||
@@ -1756,13 +1756,13 @@ func runMultiHopHtlcAggregation(ht *lntemp.HarnessTest,
|
|||||||
// the nursery waits an extra block before sweeping. Before the blocks
|
// the nursery waits an extra block before sweeping. Before the blocks
|
||||||
// are mined, we should expect to see Bob's commit sweep in the mempool.
|
// are mined, we should expect to see Bob's commit sweep in the mempool.
|
||||||
case lnrpc.CommitmentType_LEGACY:
|
case lnrpc.CommitmentType_LEGACY:
|
||||||
ht.Miner.MineBlocksAndAssertNumTxes(2, 1)
|
ht.MineBlocksAndAssertNumTxes(2, 1)
|
||||||
|
|
||||||
// Mining one additional block, Bob's second level tx is mature, and he
|
// Mining one additional block, Bob's second level tx is mature, and he
|
||||||
// can sweep the output. Before the blocks are mined, we should expect
|
// can sweep the output. Before the blocks are mined, we should expect
|
||||||
// to see Bob's commit sweep in the mempool.
|
// to see Bob's commit sweep in the mempool.
|
||||||
case lnrpc.CommitmentType_ANCHORS:
|
case lnrpc.CommitmentType_ANCHORS:
|
||||||
ht.Miner.MineBlocksAndAssertNumTxes(1, 1)
|
ht.MineBlocksAndAssertNumTxes(1, 1)
|
||||||
|
|
||||||
// Since Bob is the initiator of the Bob-Carol script-enforced leased
|
// Since Bob is the initiator of the Bob-Carol script-enforced leased
|
||||||
// channel, he incurs an additional CLTV when sweeping outputs back to
|
// channel, he incurs an additional CLTV when sweeping outputs back to
|
||||||
@@ -1779,7 +1779,7 @@ func runMultiHopHtlcAggregation(ht *lntemp.HarnessTest,
|
|||||||
_, height := ht.Miner.GetBestBlock()
|
_, height := ht.Miner.GetBestBlock()
|
||||||
bob.AddToLogf("itest: now mine %d blocks at height %d",
|
bob.AddToLogf("itest: now mine %d blocks at height %d",
|
||||||
numBlocks, height)
|
numBlocks, height)
|
||||||
ht.MineBlocksAssertNodesSync(numBlocks)
|
ht.MineBlocks(numBlocks)
|
||||||
|
|
||||||
default:
|
default:
|
||||||
ht.Fatalf("unhandled commitment type %v", c)
|
ht.Fatalf("unhandled commitment type %v", c)
|
||||||
@@ -1810,7 +1810,7 @@ func runMultiHopHtlcAggregation(ht *lntemp.HarnessTest,
|
|||||||
// When we mine one additional block, that will confirm Bob's second
|
// When we mine one additional block, that will confirm Bob's second
|
||||||
// level sweep. Now Bob should have no pending channels anymore, as
|
// level sweep. Now Bob should have no pending channels anymore, as
|
||||||
// this just resolved it by the confirmation of the sweep transaction.
|
// this just resolved it by the confirmation of the sweep transaction.
|
||||||
block := ht.Miner.MineBlocksAndAssertNumTxes(1, 1)[0]
|
block := ht.MineBlocksAndAssertNumTxes(1, 1)[0]
|
||||||
ht.Miner.AssertTxInBlock(block, &bobSweep)
|
ht.Miner.AssertTxInBlock(block, &bobSweep)
|
||||||
ht.AssertNumPendingForceClose(bob, 0)
|
ht.AssertNumPendingForceClose(bob, 0)
|
||||||
|
|
||||||
@@ -1861,7 +1861,7 @@ func createThreeHopNetwork(ht *lntemp.HarnessTest,
|
|||||||
ht.FundCoinsUnconfirmed(btcutil.SatoshiPerBitcoin, carol)
|
ht.FundCoinsUnconfirmed(btcutil.SatoshiPerBitcoin, carol)
|
||||||
|
|
||||||
// Mine 1 block to get the above coins confirmed.
|
// Mine 1 block to get the above coins confirmed.
|
||||||
ht.MineBlocksAssertNodesSync(1)
|
ht.MineBlocks(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
// We'll start the test by creating a channel between Alice and Bob,
|
// We'll start the test by creating a channel between Alice and Bob,
|
||||||
|
|||||||
Reference in new issue
Block a user