X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;ds=sidebyside;f=lightning%2Fsrc%2Frouting%2Frouter.rs;h=c680d57a6dc4f05e97d838d038e2e90276f92874;hb=26b515c13cccd1d027e67d0c65d69321d235ce40;hp=340d5e5c1078d50f24feedfe10abf5c9c124392b;hpb=ca40d8a6fb5b220db443748fa90dfc1bd8e7d99b;p=rust-lightning diff --git a/lightning/src/routing/router.rs b/lightning/src/routing/router.rs index 340d5e5c..c680d57a 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);