@@ -2604,6 +2604,14 @@ pub struct ClaimAlongRouteArgs<'a, 'b, 'c, 'd> {
2604
2604
pub expected_extra_fees : Vec < u32 > ,
2605
2605
pub skip_last : bool ,
2606
2606
pub payment_preimage : PaymentPreimage ,
2607
+ // Allow forwarding nodes to have taken 1 msat more fee than expected based on the downstream
2608
+ // fulfill amount.
2609
+ //
2610
+ // Necessary because our test utils calculate the expected fee for an intermediate node based on
2611
+ // the amount was claimed in their downstream peer's fulfill, but blinded intermediate nodes
2612
+ // calculate their fee based on the inbound amount from their upstream peer, causing a difference
2613
+ // in rounding.
2614
+ pub allow_1_msat_fee_overpay : bool ,
2607
2615
}
2608
2616
2609
2617
impl < ' a , ' b , ' c , ' d > ClaimAlongRouteArgs < ' a , ' b , ' c , ' d > {
@@ -2613,7 +2621,7 @@ impl<'a, 'b, 'c, 'd> ClaimAlongRouteArgs<'a, 'b, 'c, 'd> {
2613
2621
) -> Self {
2614
2622
Self {
2615
2623
origin_node, expected_paths, expected_extra_fees : vec ! [ 0 ; expected_paths. len( ) ] ,
2616
- skip_last : false , payment_preimage,
2624
+ skip_last : false , payment_preimage, allow_1_msat_fee_overpay : false ,
2617
2625
}
2618
2626
}
2619
2627
pub fn skip_last ( mut self , skip_last : bool ) -> Self {
@@ -2624,12 +2632,16 @@ impl<'a, 'b, 'c, 'd> ClaimAlongRouteArgs<'a, 'b, 'c, 'd> {
2624
2632
self . expected_extra_fees = extra_fees;
2625
2633
self
2626
2634
}
2635
+ pub fn allow_1_msat_fee_overpay ( mut self ) -> Self {
2636
+ self . allow_1_msat_fee_overpay = true ;
2637
+ self
2638
+ }
2627
2639
}
2628
2640
2629
2641
pub fn pass_claimed_payment_along_route < ' a , ' b , ' c , ' d > ( args : ClaimAlongRouteArgs ) -> u64 {
2630
2642
let ClaimAlongRouteArgs {
2631
2643
origin_node, expected_paths, expected_extra_fees, skip_last,
2632
- payment_preimage : our_payment_preimage
2644
+ payment_preimage : our_payment_preimage, allow_1_msat_fee_overpay
2633
2645
} = args;
2634
2646
let claim_event = expected_paths[ 0 ] . last ( ) . unwrap ( ) . node . get_and_clear_pending_events ( ) ;
2635
2647
assert_eq ! ( claim_event. len( ) , 1 ) ;
@@ -2740,9 +2752,11 @@ pub fn pass_claimed_payment_along_route<'a, 'b, 'c, 'd>(args: ClaimAlongRouteArg
2740
2752
( fwd_amt_msat * prop_fee / 1_000_000 ) + base_fee
2741
2753
} ;
2742
2754
if $idx == 1 { fee += expected_extra_fees[ i] as u64 ; }
2743
- expect_payment_forwarded!( * $node, $next_node, $prev_node, Some ( fee as u64 ) , false , false ) ;
2744
- expected_total_fee_msat += fee as u64 ;
2745
- fwd_amt_msat += fee as u64 ;
2755
+ let mut events = $node. node. get_and_clear_pending_events( ) ;
2756
+ assert_eq!( events. len( ) , 1 ) ;
2757
+ let actual_fee = expect_payment_forwarded( events. pop( ) . unwrap( ) , $node, & $next_node, $prev_node, Some ( fee as u64 ) , false , false , allow_1_msat_fee_overpay) ;
2758
+ expected_total_fee_msat += actual_fee. unwrap( ) ;
2759
+ fwd_amt_msat += actual_fee. unwrap( ) ;
2746
2760
check_added_monitors!( $node, 1 ) ;
2747
2761
let new_next_msgs = if $new_msgs {
2748
2762
let events = $node. node. get_and_clear_pending_msg_events( ) ;
0 commit comments