Skip to content

Commit 8afe62a

Browse files
authored
Merge pull request #9981 from yyforyongyu/fix-sweep-itest
itest: fix flake in `sweep_cpfp_anchor_incoming_timeout`
2 parents 45c1564 + 0e24764 commit 8afe62a

File tree

1 file changed

+20
-16
lines changed

1 file changed

+20
-16
lines changed

itest/lnd_sweep_test.go

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -665,6 +665,26 @@ func testSweepCPFPAnchorIncomingTimeout(ht *lntest.HarnessTest) {
665665
// needed to clean up the mempool.
666666
ht.MineBlocksAndAssertNumTxes(1, 2)
667667

668+
// We mined a block above, which confirmed Bob's force closing tx and
669+
// his anchor sweeping tx. Bob should now have a new change output
670+
// created from that sweeping tx, which can be used as the input to
671+
// sweep his HTLC.
672+
// Also in the above mined block, the HTLC will be offered to Bob's
673+
// sweeper for sweeping, which requires a wallet utxo since it's a
674+
// zero fee HTLC.
675+
// There's the possible race that,
676+
// - btcwallet is processing this block, and marking the change output
677+
// as confirmed.
678+
// - btcwallet notifies LND about the new block.
679+
// If the block notification comes first, LND's sweeper will not be
680+
// able to sweep this HTLC as it thinks the wallet UTXO is still
681+
// unconfirmed.
682+
// TODO(yy): To fix the above issue, we need to make sure btcwallet
683+
// should update its internal state first before notifying the new
684+
// block, which is scheduled to be fixed during the btcwallet SQLizing
685+
// saga.
686+
ht.MineEmptyBlocks(1)
687+
668688
// The above mined block should confirm Bob's force close tx, and his
669689
// contractcourt will offer the HTLC to his sweeper. We are not testing
670690
// the HTLC sweeping behaviors so we just perform a simple check and
@@ -766,14 +786,6 @@ func testSweepHTLCs(ht *lntest.HarnessTest) {
766786
// - when sweeping HTLCs, he needs one utxo for each sweep.
767787
numUTXOs := 2
768788

769-
// Bob should have enough wallet UTXOs here to sweep the HTLC in the
770-
// end of this test. However, due to a known issue, Bob's wallet may
771-
// report there's no UTXO available. For details,
772-
// - https://github.com/lightningnetwork/lnd/issues/8786
773-
//
774-
// TODO(yy): remove this extra UTXO once the issue is resolved.
775-
numUTXOs++
776-
777789
// For neutrino backend, we need two more UTXOs for Bob to create his
778790
// sweeping txns.
779791
if ht.IsNeutrinoBackend() {
@@ -1802,14 +1814,6 @@ func testFeeReplacement(ht *lntest.HarnessTest) {
18021814
// - when sweeping HTLCs, he needs one utxo for each sweep.
18031815
numUTXOs := 2
18041816

1805-
// Bob should have enough wallet UTXOs here to sweep the HTLC in the
1806-
// end of this test. However, due to a known issue, Bob's wallet may
1807-
// report there's no UTXO available. For details,
1808-
// - https://github.com/lightningnetwork/lnd/issues/8786
1809-
//
1810-
// TODO(yy): remove this extra UTXO once the issue is resolved.
1811-
numUTXOs++
1812-
18131817
// For neutrino backend, we need two more UTXOs for Bob to create his
18141818
// sweeping txns.
18151819
if ht.IsNeutrinoBackend() {

0 commit comments

Comments
 (0)