@@ -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" 
@@ -2908,13 +2909,13 @@ func testCustomChannelsHtlcSuccess(_ context.Context, net *NetworkHarness,
29082909	// With all of the HTLCs established, we'll now force close the channel with 
29092910	// Alice. 
29102911	t .Logf ("Force close by Alice w/ HTLCs..." )
2911- 	daveChanPoint  :=  & lnrpc.ChannelPoint {
2912+ 	aliceChanPoint  :=  & lnrpc.ChannelPoint {
29122913		OutputIndex : uint32 (assetFundResp .OutputIndex ),
29132914		FundingTxid : & lnrpc.ChannelPoint_FundingTxidStr {
29142915			FundingTxidStr : assetFundResp .Txid ,
29152916		},
29162917	}
2917- 	_ , closeTxid , err  :=  net .CloseChannel (alice , daveChanPoint , true )
2918+ 	_ , closeTxid , err  :=  net .CloseChannel (alice , aliceChanPoint , true )
29182919	require .NoError (t .t , err )
29192920
29202921	t .Logf ("Channel closed! Mining blocks, close_txid=%v" , closeTxid )
@@ -3051,15 +3052,34 @@ func testCustomChannelsHtlcSuccess(_ context.Context, net *NetworkHarness,
30513052	// sweep the HTLC into her wallet. 
30523053	mineBlocks (t , net , closeExpiryInfo .csvDelay , 0 )
30533054
3054- 	// With the way the sweeper works, we'll now need to mine an extra block to 
3055- 	// trigger the sweep. 
3056- 	mineBlocks (t , net , 1 , 0 )
3055+ 	// We'll pause here and wait until the sweeper recognizes that we've offered 
3056+ 	// the second level sweep transaction. 
3057+ 	err  =  wait .NoError (func () error  {
3058+ 		alicePendingSweeps , err  :=  alice .WalletKitClient .PendingSweeps (
3059+ 			ctxb , & walletrpc.PendingSweepsRequest {},
3060+ 		)
3061+ 		if  err  !=  nil  {
3062+ 			return  err 
3063+ 		}
30573064
3058- 	time .Sleep (time .Second  *  3 )
3065+ 		for  _ , sweep  :=  range  alicePendingSweeps .PendingSweeps  {
3066+ 			if  sweep .WitnessType  == 
3067+ 				walletrpc .WitnessType_TAPROOT_HTLC_ACCEPTED_SUCCESS_SECOND_LEVEL  {
3068+ 
3069+ 				return  nil 
3070+ 			}
3071+ 		}
30593072
3060- 	t .Logf ("Confirming Alice's remote HTLC success sweep" )
3073+ 		return  fmt .Errorf ("failed to find second level sweep: %v" ,
3074+ 			toProtoJSON (t .t , alicePendingSweeps ))
3075+ 	}, time .Second * 5 )
3076+ 	require .NoError (t .t , err )
3077+ 
3078+ 	// Now that we know the sweep was offered, we'll mine an extra block to 
3079+ 	// actually trigger a sweeper broadcast. 
3080+ 	mineBlocks (t , net , 1 , 0 )
30613081
3062- 	// TODO(roasbef): replace w/ mine until broadcast? 
3082+ 	t . Logf ( "Confirming Alice's local HTLC success sweep" ) 
30633083
30643084	// We'll mine one final block which will confirm Alice's sweep transaction. 
30653085	mineBlocks (t , net , 1 , 1 )
0 commit comments