itest: document the flake found in preimage extraction
We now use dedicated methods to properly document the flakes in *one* place.
This commit is contained in:
4 files changed
+40
-49
No files matched your search
@@ -0,0 +1,33 @@
|
|||||||
|
package itest
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/lightningnetwork/lnd/lntest"
|
||||||
|
)
|
||||||
|
|
||||||
|
// flakePreimageSettlement documents a flake found when testing the preimage
|
||||||
|
// extraction logic in a force close. The scenario is,
|
||||||
|
// - Alice and Bob have a channel.
|
||||||
|
// - Alice sends an HTLC to Bob, and Bob won't settle it.
|
||||||
|
// - Alice goes offline.
|
||||||
|
// - Bob force closes the channel and claims the HTLC using the preimage using
|
||||||
|
// a sweeping tx.
|
||||||
|
//
|
||||||
|
// TODO(yy): Expose blockbeat to the link layer so the preimage extraction
|
||||||
|
// happens in the same block where it's spent.
|
||||||
|
func flakePreimageSettlement(ht *lntest.HarnessTest) {
|
||||||
|
// Mine a block to trigger the sweep. This is needed because the
|
||||||
|
// preimage extraction logic from the link is not managed by the
|
||||||
|
// blockbeat, which means the preimage may be sent to the contest
|
||||||
|
// resolver after it's launched, which means Bob would miss the block to
|
||||||
|
// launch the resolver.
|
||||||
|
ht.MineEmptyBlocks(1)
|
||||||
|
|
||||||
|
// Sleep for 2 seconds, which is needed to make sure the mempool has the
|
||||||
|
// correct tx. The above mined block can cause an RBF, if the preimage
|
||||||
|
// extraction has already been finished before the block is mined. This
|
||||||
|
// means Bob would have created the sweeping tx - mining another block
|
||||||
|
// would cause the sweeper to RBF it.
|
||||||
|
time.Sleep(2 * time.Second)
|
||||||
|
}
|
||||||
@@ -1371,13 +1371,7 @@ func testFailingChannel(ht *lntest.HarnessTest) {
|
|||||||
// Carol will use the correct preimage to resolve the HTLC on-chain.
|
// Carol will use the correct preimage to resolve the HTLC on-chain.
|
||||||
ht.AssertNumPendingSweeps(carol, 1)
|
ht.AssertNumPendingSweeps(carol, 1)
|
||||||
|
|
||||||
// Mine a block to trigger the sweep. This is needed because the
|
flakePreimageSettlement(ht)
|
||||||
// preimage extraction logic from the link is not managed by the
|
|
||||||
// blockbeat, which means the preimage may be sent to the contest
|
|
||||||
// resolver after it's launched.
|
|
||||||
//
|
|
||||||
// TODO(yy): Expose blockbeat to the link layer.
|
|
||||||
ht.MineEmptyBlocks(1)
|
|
||||||
|
|
||||||
// Carol should have broadcast her sweeping tx.
|
// Carol should have broadcast her sweeping tx.
|
||||||
ht.AssertNumTxsInMempool(1)
|
ht.AssertNumTxsInMempool(1)
|
||||||
|
|||||||
@@ -1842,13 +1842,7 @@ func runLocalClaimIncomingHTLC(ht *lntest.HarnessTest,
|
|||||||
// - the anchor output from channel Bob=>Carol.
|
// - the anchor output from channel Bob=>Carol.
|
||||||
ht.AssertNumPendingSweeps(bob, 3)
|
ht.AssertNumPendingSweeps(bob, 3)
|
||||||
|
|
||||||
// Mine a block to trigger the sweep. This is needed because the
|
flakePreimageSettlement(ht)
|
||||||
// preimage extraction logic from the link is not managed by the
|
|
||||||
// blockbeat, which means the preimage may be sent to the contest
|
|
||||||
// resolver after it's launched.
|
|
||||||
//
|
|
||||||
// TODO(yy): Expose blockbeat to the link layer.
|
|
||||||
ht.MineEmptyBlocks(1)
|
|
||||||
|
|
||||||
// At this point, Bob should have broadcast his second layer success
|
// At this point, Bob should have broadcast his second layer success
|
||||||
// tx, and should have sent it to his sweeper.
|
// tx, and should have sent it to his sweeper.
|
||||||
@@ -2126,13 +2120,7 @@ func runLocalClaimIncomingHTLCLeased(ht *lntest.HarnessTest,
|
|||||||
// - the anchor output from channel Bob=>Carol.
|
// - the anchor output from channel Bob=>Carol.
|
||||||
ht.AssertNumPendingSweeps(bob, 3)
|
ht.AssertNumPendingSweeps(bob, 3)
|
||||||
|
|
||||||
// Mine a block to trigger the sweep. This is needed because the
|
flakePreimageSettlement(ht)
|
||||||
// preimage extraction logic from the link is not managed by the
|
|
||||||
// blockbeat, which means the preimage may be sent to the contest
|
|
||||||
// resolver after it's launched.
|
|
||||||
//
|
|
||||||
// TODO(yy): Expose blockbeat to the link layer.
|
|
||||||
ht.MineEmptyBlocks(1)
|
|
||||||
|
|
||||||
// At this point, Bob should have broadcast his second layer success
|
// At this point, Bob should have broadcast his second layer success
|
||||||
// tx, and should have sent it to his sweeper.
|
// tx, and should have sent it to his sweeper.
|
||||||
@@ -2527,13 +2515,7 @@ func runLocalPreimageClaim(ht *lntest.HarnessTest,
|
|||||||
ht.MineEmptyBlocks(1)
|
ht.MineEmptyBlocks(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mine a block to trigger the sweep. This is needed because the
|
flakePreimageSettlement(ht)
|
||||||
// preimage extraction logic from the link is not managed by the
|
|
||||||
// blockbeat, which means the preimage may be sent to the contest
|
|
||||||
// resolver after it's launched.
|
|
||||||
//
|
|
||||||
// TODO(yy): Expose blockbeat to the link layer.
|
|
||||||
ht.MineEmptyBlocks(1)
|
|
||||||
|
|
||||||
// Bob should broadcast the sweeping of the direct preimage spent now.
|
// Bob should broadcast the sweeping of the direct preimage spent now.
|
||||||
bobHtlcSweep := ht.GetNumTxsFromMempool(1)[0]
|
bobHtlcSweep := ht.GetNumTxsFromMempool(1)[0]
|
||||||
@@ -2791,13 +2773,7 @@ func runLocalPreimageClaimLeased(ht *lntest.HarnessTest,
|
|||||||
// - the htlc sweeping tx.
|
// - the htlc sweeping tx.
|
||||||
ht.AssertNumPendingSweeps(bob, 3)
|
ht.AssertNumPendingSweeps(bob, 3)
|
||||||
|
|
||||||
// Mine a block to trigger the sweep. This is needed because the
|
flakePreimageSettlement(ht)
|
||||||
// preimage extraction logic from the link is not managed by the
|
|
||||||
// blockbeat, which means the preimage may be sent to the contest
|
|
||||||
// resolver after it's launched.
|
|
||||||
//
|
|
||||||
// TODO(yy): Expose blockbeat to the link layer.
|
|
||||||
ht.MineEmptyBlocks(1)
|
|
||||||
|
|
||||||
// Bob should broadcast the sweeping of the direct preimage spent now.
|
// Bob should broadcast the sweeping of the direct preimage spent now.
|
||||||
bobHtlcSweep := ht.GetNumTxsFromMempool(1)[0]
|
bobHtlcSweep := ht.GetNumTxsFromMempool(1)[0]
|
||||||
@@ -3223,13 +3199,7 @@ func runHtlcAggregation(ht *lntest.HarnessTest,
|
|||||||
// txns.
|
// txns.
|
||||||
ht.AssertNumPendingSweeps(bob, numInvoices*2)
|
ht.AssertNumPendingSweeps(bob, numInvoices*2)
|
||||||
|
|
||||||
// Mine a block to trigger the sweep. This is needed because the
|
flakePreimageSettlement(ht)
|
||||||
// preimage extraction logic from the link is not managed by the
|
|
||||||
// blockbeat, which means the preimage may be sent to the contest
|
|
||||||
// resolver after it's launched.
|
|
||||||
//
|
|
||||||
// TODO(yy): Expose blockbeat to the link layer.
|
|
||||||
ht.MineEmptyBlocks(1)
|
|
||||||
|
|
||||||
// We expect to see three sweeping txns:
|
// We expect to see three sweeping txns:
|
||||||
// 1. Bob's sweeping tx for all timeout HTLCs.
|
// 1. Bob's sweeping tx for all timeout HTLCs.
|
||||||
|
|||||||
@@ -152,13 +152,7 @@ func testPaymentSucceededHTLCRemoteSwept(ht *lntest.HarnessTest) {
|
|||||||
// Alice should have a pending force close channel.
|
// Alice should have a pending force close channel.
|
||||||
ht.AssertNumPendingForceClose(alice, 1)
|
ht.AssertNumPendingForceClose(alice, 1)
|
||||||
|
|
||||||
// Mine a block to trigger the sweep. This is needed because the
|
flakePreimageSettlement(ht)
|
||||||
// preimage extraction logic from the link is not managed by the
|
|
||||||
// blockbeat, which means the preimage may be sent to the contest
|
|
||||||
// resolver after it's launched.
|
|
||||||
//
|
|
||||||
// TODO(yy): Expose blockbeat to the link layer.
|
|
||||||
ht.MineEmptyBlocks(1)
|
|
||||||
|
|
||||||
// Mine Bob's sweeping tx.
|
// Mine Bob's sweeping tx.
|
||||||
ht.MineBlocksAndAssertNumTxes(1, 1)
|
ht.MineBlocksAndAssertNumTxes(1, 1)
|
||||||
|
|||||||
Reference in new issue
Block a user