@@ -1272,8 +1272,17 @@ func testChannelFundingWithUnstableUtxos(ht *lntest.HarnessTest) {
12721272 // Make sure Carol sees her to_remote output from the force close tx.
12731273 ht .AssertNumPendingSweeps (carol , 1 )
12741274
1275- // We need to wait for carol initiating the sweep of the to_remote
1276- // output of chanPoint2.
1275+ // Wait for Carol's sweep transaction to appear in the mempool. Due to
1276+ // async confirmation notifications, there's a race between when the
1277+ // sweep is registered and when the sweeper processes the next block.
1278+ // The sweeper uses immediate=false, so it broadcasts on the next block
1279+ // after registration. Mine an empty block to trigger the broadcast.
1280+ ht .MineEmptyBlocks (1 )
1281+
1282+ // Now the sweep should be in the mempool.
1283+ ht .AssertNumTxsInMempool (1 )
1284+
1285+ // Now we should see the unconfirmed UTXO from the sweep.
12771286 utxo := ht .AssertNumUTXOsUnconfirmed (carol , 1 )[0 ]
12781287
12791288 // We now try to open channel using the unconfirmed utxo.
@@ -1329,6 +1338,11 @@ func testChannelFundingWithUnstableUtxos(ht *lntest.HarnessTest) {
13291338 // Make sure Carol sees her to_remote output from the force close tx.
13301339 ht .AssertNumPendingSweeps (carol , 1 )
13311340
1341+ // Mine an empty block to trigger the sweep broadcast (same fix as
1342+ // above).
1343+ ht .MineEmptyBlocks (1 )
1344+ ht .AssertNumTxsInMempool (1 )
1345+
13321346 // Wait for the to_remote sweep tx to show up in carol's wallet.
13331347 ht .AssertNumUTXOsUnconfirmed (carol , 1 )
13341348
0 commit comments