@@ -2697,6 +2697,8 @@ pub fn pass_claimed_payment_along_route<'a, 'b, 'c, 'd>(args: ClaimAlongRouteArg
26972697 } = args;
26982698 let claim_event = expected_paths[ 0 ] . last ( ) . unwrap ( ) . node . get_and_clear_pending_events ( ) ;
26992699 assert_eq ! ( claim_event. len( ) , 1 ) ;
2700+ #[ allow( unused) ]
2701+ let mut fwd_amt_msat = 0 ;
27002702 match claim_event[ 0 ] {
27012703 Event :: PaymentClaimed {
27022704 purpose : PaymentPurpose :: SpontaneousPayment ( preimage) ,
@@ -2713,6 +2715,7 @@ pub fn pass_claimed_payment_along_route<'a, 'b, 'c, 'd>(args: ClaimAlongRouteArg
27132715 assert_eq ! ( htlcs. len( ) , expected_paths. len( ) ) ; // One per path.
27142716 assert_eq ! ( htlcs. iter( ) . map( |h| h. value_msat) . sum:: <u64 >( ) , amount_msat) ;
27152717 expected_paths. iter ( ) . zip ( htlcs) . for_each ( |( path, htlc) | check_claimed_htlc_channel ( origin_node, path, htlc) ) ;
2718+ fwd_amt_msat = amount_msat;
27162719 } ,
27172720 Event :: PaymentClaimed {
27182721 purpose : PaymentPurpose :: InvoicePayment { .. } ,
@@ -2725,6 +2728,7 @@ pub fn pass_claimed_payment_along_route<'a, 'b, 'c, 'd>(args: ClaimAlongRouteArg
27252728 assert_eq ! ( htlcs. len( ) , expected_paths. len( ) ) ; // One per path.
27262729 assert_eq ! ( htlcs. iter( ) . map( |h| h. value_msat) . sum:: <u64 >( ) , amount_msat) ;
27272730 expected_paths. iter ( ) . zip ( htlcs) . for_each ( |( path, htlc) | check_claimed_htlc_channel ( origin_node, path, htlc) ) ;
2731+ fwd_amt_msat = amount_msat;
27282732 }
27292733 _ => panic ! ( ) ,
27302734 }
@@ -2785,15 +2789,20 @@ pub fn pass_claimed_payment_along_route<'a, 'b, 'c, 'd>(args: ClaimAlongRouteArg
27852789 {
27862790 $node. node. handle_update_fulfill_htlc( & $prev_node. node. get_our_node_id( ) , & next_msgs. as_ref( ) . unwrap( ) . 0 ) ;
27872791 let mut fee = {
2788- let per_peer_state = $node. node. per_peer_state. read( ) . unwrap( ) ;
2789- let peer_state = per_peer_state. get( & $prev_node. node. get_our_node_id( ) )
2790- . unwrap( ) . lock( ) . unwrap( ) ;
2791- let channel = peer_state. channel_by_id. get( & next_msgs. as_ref( ) . unwrap( ) . 0 . channel_id) . unwrap( ) ;
2792- if let Some ( prev_config) = channel. context( ) . prev_config( ) {
2793- prev_config. forwarding_fee_base_msat
2794- } else {
2795- channel. context( ) . config( ) . forwarding_fee_base_msat
2796- }
2792+ let ( base_fee, prop_fee) = {
2793+ let per_peer_state = $node. node. per_peer_state. read( ) . unwrap( ) ;
2794+ let peer_state = per_peer_state. get( & $prev_node. node. get_our_node_id( ) )
2795+ . unwrap( ) . lock( ) . unwrap( ) ;
2796+ let channel = peer_state. channel_by_id. get( & next_msgs. as_ref( ) . unwrap( ) . 0 . channel_id) . unwrap( ) ;
2797+ if let Some ( prev_config) = channel. context( ) . prev_config( ) {
2798+ ( prev_config. forwarding_fee_base_msat as u64 ,
2799+ prev_config. forwarding_fee_proportional_millionths as u64 )
2800+ } else {
2801+ ( channel. context( ) . config( ) . forwarding_fee_base_msat as u64 ,
2802+ channel. context( ) . config( ) . forwarding_fee_proportional_millionths as u64 )
2803+ }
2804+ } ;
2805+ ( ( fwd_amt_msat * prop_fee / 1_000_000 ) + base_fee) as u32
27972806 } ;
27982807
27992808 let mut expected_extra_fee = None ;
@@ -2807,6 +2816,7 @@ pub fn pass_claimed_payment_along_route<'a, 'b, 'c, 'd>(args: ClaimAlongRouteArg
28072816 expect_payment_forwarded( events. pop( ) . unwrap( ) , * $node, $next_node, $prev_node,
28082817 Some ( fee as u64 ) , expected_extra_fee, false , false ) ;
28092818 expected_total_fee_msat += fee as u64 ;
2819+ fwd_amt_msat += fee as u64 ;
28102820 check_added_monitors!( $node, 1 ) ;
28112821 let new_next_msgs = if $new_msgs {
28122822 let events = $node. node. get_and_clear_pending_msg_events( ) ;
0 commit comments