From: Elias Rohrer Date: Fri, 14 Jul 2023 14:46:52 +0000 (+0200) Subject: Test we adhere to `max_total_routing_fee_msat` X-Git-Tag: v0.0.117-alpha2~5^2~5 X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=b1a878fe81e6abe129c47f1aaea103278cf207a3;p=rust-lightning Test we adhere to `max_total_routing_fee_msat` --- diff --git a/lightning/src/routing/router.rs b/lightning/src/routing/router.rs index 340d5e5c1..c680d57a6 100644 --- a/lightning/src/routing/router.rs +++ b/lightning/src/routing/router.rs @@ -5269,9 +5269,21 @@ mod tests { } else { panic!(); } } + { + // Attempt to route while setting max_total_routing_fee_msat to 149_999 results in a failure. + let route_params = RouteParameters { payment_params: payment_params.clone(), final_value_msat: 200_000, + max_total_routing_fee_msat: Some(149_999) }; + if let Err(LightningError{err, action: ErrorAction::IgnoreError}) = get_route( + &our_id, &route_params, &network_graph.read_only(), None, Arc::clone(&logger), + &scorer, &(), &random_seed_bytes) { + assert_eq!(err, "Failed to find a sufficient route to the given destination"); + } else { panic!(); } + } + { // Now, attempt to route 200 sats (exact amount we can route). - let route_params = RouteParameters::from_payment_params_and_value(payment_params, 200_000); + let route_params = RouteParameters { payment_params: payment_params.clone(), final_value_msat: 200_000, + max_total_routing_fee_msat: Some(150_000) }; let route = get_route(&our_id, &route_params, &network_graph.read_only(), None, Arc::clone(&logger), &scorer, &(), &random_seed_bytes).unwrap(); assert_eq!(route.paths.len(), 2);