@@ -4821,6 +4821,31 @@ mod tests {
4821
4821
assert_eq ! ( route. get_total_amount( ) , 0 ) ;
4822
4822
}
4823
4823
4824
+ #[ test]
4825
+ fn limits_total_cltv_delta ( ) {
4826
+ let ( secp_ctx, network_graph, _, _, logger) = build_graph ( ) ;
4827
+ let ( _, our_id, _, nodes) = get_nodes ( & secp_ctx) ;
4828
+ let payee = Payee :: from_node_id ( nodes[ 6 ] ) . with_route_hints ( last_hops ( & nodes) ) ;
4829
+
4830
+ let scorer = test_utils:: TestScorer :: with_fixed_penalty ( 0 ) ;
4831
+
4832
+ // Make sure that generally there is at least one route available
4833
+ let feasible_max_total_cltv_delta = 1000 ;
4834
+ let route = get_route ( & our_id, & payee, & network_graph, None , 100 , 42 , feasible_max_total_cltv_delta, Arc :: clone ( & logger) , & scorer) . unwrap ( ) ;
4835
+ let path = route. paths [ 0 ] . iter ( ) . map ( |hop| hop. short_channel_id ) . collect :: < Vec < _ > > ( ) ;
4836
+ assert_ne ! ( path. len( ) , 0 ) ;
4837
+
4838
+ // But not if we exclude all paths on the basis of their accumulated CLTV delta
4839
+ let fail_max_total_cltv_delta = 0 ;
4840
+ match get_route ( & our_id, & payee, & network_graph, None , 100 , 42 , fail_max_total_cltv_delta, Arc :: clone ( & logger) , & scorer)
4841
+ {
4842
+ Err ( LightningError { err, .. } ) => {
4843
+ assert_eq ! ( err, "Failed to find a path to the given destination" ) ;
4844
+ } ,
4845
+ Ok ( _) => panic ! ( "Expected error" ) ,
4846
+ }
4847
+ }
4848
+
4824
4849
#[ cfg( not( feature = "no-std" ) ) ]
4825
4850
pub ( super ) fn random_init_seed ( ) -> u64 {
4826
4851
// Because the default HashMap in std pulls OS randomness, we can use it as a (bad) RNG.
0 commit comments