@@ -2389,7 +2389,7 @@ func testCustomChannelsLiquidityEdgeCasesCore(ctx context.Context,
23892389	)
23902390	charlieFundingAmount  :=  cents .Amount  -  uint64 (2 * 400_000 )
23912391
2392- 	_ , _ , _   =  createTestAssetNetwork (
2392+ 	_ , _ , chanPointEF   : =createTestAssetNetwork (
23932393		t , net , charlieTap , daveTap , erinTap , fabiaTap , yaraTap ,
23942394		universeTap , cents , 400_000 , charlieFundingAmount ,
23952395		daveFundingAmount , erinFundingAmount , 0 ,
@@ -2407,6 +2407,37 @@ func testCustomChannelsLiquidityEdgeCasesCore(ctx context.Context,
24072407
24082408	logBalance (t .t , nodes , assetID , "initial" )
24092409
2410+ 	// Edge case: We send a single satoshi keysend payment from Dave to 
2411+ 	// Fabia. Which will make it so that Fabia's balance in the channel 
2412+ 	// between Erin and her is 1 satoshi, which is below the dust limit. 
2413+ 	// This is only allowed while Fabia doesn't have any assets on her side 
2414+ 	// yet. 
2415+ 	erinFabiaChan  :=  fetchChannel (t .t , fabia , chanPointEF )
2416+ 	hinEF  :=  & lnrpc.HopHint {
2417+ 		NodeId :                    erin .PubKeyStr ,
2418+ 		ChanId :                    erinFabiaChan .PeerScidAlias ,
2419+ 		CltvExpiryDelta :           80 ,
2420+ 		FeeBaseMsat :               1000 ,
2421+ 		FeeProportionalMillionths : 1 ,
2422+ 	}
2423+ 	sendKeySendPayment (
2424+ 		t .t , dave , fabia , 1 , withPayRouteHints ([]* lnrpc.RouteHint {{
2425+ 			HopHints : []* lnrpc.HopHint {hinEF },
2426+ 		}}),
2427+ 	)
2428+ 	logBalance (t .t , nodes , assetID , "after single sat keysend" )
2429+ 
2430+ 	// We make sure that a single sat keysend payment is not allowed when 
2431+ 	// it carries assets. 
2432+ 	sendAssetKeySendPayment (
2433+ 		t .t , erin , fabia , 123 , assetID , fn.Some [int64 ](1 ),
2434+ 		withPayErrSubStr (
2435+ 			fmt .Sprintf ("keysend payment satoshi amount must be " + 
2436+ 				"greater than or equal to %d satoshis" ,
2437+ 				rfqmath .DefaultOnChainHtlcSat ),
2438+ 		),
2439+ 	)
2440+ 
24102441	// Normal case. 
24112442	// Send 50 assets from Charlie to Dave. 
24122443	sendAssetKeySendPayment (
@@ -2870,6 +2901,54 @@ func testCustomChannelsLiquidityEdgeCasesCore(ctx context.Context,
28702901	)
28712902
28722903	logBalance (t .t , nodes , assetID , "after safe asset htlc failure" )
2904+ 
2905+ 	// Another test case: Make sure an asset invoice contains the correct 
2906+ 	// channel policy. We expect it to be the policy for the direction from 
2907+ 	// edge node to receiver node. To test this, we first set two different 
2908+ 	// policies on the channel between Erin and Fabia. 
2909+ 	resp , err  :=  erin .UpdateChannelPolicy (ctx , & lnrpc.PolicyUpdateRequest {
2910+ 		Scope : & lnrpc.PolicyUpdateRequest_ChanPoint {
2911+ 			ChanPoint : chanPointEF ,
2912+ 		},
2913+ 		BaseFeeMsat :   31337 ,
2914+ 		FeeRatePpm :    443322 ,
2915+ 		TimeLockDelta : 19 ,
2916+ 	})
2917+ 	require .NoError (t .t , err )
2918+ 	require .Empty (t .t , resp .FailedUpdates )
2919+ 
2920+ 	resp , err  =  fabia .UpdateChannelPolicy (ctx , & lnrpc.PolicyUpdateRequest {
2921+ 		Scope : & lnrpc.PolicyUpdateRequest_ChanPoint {
2922+ 			ChanPoint : chanPointEF ,
2923+ 		},
2924+ 		BaseFeeMsat :   42069 ,
2925+ 		FeeRatePpm :    223344 ,
2926+ 		TimeLockDelta : 18 ,
2927+ 	})
2928+ 	require .NoError (t .t , err )
2929+ 	require .Empty (t .t , resp .FailedUpdates )
2930+ 
2931+ 	// We now create an invoice on Fabia and expect Erin's policy to be used 
2932+ 	// in the invoice. 
2933+ 	invoiceResp  =  createAssetInvoice (t .t , erin , fabia , 1_000 , assetID )
2934+ 	req , err  :=  erin .DecodePayReq (ctx , & lnrpc.PayReqString {
2935+ 		PayReq : invoiceResp .PaymentRequest ,
2936+ 	})
2937+ 	require .NoError (t .t , err )
2938+ 
2939+ 	require .Len (t .t , req .RouteHints , 1 )
2940+ 	require .Len (t .t , req .RouteHints [0 ].HopHints , 1 )
2941+ 	invoiceHint  :=  req .RouteHints [0 ].HopHints [0 ]
2942+ 	require .Equal (t .t , erin .PubKeyStr , invoiceHint .NodeId )
2943+ 	require .EqualValues (t .t , 31337 , invoiceHint .FeeBaseMsat )
2944+ 	require .EqualValues (t .t , 443322 , invoiceHint .FeeProportionalMillionths )
2945+ 	require .EqualValues (t .t , 19 , invoiceHint .CltvExpiryDelta )
2946+ 
2947+ 	// Now we pay the invoice and expect the same policy with very expensive 
2948+ 	// fees to be used. 
2949+ 	payInvoiceWithSatoshi (
2950+ 		t .t , dave , invoiceResp , withFeeLimit (100_000_000 ),
2951+ 	)
28732952}
28742953
28752954// testCustomChannelsLiquidityEdgeCases is a test that runs through some 
0 commit comments