@@ -2590,6 +2590,14 @@ pub struct ClaimAlongRouteArgs<'a, 'b, 'c, 'd> {
2590
2590
pub expected_extra_fees : Vec < u32 > ,
2591
2591
pub skip_last : bool ,
2592
2592
pub payment_preimage : PaymentPreimage ,
2593
+ // Allow forwarding nodes to have taken 1 msat more fee than expected based on the downstream
2594
+ // fulfill amount.
2595
+ //
2596
+ // Necessary because our test utils calculate the expected fee for an intermediate node based on
2597
+ // the amount was claimed in their downstream peer's fulfill, but blinded intermediate nodes
2598
+ // calculate their fee based on the inbound amount from their upstream peer, causing a difference
2599
+ // in rounding.
2600
+ pub allow_1_msat_fee_overpay : bool ,
2593
2601
}
2594
2602
2595
2603
impl < ' a , ' b , ' c , ' d > ClaimAlongRouteArgs < ' a , ' b , ' c , ' d > {
@@ -2599,7 +2607,7 @@ impl<'a, 'b, 'c, 'd> ClaimAlongRouteArgs<'a, 'b, 'c, 'd> {
2599
2607
) -> Self {
2600
2608
Self {
2601
2609
origin_node, expected_paths, expected_extra_fees : vec ! [ 0 ; expected_paths. len( ) ] ,
2602
- skip_last : false , payment_preimage,
2610
+ skip_last : false , payment_preimage, allow_1_msat_fee_overpay : false ,
2603
2611
}
2604
2612
}
2605
2613
pub fn skip_last ( mut self , skip_last : bool ) -> Self {
@@ -2610,12 +2618,16 @@ impl<'a, 'b, 'c, 'd> ClaimAlongRouteArgs<'a, 'b, 'c, 'd> {
2610
2618
self . expected_extra_fees = extra_fees;
2611
2619
self
2612
2620
}
2621
+ pub fn allow_1_msat_fee_overpay ( mut self ) -> Self {
2622
+ self . allow_1_msat_fee_overpay = true ;
2623
+ self
2624
+ }
2613
2625
}
2614
2626
2615
2627
pub fn pass_claimed_payment_along_route < ' a , ' b , ' c , ' d > ( args : ClaimAlongRouteArgs ) -> u64 {
2616
2628
let ClaimAlongRouteArgs {
2617
2629
origin_node, expected_paths, expected_extra_fees, skip_last,
2618
- payment_preimage : our_payment_preimage
2630
+ payment_preimage : our_payment_preimage, allow_1_msat_fee_overpay
2619
2631
} = args;
2620
2632
let claim_event = expected_paths[ 0 ] . last ( ) . unwrap ( ) . node . get_and_clear_pending_events ( ) ;
2621
2633
assert_eq ! ( claim_event. len( ) , 1 ) ;
@@ -2726,9 +2738,11 @@ pub fn pass_claimed_payment_along_route<'a, 'b, 'c, 'd>(args: ClaimAlongRouteArg
2726
2738
( fwd_amt_msat * prop_fee / 1_000_000 ) + base_fee
2727
2739
} ;
2728
2740
if $idx == 1 { fee += expected_extra_fees[ i] as u64 ; }
2729
- expect_payment_forwarded!( * $node, $next_node, $prev_node, Some ( fee as u64 ) , false , false ) ;
2730
- expected_total_fee_msat += fee as u64 ;
2731
- fwd_amt_msat += fee as u64 ;
2741
+ let mut events = $node. node. get_and_clear_pending_events( ) ;
2742
+ assert_eq!( events. len( ) , 1 ) ;
2743
+ 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) ;
2744
+ expected_total_fee_msat += actual_fee. unwrap( ) ;
2745
+ fwd_amt_msat += actual_fee. unwrap( ) ;
2732
2746
check_added_monitors!( $node, 1 ) ;
2733
2747
let new_next_msgs = if $new_msgs {
2734
2748
let events = $node. node. get_and_clear_pending_msg_events( ) ;
0 commit comments