@@ -2606,6 +2606,8 @@ pub fn pass_claimed_payment_along_route<'a, 'b, 'c, 'd>(args: ClaimAlongRouteArg
2606
2606
} = args;
2607
2607
let claim_event = expected_paths[ 0 ] . last ( ) . unwrap ( ) . node . get_and_clear_pending_events ( ) ;
2608
2608
assert_eq ! ( claim_event. len( ) , 1 ) ;
2609
+ #[ allow( unused) ]
2610
+ let mut fwd_amt_msat = 0 ;
2609
2611
match claim_event[ 0 ] {
2610
2612
Event :: PaymentClaimed {
2611
2613
purpose : PaymentPurpose :: SpontaneousPayment ( preimage) ,
@@ -2622,6 +2624,7 @@ pub fn pass_claimed_payment_along_route<'a, 'b, 'c, 'd>(args: ClaimAlongRouteArg
2622
2624
assert_eq ! ( htlcs. len( ) , expected_paths. len( ) ) ; // One per path.
2623
2625
assert_eq ! ( htlcs. iter( ) . map( |h| h. value_msat) . sum:: <u64 >( ) , amount_msat) ;
2624
2626
expected_paths. iter ( ) . zip ( htlcs) . for_each ( |( path, htlc) | check_claimed_htlc_channel ( origin_node, path, htlc) ) ;
2627
+ fwd_amt_msat = amount_msat;
2625
2628
} ,
2626
2629
Event :: PaymentClaimed {
2627
2630
purpose : PaymentPurpose :: InvoicePayment { .. } ,
@@ -2634,6 +2637,7 @@ pub fn pass_claimed_payment_along_route<'a, 'b, 'c, 'd>(args: ClaimAlongRouteArg
2634
2637
assert_eq ! ( htlcs. len( ) , expected_paths. len( ) ) ; // One per path.
2635
2638
assert_eq ! ( htlcs. iter( ) . map( |h| h. value_msat) . sum:: <u64 >( ) , amount_msat) ;
2636
2639
expected_paths. iter ( ) . zip ( htlcs) . for_each ( |( path, htlc) | check_claimed_htlc_channel ( origin_node, path, htlc) ) ;
2640
+ fwd_amt_msat = amount_msat;
2637
2641
}
2638
2642
_ => panic ! ( ) ,
2639
2643
}
@@ -2693,19 +2697,25 @@ pub fn pass_claimed_payment_along_route<'a, 'b, 'c, 'd>(args: ClaimAlongRouteArg
2693
2697
{
2694
2698
$node. node. handle_update_fulfill_htlc( & $prev_node. node. get_our_node_id( ) , & next_msgs. as_ref( ) . unwrap( ) . 0 ) ;
2695
2699
let mut fee = {
2696
- let per_peer_state = $node. node. per_peer_state. read( ) . unwrap( ) ;
2697
- let peer_state = per_peer_state. get( & $prev_node. node. get_our_node_id( ) )
2698
- . unwrap( ) . lock( ) . unwrap( ) ;
2699
- let channel = peer_state. channel_by_id. get( & next_msgs. as_ref( ) . unwrap( ) . 0 . channel_id) . unwrap( ) ;
2700
- if let Some ( prev_config) = channel. context( ) . prev_config( ) {
2701
- prev_config. forwarding_fee_base_msat
2702
- } else {
2703
- channel. context( ) . config( ) . forwarding_fee_base_msat
2704
- }
2700
+ let ( base_fee, prop_fee) = {
2701
+ let per_peer_state = $node. node. per_peer_state. read( ) . unwrap( ) ;
2702
+ let peer_state = per_peer_state. get( & $prev_node. node. get_our_node_id( ) )
2703
+ . unwrap( ) . lock( ) . unwrap( ) ;
2704
+ let channel = peer_state. channel_by_id. get( & next_msgs. as_ref( ) . unwrap( ) . 0 . channel_id) . unwrap( ) ;
2705
+ if let Some ( prev_config) = channel. context( ) . prev_config( ) {
2706
+ ( prev_config. forwarding_fee_base_msat as u64 ,
2707
+ prev_config. forwarding_fee_proportional_millionths as u64 )
2708
+ } else {
2709
+ ( channel. context( ) . config( ) . forwarding_fee_base_msat as u64 ,
2710
+ channel. context( ) . config( ) . forwarding_fee_proportional_millionths as u64 )
2711
+ }
2712
+ } ;
2713
+ ( fwd_amt_msat * prop_fee / 1_000_000 ) + base_fee
2705
2714
} ;
2706
- if $idx == 1 { fee += expected_extra_fees[ i] ; }
2715
+ if $idx == 1 { fee += expected_extra_fees[ i] as u64 ; }
2707
2716
expect_payment_forwarded!( * $node, $next_node, $prev_node, Some ( fee as u64 ) , false , false ) ;
2708
2717
expected_total_fee_msat += fee as u64 ;
2718
+ fwd_amt_msat += fee as u64 ;
2709
2719
check_added_monitors!( $node, 1 ) ;
2710
2720
let new_next_msgs = if $new_msgs {
2711
2721
let events = $node. node. get_and_clear_pending_msg_events( ) ;
0 commit comments