@@ -24,6 +24,7 @@ import (
2424 "github.com/lightningnetwork/lnd/fn"
2525 "github.com/lightningnetwork/lnd/lnrpc"
2626 "github.com/lightningnetwork/lnd/lnrpc/invoicesrpc"
27+ "github.com/lightningnetwork/lnd/lnrpc/walletrpc"
2728 "github.com/lightningnetwork/lnd/lntest"
2829 "github.com/lightningnetwork/lnd/lntest/port"
2930 "github.com/lightningnetwork/lnd/lntest/wait"
@@ -2907,13 +2908,13 @@ func testCustomChannelsHtlcSuccess(_ context.Context, net *NetworkHarness,
29072908 // With all of the HTLCs established, we'll now force close the channel with
29082909 // Alice.
29092910 t .Logf ("Force close by Alice w/ HTLCs..." )
2910- daveChanPoint := & lnrpc.ChannelPoint {
2911+ aliceChanPoint := & lnrpc.ChannelPoint {
29112912 OutputIndex : uint32 (assetFundResp .OutputIndex ),
29122913 FundingTxid : & lnrpc.ChannelPoint_FundingTxidStr {
29132914 FundingTxidStr : assetFundResp .Txid ,
29142915 },
29152916 }
2916- _ , closeTxid , err := net .CloseChannel (alice , daveChanPoint , true )
2917+ _ , closeTxid , err := net .CloseChannel (alice , aliceChanPoint , true )
29172918 require .NoError (t .t , err )
29182919
29192920 t .Logf ("Channel closed! Mining blocks, close_txid=%v" , closeTxid )
@@ -3050,15 +3051,34 @@ func testCustomChannelsHtlcSuccess(_ context.Context, net *NetworkHarness,
30503051 // sweep the HTLC into her wallet.
30513052 mineBlocks (t , net , closeExpiryInfo .csvDelay , 0 )
30523053
3053- // With the way the sweeper works, we'll now need to mine an extra block to
3054- // trigger the sweep.
3055- mineBlocks (t , net , 1 , 0 )
3054+ // We'll pause here and wait until the sweeper recognizes that we've offered
3055+ // the second level sweep transaction.
3056+ err = wait .NoError (func () error {
3057+ alicePendingSweeps , err := alice .WalletKitClient .PendingSweeps (
3058+ ctxb , & walletrpc.PendingSweepsRequest {},
3059+ )
3060+ if err != nil {
3061+ return err
3062+ }
30563063
3057- time .Sleep (time .Second * 3 )
3064+ for _ , sweep := range alicePendingSweeps .PendingSweeps {
3065+ if sweep .WitnessType ==
3066+ walletrpc .WitnessType_TAPROOT_HTLC_ACCEPTED_SUCCESS_SECOND_LEVEL {
3067+
3068+ return nil
3069+ }
3070+ }
30583071
3059- t .Logf ("Confirming Alice's remote HTLC success sweep" )
3072+ return fmt .Errorf ("failed to find second level sweep: %v" ,
3073+ toProtoJSON (t .t , alicePendingSweeps ))
3074+ }, time .Second * 5 )
3075+ require .NoError (t .t , err )
3076+
3077+ // Now that we know the sweep was offered, we'll mine an extra block to
3078+ // actually trigger a sweeper broadcast.
3079+ mineBlocks (t , net , 1 , 0 )
30603080
3061- // TODO(roasbef): replace w/ mine until broadcast?
3081+ t . Logf ( "Confirming Alice's local HTLC success sweep" )
30623082
30633083 // We'll mine one final block which will confirm Alice's sweep transaction.
30643084 mineBlocks (t , net , 1 , 1 )
0 commit comments