]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Test we adhere to `max_total_routing_fee_msat`
authorElias Rohrer <dev@tnull.de>
Fri, 14 Jul 2023 14:46:52 +0000 (16:46 +0200)
committerElias Rohrer <dev@tnull.de>
Tue, 26 Sep 2023 07:44:05 +0000 (09:44 +0200)
lightning/src/routing/router.rs

index 340d5e5c1078d50f24feedfe10abf5c9c124392b..c680d57a6dc4f05e97d838d038e2e90276f92874 100644 (file)
@@ -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);