@@ -2695,6 +2695,8 @@ pub fn pass_claimed_payment_along_route<'a, 'b, 'c, 'd>(args: ClaimAlongRouteArg
2695
2695
} = args;
2696
2696
let claim_event = expected_paths[ 0 ] . last ( ) . unwrap ( ) . node . get_and_clear_pending_events ( ) ;
2697
2697
assert_eq ! ( claim_event. len( ) , 1 ) ;
2698
+ #[ allow( unused) ]
2699
+ let mut fwd_amt_msat = 0 ;
2698
2700
match claim_event[ 0 ] {
2699
2701
Event :: PaymentClaimed {
2700
2702
purpose : PaymentPurpose :: SpontaneousPayment ( preimage) ,
@@ -2711,6 +2713,7 @@ pub fn pass_claimed_payment_along_route<'a, 'b, 'c, 'd>(args: ClaimAlongRouteArg
2711
2713
assert_eq ! ( htlcs. len( ) , expected_paths. len( ) ) ; // One per path.
2712
2714
assert_eq ! ( htlcs. iter( ) . map( |h| h. value_msat) . sum:: <u64 >( ) , amount_msat) ;
2713
2715
expected_paths. iter ( ) . zip ( htlcs) . for_each ( |( path, htlc) | check_claimed_htlc_channel ( origin_node, path, htlc) ) ;
2716
+ fwd_amt_msat = amount_msat;
2714
2717
} ,
2715
2718
Event :: PaymentClaimed {
2716
2719
purpose : PaymentPurpose :: InvoicePayment { .. } ,
@@ -2723,6 +2726,7 @@ pub fn pass_claimed_payment_along_route<'a, 'b, 'c, 'd>(args: ClaimAlongRouteArg
2723
2726
assert_eq ! ( htlcs. len( ) , expected_paths. len( ) ) ; // One per path.
2724
2727
assert_eq ! ( htlcs. iter( ) . map( |h| h. value_msat) . sum:: <u64 >( ) , amount_msat) ;
2725
2728
expected_paths. iter ( ) . zip ( htlcs) . for_each ( |( path, htlc) | check_claimed_htlc_channel ( origin_node, path, htlc) ) ;
2729
+ fwd_amt_msat = amount_msat;
2726
2730
}
2727
2731
_ => panic ! ( ) ,
2728
2732
}
@@ -2783,15 +2787,20 @@ pub fn pass_claimed_payment_along_route<'a, 'b, 'c, 'd>(args: ClaimAlongRouteArg
2783
2787
{
2784
2788
$node. node. handle_update_fulfill_htlc( & $prev_node. node. get_our_node_id( ) , & next_msgs. as_ref( ) . unwrap( ) . 0 ) ;
2785
2789
let mut fee = {
2786
- let per_peer_state = $node. node. per_peer_state. read( ) . unwrap( ) ;
2787
- let peer_state = per_peer_state. get( & $prev_node. node. get_our_node_id( ) )
2788
- . unwrap( ) . lock( ) . unwrap( ) ;
2789
- let channel = peer_state. channel_by_id. get( & next_msgs. as_ref( ) . unwrap( ) . 0 . channel_id) . unwrap( ) ;
2790
- if let Some ( prev_config) = channel. context( ) . prev_config( ) {
2791
- prev_config. forwarding_fee_base_msat
2792
- } else {
2793
- channel. context( ) . config( ) . forwarding_fee_base_msat
2794
- }
2790
+ let ( base_fee, prop_fee) = {
2791
+ let per_peer_state = $node. node. per_peer_state. read( ) . unwrap( ) ;
2792
+ let peer_state = per_peer_state. get( & $prev_node. node. get_our_node_id( ) )
2793
+ . unwrap( ) . lock( ) . unwrap( ) ;
2794
+ let channel = peer_state. channel_by_id. get( & next_msgs. as_ref( ) . unwrap( ) . 0 . channel_id) . unwrap( ) ;
2795
+ if let Some ( prev_config) = channel. context( ) . prev_config( ) {
2796
+ ( prev_config. forwarding_fee_base_msat as u64 ,
2797
+ prev_config. forwarding_fee_proportional_millionths as u64 )
2798
+ } else {
2799
+ ( channel. context( ) . config( ) . forwarding_fee_base_msat as u64 ,
2800
+ channel. context( ) . config( ) . forwarding_fee_proportional_millionths as u64 )
2801
+ }
2802
+ } ;
2803
+ ( ( fwd_amt_msat * prop_fee / 1_000_000 ) + base_fee) as u32
2795
2804
} ;
2796
2805
2797
2806
let mut expected_extra_fee = None ;
@@ -2805,6 +2814,7 @@ pub fn pass_claimed_payment_along_route<'a, 'b, 'c, 'd>(args: ClaimAlongRouteArg
2805
2814
expect_payment_forwarded( events. pop( ) . unwrap( ) , * $node, $next_node, $prev_node,
2806
2815
Some ( fee as u64 ) , expected_extra_fee, false , false ) ;
2807
2816
expected_total_fee_msat += fee as u64 ;
2817
+ fwd_amt_msat += fee as u64 ;
2808
2818
check_added_monitors!( $node, 1 ) ;
2809
2819
let new_next_msgs = if $new_msgs {
2810
2820
let events = $node. node. get_and_clear_pending_msg_events( ) ;
0 commit comments