@@ -3636,6 +3636,29 @@ pub struct ClaimAlongRouteArgs<'a, 'b, 'c, 'd> {
36363636 pub origin_node : & ' a Node < ' b , ' c , ' d > ,
36373637 pub expected_paths : & ' a [ & ' a [ & ' a Node < ' b , ' c , ' d > ] ] ,
36383638 pub expected_extra_fees : Vec < u32 > ,
3639+ /// A one-off adjustment used only in tests to account for an existing
3640+ /// fee-handling trade-off in LDK.
3641+ ///
3642+ /// When the payer is the introduction node of a blinded path, LDK does not
3643+ /// subtract the forward fee for the `payer -> next_hop` channel
3644+ /// (see [`BlindedPaymentPath::advance_path_by_one`]). This keeps the fee
3645+ /// logic simpler at the cost of a small, intentional overpayment.
3646+ ///
3647+ /// In the simple two-hop case (payer as introduction node → payee),
3648+ /// this overpayment has historically been avoided by simply not charging
3649+ /// the payer the forward fee, since the payer knows there is only
3650+ /// a single hop after them.
3651+ ///
3652+ /// However, with the introduction of dummy hops in LDK v3.0, even a
3653+ /// two-node real path (payer as introduction node → payee) may appear as a
3654+ /// multi-hop blinded path. This makes the existing overpayment surface in
3655+ /// tests.
3656+ ///
3657+ /// Until the fee-handling trade-off is revisited, this field allows tests
3658+ /// to compensate for that expected difference.
3659+ ///
3660+ /// [`BlindedPaymentPath::advance_path_by_one`]: crate::blinded_path::payment::BlindedPaymentPath::advance_path_by_one
3661+ pub expected_extra_total_fees_msat : u64 ,
36393662 pub expected_min_htlc_overpay : Vec < u32 > ,
36403663 pub skip_last : bool ,
36413664 pub payment_preimage : PaymentPreimage ,
@@ -3659,6 +3682,7 @@ impl<'a, 'b, 'c, 'd> ClaimAlongRouteArgs<'a, 'b, 'c, 'd> {
36593682 origin_node,
36603683 expected_paths,
36613684 expected_extra_fees : vec ! [ 0 ; expected_paths. len( ) ] ,
3685+ expected_extra_total_fees_msat : 0 ,
36623686 expected_min_htlc_overpay : vec ! [ 0 ; expected_paths. len( ) ] ,
36633687 skip_last : false ,
36643688 payment_preimage,
@@ -3674,6 +3698,10 @@ impl<'a, 'b, 'c, 'd> ClaimAlongRouteArgs<'a, 'b, 'c, 'd> {
36743698 self . expected_extra_fees = extra_fees;
36753699 self
36763700 }
3701+ pub fn with_expected_extra_total_fees_msat ( mut self , extra_total_fees : u64 ) -> Self {
3702+ self . expected_extra_total_fees_msat = extra_total_fees;
3703+ self
3704+ }
36773705 pub fn with_expected_min_htlc_overpay ( mut self , extra_fees : Vec < u32 > ) -> Self {
36783706 self . expected_min_htlc_overpay = extra_fees;
36793707 self
@@ -3698,6 +3726,7 @@ pub fn pass_claimed_payment_along_route(args: ClaimAlongRouteArgs) -> u64 {
36983726 payment_preimage : our_payment_preimage,
36993727 allow_1_msat_fee_overpay,
37003728 custom_tlvs,
3729+ ..
37013730 } = args;
37023731 let claim_event = expected_paths[ 0 ] . last ( ) . unwrap ( ) . node . get_and_clear_pending_events ( ) ;
37033732 assert_eq ! ( claim_event. len( ) , 1 ) ;
@@ -3934,7 +3963,9 @@ pub fn claim_payment_along_route(
39343963 let origin_node = args. origin_node ;
39353964 let payment_preimage = args. payment_preimage ;
39363965 let skip_last = args. skip_last ;
3937- let expected_total_fee_msat = do_claim_payment_along_route ( args) ;
3966+ let expected_extra_total_fees_msat = args. expected_extra_total_fees_msat ;
3967+ let mut expected_total_fee_msat = do_claim_payment_along_route ( args) ;
3968+ expected_total_fee_msat += expected_extra_total_fees_msat;
39383969 if !skip_last {
39393970 expect_payment_sent ! ( origin_node, payment_preimage, Some ( expected_total_fee_msat) )
39403971 } else {
0 commit comments