@@ -3435,6 +3435,7 @@ fn fail_payment_along_path<'a, 'b, 'c>(expected_path: &[&Node<'a, 'b, 'c>]) {
34353435pub struct PassAlongPathArgs < ' a , ' b , ' c , ' d > {
34363436 pub origin_node : & ' a Node < ' b , ' c , ' d > ,
34373437 pub expected_path : & ' a [ & ' a Node < ' b , ' c , ' d > ] ,
3438+ pub dummy_hop_override : Option < usize > ,
34383439 pub recv_value : u64 ,
34393440 pub payment_hash : PaymentHash ,
34403441 pub payment_secret : Option < PaymentSecret > ,
@@ -3456,6 +3457,7 @@ impl<'a, 'b, 'c, 'd> PassAlongPathArgs<'a, 'b, 'c, 'd> {
34563457 Self {
34573458 origin_node,
34583459 expected_path,
3460+ dummy_hop_override : None ,
34593461 recv_value,
34603462 payment_hash,
34613463 payment_secret : None ,
@@ -3503,12 +3505,17 @@ impl<'a, 'b, 'c, 'd> PassAlongPathArgs<'a, 'b, 'c, 'd> {
35033505 self . expected_failure = Some ( failure) ;
35043506 self
35053507 }
3508+ pub fn with_dummy_override ( mut self , dummy_override : usize ) -> Self {
3509+ self . dummy_hop_override = Some ( dummy_override) ;
3510+ self
3511+ }
35063512}
35073513
35083514pub fn do_pass_along_path < ' a , ' b , ' c > ( args : PassAlongPathArgs ) -> Option < Event > {
35093515 let PassAlongPathArgs {
35103516 origin_node,
35113517 expected_path,
3518+ dummy_hop_override,
35123519 recv_value,
35133520 payment_hash : our_payment_hash,
35143521 payment_secret : our_payment_secret,
@@ -3755,6 +3762,29 @@ pub struct ClaimAlongRouteArgs<'a, 'b, 'c, 'd> {
37553762 pub origin_node : & ' a Node < ' b , ' c , ' d > ,
37563763 pub expected_paths : & ' a [ & ' a [ & ' a Node < ' b , ' c , ' d > ] ] ,
37573764 pub expected_extra_fees : Vec < u32 > ,
3765+ /// A one-off adjustment used only in tests to account for an existing
3766+ /// fee-handling trade-off in LDK.
3767+ ///
3768+ /// When the payer is the introduction node of a blinded path, LDK does not
3769+ /// subtract the forward fee for the `payer -> next_hop` channel
3770+ /// (see [`BlindedPaymentPath::advance_path_by_one`]). This keeps the fee
3771+ /// logic simpler at the cost of a small, intentional overpayment.
3772+ ///
3773+ /// In the simple two-hop case (payer as introduction node → payee),
3774+ /// this overpayment has historically been avoided by simply not charging
3775+ /// the payer the forward fee, since the payer knows there is only
3776+ /// a single hop after them.
3777+ ///
3778+ /// However, with the introduction of dummy hops in LDK v3.0, even a
3779+ /// two-node real path (payer as introduction node → payee) may appear as a
3780+ /// multi-hop blinded path. This makes the existing overpayment surface in
3781+ /// tests.
3782+ ///
3783+ /// Until the fee-handling trade-off is revisited, this field allows tests
3784+ /// to compensate for that expected difference.
3785+ ///
3786+ /// [`BlindedPaymentPath::advance_path_by_one`]: crate::blinded_path::payment::BlindedPaymentPath::advance_path_by_one
3787+ pub expected_extra_total_fees_msat : u64 ,
37583788 pub expected_min_htlc_overpay : Vec < u32 > ,
37593789 pub skip_last : bool ,
37603790 pub payment_preimage : PaymentPreimage ,
@@ -3778,6 +3808,7 @@ impl<'a, 'b, 'c, 'd> ClaimAlongRouteArgs<'a, 'b, 'c, 'd> {
37783808 origin_node,
37793809 expected_paths,
37803810 expected_extra_fees : vec ! [ 0 ; expected_paths. len( ) ] ,
3811+ expected_extra_total_fees_msat : 0 ,
37813812 expected_min_htlc_overpay : vec ! [ 0 ; expected_paths. len( ) ] ,
37823813 skip_last : false ,
37833814 payment_preimage,
@@ -3793,6 +3824,10 @@ impl<'a, 'b, 'c, 'd> ClaimAlongRouteArgs<'a, 'b, 'c, 'd> {
37933824 self . expected_extra_fees = extra_fees;
37943825 self
37953826 }
3827+ pub fn with_expected_extra_total_fees_msat ( mut self , extra_total_fees : u64 ) -> Self {
3828+ self . expected_extra_total_fees_msat = extra_total_fees;
3829+ self
3830+ }
37963831 pub fn with_expected_min_htlc_overpay ( mut self , extra_fees : Vec < u32 > ) -> Self {
37973832 self . expected_min_htlc_overpay = extra_fees;
37983833 self
@@ -3817,6 +3852,7 @@ pub fn pass_claimed_payment_along_route(args: ClaimAlongRouteArgs) -> u64 {
38173852 payment_preimage : our_payment_preimage,
38183853 allow_1_msat_fee_overpay,
38193854 custom_tlvs,
3855+ ..
38203856 } = args;
38213857 let claim_event = expected_paths[ 0 ] . last ( ) . unwrap ( ) . node . get_and_clear_pending_events ( ) ;
38223858 assert_eq ! ( claim_event. len( ) , 1 ) ;
@@ -4052,10 +4088,17 @@ pub fn pass_claimed_payment_along_route(args: ClaimAlongRouteArgs) -> u64 {
40524088pub fn claim_payment_along_route (
40534089 args : ClaimAlongRouteArgs ,
40544090) -> ( Option < PaidBolt12Invoice > , Vec < Event > ) {
4055- let origin_node = args. origin_node ;
4056- let payment_preimage = args. payment_preimage ;
4057- let skip_last = args. skip_last ;
4058- let expected_total_fee_msat = do_claim_payment_along_route ( args) ;
4091+ let ClaimAlongRouteArgs {
4092+ origin_node,
4093+ payment_preimage,
4094+ skip_last,
4095+ expected_extra_total_fees_msat,
4096+ ..
4097+ } = args;
4098+
4099+ let expected_total_fee_msat =
4100+ do_claim_payment_along_route ( args) + expected_extra_total_fees_msat;
4101+
40594102 if !skip_last {
40604103 expect_payment_sent ! ( origin_node, payment_preimage, Some ( expected_total_fee_msat) )
40614104 } else {
0 commit comments