@@ -999,3 +999,54 @@ fn min_htlc() {
999999	expect_payment_failed_conditions ( & nodes[ 0 ] ,  payment_hash,  false , 
10001000		PaymentFailedConditions :: new ( ) . expected_htlc_error_data ( INVALID_ONION_BLINDING ,  & [ 0 ;  32 ] ) ) ; 
10011001} 
1002+ 
1003+ #[ test]  
1004+ fn  high_prop_fees ( )  { 
1005+ 	// Previously, the (rng-found) feerates below caught a bug where an intermediate node would 
1006+ 	// calculate an amt_to_forward that underpaid them by 1 msat, caused by rounding up the outbound 
1007+ 	// amount on top of an already rounded-up total routing fee. Ensure that we'll conditionally round 
1008+ 	// down intermediate nodes' outbound amounts based on whether rounding up will result in 
1009+ 	// undercharging for relay. 
1010+ 	let  chanmon_cfgs = create_chanmon_cfgs ( 5 ) ; 
1011+ 	let  node_cfgs = create_node_cfgs ( 5 ,  & chanmon_cfgs) ; 
1012+ 
1013+ 	let  mut  node_1_cfg = test_default_channel_config ( ) ; 
1014+ 	node_1_cfg. channel_config . forwarding_fee_base_msat  = 247371 ; 
1015+ 	node_1_cfg. channel_config . forwarding_fee_proportional_millionths  = 86552 ; 
1016+ 
1017+ 	let  mut  node_2_cfg = test_default_channel_config ( ) ; 
1018+ 	node_2_cfg. channel_config . forwarding_fee_base_msat  = 198921 ; 
1019+ 	node_2_cfg. channel_config . forwarding_fee_proportional_millionths  = 681759 ; 
1020+ 
1021+ 	let  mut  node_3_cfg = test_default_channel_config ( ) ; 
1022+ 	node_3_cfg. channel_config . forwarding_fee_base_msat  = 132845 ; 
1023+ 	node_3_cfg. channel_config . forwarding_fee_proportional_millionths  = 552561 ; 
1024+ 
1025+ 	let  node_chanmgrs = create_node_chanmgrs ( 5 ,  & node_cfgs,  & [ None ,  Some ( node_1_cfg) ,  Some ( node_2_cfg) ,  Some ( node_3_cfg) ,  None ] ) ; 
1026+ 	let  nodes = create_network ( 5 ,  & node_cfgs,  & node_chanmgrs) ; 
1027+ 	create_announced_chan_between_nodes_with_value ( & nodes,  0 ,  1 ,  1_000_000 ,  0 ) ; 
1028+ 	let  chan_1_2 = create_announced_chan_between_nodes_with_value ( & nodes,  1 ,  2 ,  1_000_000 ,  0 ) ; 
1029+ 	let  chan_2_3 = create_announced_chan_between_nodes_with_value ( & nodes,  2 ,  3 ,  1_000_000 ,  0 ) ; 
1030+ 	let  chan_3_4 = create_announced_chan_between_nodes_with_value ( & nodes,  3 ,  4 ,  1_000_000 ,  0 ) ; 
1031+ 
1032+ 	let  amt_msat = 100_000 ; 
1033+ 	let  ( payment_preimage,  payment_hash,  payment_secret)  = get_payment_preimage_hash ( & nodes[ 4 ] ,  Some ( amt_msat) ,  None ) ; 
1034+ 	let  mut  route_params = get_blinded_route_parameters ( amt_msat,  payment_secret, 
1035+ 		chan_1_2. 1 . contents . htlc_minimum_msat ,  chan_1_2. 1 . contents . htlc_maximum_msat , 
1036+ 		vec ! [ nodes[ 1 ] . node. get_our_node_id( ) ,  nodes[ 2 ] . node. get_our_node_id( ) , 
1037+ 		nodes[ 3 ] . node. get_our_node_id( ) ,  nodes[ 4 ] . node. get_our_node_id( ) ] , 
1038+ 		& [ & chan_1_2. 0 . contents ,  & chan_2_3. 0 . contents ,  & chan_3_4. 0 . contents ] , 
1039+ 		& chanmon_cfgs[ 4 ] . keys_manager ) ; 
1040+ 	route_params. max_total_routing_fee_msat  = None ; 
1041+ 
1042+ 	nodes[ 0 ] . node . send_payment ( payment_hash,  RecipientOnionFields :: spontaneous_empty ( ) ,  PaymentId ( payment_hash. 0 ) ,  route_params,  Retry :: Attempts ( 0 ) ) . unwrap ( ) ; 
1043+ 	check_added_monitors ( & nodes[ 0 ] ,  1 ) ; 
1044+ 	pass_along_route ( & nodes[ 0 ] ,  & [ & [ & nodes[ 1 ] ,  & nodes[ 2 ] ,  & nodes[ 3 ] ,  & nodes[ 4 ] ] ] ,  amt_msat,  payment_hash,  payment_secret) ; 
1045+ 	nodes[ 4 ] . node . claim_funds ( payment_preimage) ; 
1046+ 	let  expected_path = & [ & nodes[ 1 ] ,  & nodes[ 2 ] ,  & nodes[ 3 ] ,  & nodes[ 4 ] ] ; 
1047+ 	let  expected_route = & [ & expected_path[ ..] ] ; 
1048+ 	let  mut  args = ClaimAlongRouteArgs :: new ( & nodes[ 0 ] ,  & expected_route[ ..] ,  payment_preimage) 
1049+ 		. allow_1_msat_fee_overpay ( ) ; 
1050+ 	let  expected_fee = pass_claimed_payment_along_route ( args) ; 
1051+ 	expect_payment_sent ( & nodes[ 0 ] ,  payment_preimage,  Some ( Some ( expected_fee) ) ,  true ,  true ) ; 
1052+ } 
0 commit comments