@@ -2697,6 +2697,8 @@ pub fn pass_claimed_payment_along_route<'a, 'b, 'c, 'd>(args: ClaimAlongRouteArg
2697
2697
} = args;
2698
2698
let claim_event = expected_paths[ 0 ] . last ( ) . unwrap ( ) . node . get_and_clear_pending_events ( ) ;
2699
2699
assert_eq ! ( claim_event. len( ) , 1 ) ;
2700
+ #[ allow( unused) ]
2701
+ let mut fwd_amt_msat = 0 ;
2700
2702
match claim_event[ 0 ] {
2701
2703
Event :: PaymentClaimed {
2702
2704
purpose : PaymentPurpose :: SpontaneousPayment ( preimage) ,
@@ -2713,6 +2715,7 @@ pub fn pass_claimed_payment_along_route<'a, 'b, 'c, 'd>(args: ClaimAlongRouteArg
2713
2715
assert_eq ! ( htlcs. len( ) , expected_paths. len( ) ) ; // One per path.
2714
2716
assert_eq ! ( htlcs. iter( ) . map( |h| h. value_msat) . sum:: <u64 >( ) , amount_msat) ;
2715
2717
expected_paths. iter ( ) . zip ( htlcs) . for_each ( |( path, htlc) | check_claimed_htlc_channel ( origin_node, path, htlc) ) ;
2718
+ fwd_amt_msat = amount_msat;
2716
2719
} ,
2717
2720
Event :: PaymentClaimed {
2718
2721
purpose : PaymentPurpose :: InvoicePayment { .. } ,
@@ -2725,6 +2728,7 @@ pub fn pass_claimed_payment_along_route<'a, 'b, 'c, 'd>(args: ClaimAlongRouteArg
2725
2728
assert_eq ! ( htlcs. len( ) , expected_paths. len( ) ) ; // One per path.
2726
2729
assert_eq ! ( htlcs. iter( ) . map( |h| h. value_msat) . sum:: <u64 >( ) , amount_msat) ;
2727
2730
expected_paths. iter ( ) . zip ( htlcs) . for_each ( |( path, htlc) | check_claimed_htlc_channel ( origin_node, path, htlc) ) ;
2731
+ fwd_amt_msat = amount_msat;
2728
2732
}
2729
2733
_ => panic ! ( ) ,
2730
2734
}
@@ -2785,15 +2789,20 @@ pub fn pass_claimed_payment_along_route<'a, 'b, 'c, 'd>(args: ClaimAlongRouteArg
2785
2789
{
2786
2790
$node. node. handle_update_fulfill_htlc( & $prev_node. node. get_our_node_id( ) , & next_msgs. as_ref( ) . unwrap( ) . 0 ) ;
2787
2791
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
2797
2806
} ;
2798
2807
2799
2808
let mut expected_extra_fee = None ;
@@ -2807,6 +2816,7 @@ pub fn pass_claimed_payment_along_route<'a, 'b, 'c, 'd>(args: ClaimAlongRouteArg
2807
2816
expect_payment_forwarded( events. pop( ) . unwrap( ) , * $node, $next_node, $prev_node,
2808
2817
Some ( fee as u64 ) , expected_extra_fee, false , false ) ;
2809
2818
expected_total_fee_msat += fee as u64 ;
2819
+ fwd_amt_msat += fee as u64 ;
2810
2820
check_added_monitors!( $node, 1 ) ;
2811
2821
let new_next_msgs = if $new_msgs {
2812
2822
let events = $node. node. get_and_clear_pending_msg_events( ) ;
0 commit comments