lntest+itest: clean mempool in testHtlcTimeoutResolverExtractPreimageRemote
This commit is contained in:
2 files changed
+36
-18
No files matched your search
@@ -1936,11 +1936,6 @@ func runExtraPreimageFromRemoteCommit(ht *lntest.HarnessTest,
|
|||||||
// notice the force close from Carol.
|
// notice the force close from Carol.
|
||||||
require.NoError(ht, restartBob())
|
require.NoError(ht, restartBob())
|
||||||
|
|
||||||
// For anchor channels, Bob should sweep his anchor output.
|
|
||||||
if lntest.CommitTypeHasAnchors(c) {
|
|
||||||
ht.Miner.AssertNumTxsInMempool(1)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get the current height to compute number of blocks to mine to
|
// Get the current height to compute number of blocks to mine to
|
||||||
// trigger the htlc timeout resolver from Bob.
|
// trigger the htlc timeout resolver from Bob.
|
||||||
_, height := ht.Miner.GetBestBlock()
|
_, height := ht.Miner.GetBestBlock()
|
||||||
@@ -1949,23 +1944,52 @@ func runExtraPreimageFromRemoteCommit(ht *lntest.HarnessTest,
|
|||||||
numBlocks = htlc.ExpirationHeight - uint32(height) -
|
numBlocks = htlc.ExpirationHeight - uint32(height) -
|
||||||
lncfg.DefaultOutgoingBroadcastDelta
|
lncfg.DefaultOutgoingBroadcastDelta
|
||||||
|
|
||||||
// Mine empty blocks so Carol's htlc success tx stays in mempool. Once
|
// We should now have Carol's htlc suucess tx in the mempool.
|
||||||
// the height is reached, Bob's timeout resolver will resolve the htlc
|
numTxesMempool := 1
|
||||||
// by extracing the preimage from the mempool.
|
|
||||||
ht.MineEmptyBlocks(int(numBlocks))
|
|
||||||
|
|
||||||
// For neutrino backend, the timeout resolver needs to extract the
|
// For neutrino backend, the timeout resolver needs to extract the
|
||||||
// preimage from the blocks.
|
// preimage from the blocks.
|
||||||
if ht.IsNeutrinoBackend() {
|
if ht.IsNeutrinoBackend() {
|
||||||
// Mine a block to confirm Carol's 2nd level success tx.
|
// Mine a block to confirm Carol's 2nd level success tx.
|
||||||
ht.MineBlocksAndAssertNumTxes(1, 1)
|
ht.MineBlocksAndAssertNumTxes(1, 1)
|
||||||
|
numTxesMempool--
|
||||||
}
|
}
|
||||||
|
// Mine empty blocks so Carol's htlc success tx stays in mempool. Once
|
||||||
|
// the height is reached, Bob's timeout resolver will resolve the htlc
|
||||||
|
// by extracing the preimage from the mempool.
|
||||||
|
ht.MineEmptyBlocks(int(numBlocks))
|
||||||
|
|
||||||
// Finally, check that the Alice's payment is marked as succeeded as
|
// Finally, check that the Alice's payment is marked as succeeded as
|
||||||
// Bob has settled the htlc using the preimage extracted from Carol's
|
// Bob has settled the htlc using the preimage extracted from Carol's
|
||||||
// 2nd level success tx.
|
// 2nd level success tx.
|
||||||
ht.AssertPaymentStatus(alice, preimage, lnrpc.Payment_SUCCEEDED)
|
ht.AssertPaymentStatus(alice, preimage, lnrpc.Payment_SUCCEEDED)
|
||||||
|
|
||||||
|
switch c {
|
||||||
|
// For non-anchor channel type, we should expect to see Bob's commit
|
||||||
|
// sweep in the mempool.
|
||||||
|
case lnrpc.CommitmentType_LEGACY:
|
||||||
|
numTxesMempool++
|
||||||
|
|
||||||
|
// For non-anchor channel type, we should expect to see Bob's commit
|
||||||
|
// sweep and his anchor sweep tx in the mempool.
|
||||||
|
case lnrpc.CommitmentType_ANCHORS:
|
||||||
|
numTxesMempool += 2
|
||||||
|
|
||||||
|
// For script-enforced leased channel, we should expect to see Bob's
|
||||||
|
// anchor sweep tx in the mempool.
|
||||||
|
case lnrpc.CommitmentType_SCRIPT_ENFORCED_LEASE:
|
||||||
|
numTxesMempool++
|
||||||
|
|
||||||
|
// For neutrino backend, because of the additional block mined,
|
||||||
|
// Bob's output is now mature.
|
||||||
|
if ht.IsNeutrinoBackend() {
|
||||||
|
numTxesMempool++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mine a block to clean the mempool.
|
||||||
|
ht.MineBlocksAndAssertNumTxes(1, numTxesMempool)
|
||||||
|
|
||||||
// NOTE: for non-standby nodes there's no need to clean up the force
|
// NOTE: for non-standby nodes there's no need to clean up the force
|
||||||
// close as long as the mempool is cleaned.
|
// close as long as the mempool is cleaned.
|
||||||
ht.CleanShutDown()
|
ht.CleanShutDown()
|
||||||
|
|||||||
+3
-9
@@ -1646,18 +1646,12 @@ func (h *HarnessTest) cleanMempool() {
|
|||||||
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.
|
||||||
|
h.AssertActiveNodesSyncedTo(bestBlock)
|
||||||
|
|
||||||
return fmt.Errorf("still have %d txes in mempool", len(mem))
|
return fmt.Errorf("still have %d txes in mempool", len(mem))
|
||||||
}, wait.MinerMempoolTimeout)
|
}, wait.MinerMempoolTimeout)
|
||||||
require.NoError(h, err, "timeout cleaning up mempool")
|
require.NoError(h, err, "timeout cleaning up mempool")
|
||||||
|
|
||||||
// Exit early if the best block is nil, which means we haven't mined
|
|
||||||
// any blocks during the cleanup.
|
|
||||||
if bestBlock == nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Make sure all the active nodes are synced.
|
|
||||||
h.AssertActiveNodesSyncedTo(bestBlock)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// CleanShutDown is used to quickly end a test by shutting down all non-standby
|
// CleanShutDown is used to quickly end a test by shutting down all non-standby
|
||||||
|
|||||||
Reference in new issue
Block a user