+ #[test]
+ fn limits_total_cltv_delta() {
+ let (secp_ctx, network_graph, _, _, logger) = build_graph();
+ let (_, our_id, _, nodes) = get_nodes(&secp_ctx);
+
+ let scorer = test_utils::TestScorer::with_fixed_penalty(0);
+
+ // Make sure that generally there is at least one route available
+ let feasible_max_total_cltv_delta = 1008;
+ let feasible_payee = Payee::from_node_id(nodes[6]).with_route_hints(last_hops(&nodes))
+ .with_max_total_cltv_expiry_delta(feasible_max_total_cltv_delta);
+ let route = get_route(&our_id, &feasible_payee, &network_graph, None, 100, 42, Arc::clone(&logger), &scorer).unwrap();
+ let path = route.paths[0].iter().map(|hop| hop.short_channel_id).collect::<Vec<_>>();
+ assert_ne!(path.len(), 0);
+
+ // But not if we exclude all paths on the basis of their accumulated CLTV delta
+ let fail_max_total_cltv_delta = 23;
+ let fail_payee = Payee::from_node_id(nodes[6]).with_route_hints(last_hops(&nodes))
+ .with_max_total_cltv_expiry_delta(fail_max_total_cltv_delta);
+ match get_route(&our_id, &fail_payee, &network_graph, None, 100, 42, Arc::clone(&logger), &scorer)
+ {
+ Err(LightningError { err, .. } ) => {
+ assert_eq!(err, "Failed to find a path to the given destination");
+ },
+ Ok(_) => panic!("Expected error"),
+ }
+ }
+