@@ -2673,6 +2673,8 @@ pub fn pass_claimed_payment_along_route<'a, 'b, 'c, 'd>(args: ClaimAlongRouteArg
26732673 } = args;
26742674 let claim_event = expected_paths[ 0 ] . last ( ) . unwrap ( ) . node . get_and_clear_pending_events ( ) ;
26752675 assert_eq ! ( claim_event. len( ) , 1 ) ;
2676+ #[ allow( unused) ]
2677+ let mut fwd_amt_msat = 0 ;
26762678 match claim_event[ 0 ] {
26772679 Event :: PaymentClaimed {
26782680 purpose : PaymentPurpose :: SpontaneousPayment ( preimage) ,
@@ -2689,6 +2691,7 @@ pub fn pass_claimed_payment_along_route<'a, 'b, 'c, 'd>(args: ClaimAlongRouteArg
26892691 assert_eq ! ( htlcs. len( ) , expected_paths. len( ) ) ; // One per path.
26902692 assert_eq ! ( htlcs. iter( ) . map( |h| h. value_msat) . sum:: <u64 >( ) , amount_msat) ;
26912693 expected_paths. iter ( ) . zip ( htlcs) . for_each ( |( path, htlc) | check_claimed_htlc_channel ( origin_node, path, htlc) ) ;
2694+ fwd_amt_msat = amount_msat;
26922695 } ,
26932696 Event :: PaymentClaimed {
26942697 purpose : PaymentPurpose :: InvoicePayment { .. } ,
@@ -2701,6 +2704,7 @@ pub fn pass_claimed_payment_along_route<'a, 'b, 'c, 'd>(args: ClaimAlongRouteArg
27012704 assert_eq ! ( htlcs. len( ) , expected_paths. len( ) ) ; // One per path.
27022705 assert_eq ! ( htlcs. iter( ) . map( |h| h. value_msat) . sum:: <u64 >( ) , amount_msat) ;
27032706 expected_paths. iter ( ) . zip ( htlcs) . for_each ( |( path, htlc) | check_claimed_htlc_channel ( origin_node, path, htlc) ) ;
2707+ fwd_amt_msat = amount_msat;
27042708 }
27052709 _ => panic ! ( ) ,
27062710 }
@@ -2761,15 +2765,20 @@ pub fn pass_claimed_payment_along_route<'a, 'b, 'c, 'd>(args: ClaimAlongRouteArg
27612765 {
27622766 $node. node. handle_update_fulfill_htlc( & $prev_node. node. get_our_node_id( ) , & next_msgs. as_ref( ) . unwrap( ) . 0 ) ;
27632767 let mut fee = {
2764- let per_peer_state = $node. node. per_peer_state. read( ) . unwrap( ) ;
2765- let peer_state = per_peer_state. get( & $prev_node. node. get_our_node_id( ) )
2766- . unwrap( ) . lock( ) . unwrap( ) ;
2767- let channel = peer_state. channel_by_id. get( & next_msgs. as_ref( ) . unwrap( ) . 0 . channel_id) . unwrap( ) ;
2768- if let Some ( prev_config) = channel. context( ) . prev_config( ) {
2769- prev_config. forwarding_fee_base_msat
2770- } else {
2771- channel. context( ) . config( ) . forwarding_fee_base_msat
2772- }
2768+ let ( base_fee, prop_fee) = {
2769+ let per_peer_state = $node. node. per_peer_state. read( ) . unwrap( ) ;
2770+ let peer_state = per_peer_state. get( & $prev_node. node. get_our_node_id( ) )
2771+ . unwrap( ) . lock( ) . unwrap( ) ;
2772+ let channel = peer_state. channel_by_id. get( & next_msgs. as_ref( ) . unwrap( ) . 0 . channel_id) . unwrap( ) ;
2773+ if let Some ( prev_config) = channel. context( ) . prev_config( ) {
2774+ ( prev_config. forwarding_fee_base_msat as u64 ,
2775+ prev_config. forwarding_fee_proportional_millionths as u64 )
2776+ } else {
2777+ ( channel. context( ) . config( ) . forwarding_fee_base_msat as u64 ,
2778+ channel. context( ) . config( ) . forwarding_fee_proportional_millionths as u64 )
2779+ }
2780+ } ;
2781+ ( ( fwd_amt_msat * prop_fee / 1_000_000 ) + base_fee) as u32
27732782 } ;
27742783
27752784 let mut expected_extra_fee = None ;
@@ -2783,6 +2792,7 @@ pub fn pass_claimed_payment_along_route<'a, 'b, 'c, 'd>(args: ClaimAlongRouteArg
27832792 expect_payment_forwarded( events. pop( ) . unwrap( ) , * $node, $next_node, $prev_node,
27842793 Some ( fee as u64 ) , expected_extra_fee, false , false ) ;
27852794 expected_total_fee_msat += fee as u64 ;
2795+ fwd_amt_msat += fee as u64 ;
27862796 check_added_monitors!( $node, 1 ) ;
27872797 let new_next_msgs = if $new_msgs {
27882798 let events = $node. node. get_and_clear_pending_msg_events( ) ;
0 commit comments