@@ -887,7 +887,7 @@ where L::Target: Logger {
887
887
HashMap :: with_capacity ( network_nodes. len ( ) ) ;
888
888
889
889
// Keeping track of how much value we already collected across other paths. Helps to decide
890
- // when we want to stop looking for new paths.
890
+ // when we want to stop looking for new paths.
891
891
let mut already_collected_value_msat = 0 ;
892
892
893
893
for ( _, channels) in first_hop_targets. iter_mut ( ) {
@@ -4015,7 +4015,8 @@ mod tests {
4015
4015
let scorer = test_utils:: TestScorer :: with_penalty ( 0 ) ;
4016
4016
let keys_manager = test_utils:: TestKeysInterface :: new ( & [ 0u8 ; 32 ] , Network :: Testnet ) ;
4017
4017
let random_seed_bytes = keys_manager. get_secure_random_bytes ( ) ;
4018
- let payment_params = PaymentParameters :: from_node_id ( nodes[ 2 ] ) . with_features ( InvoiceFeatures :: known ( ) ) ;
4018
+ let payment_params = PaymentParameters :: from_node_id ( nodes[ 2 ] )
4019
+ . with_features ( InvoiceFeatures :: known ( ) ) ;
4019
4020
4020
4021
// We need a route consisting of 3 paths:
4021
4022
// From our node to node2 via node0, node7, node1 (three paths one hop each).
@@ -4108,15 +4109,39 @@ mod tests {
4108
4109
{
4109
4110
// Attempt to route more than available results in a failure.
4110
4111
if let Err ( LightningError { err, action : ErrorAction :: IgnoreError } ) = get_route (
4111
- & our_id, & payment_params, & network_graph. read_only ( ) , None , 300_000 , 42 , Arc :: clone ( & logger) , & scorer, & random_seed_bytes) {
4112
- assert_eq ! ( err, "Failed to find a sufficient route to the given destination" ) ;
4112
+ & our_id, & payment_params, & network_graph. read_only ( ) , None , 300_000 , 42 ,
4113
+ Arc :: clone ( & logger) , & scorer, & random_seed_bytes) {
4114
+ assert_eq ! ( err, "Failed to find a sufficient route to the given destination" ) ;
4115
+ } else { panic ! ( ) ; }
4116
+ }
4117
+
4118
+ {
4119
+ // Attempt to route while setting max_mpp_path_count to 0 results in a failure.
4120
+ let zero_payment_params = payment_params. clone ( ) . with_max_mpp_path_count ( 0 ) ;
4121
+ if let Err ( LightningError { err, action : ErrorAction :: IgnoreError } ) = get_route (
4122
+ & our_id, & zero_payment_params, & network_graph. read_only ( ) , None , 100 , 42 ,
4123
+ Arc :: clone ( & logger) , & scorer, & random_seed_bytes) {
4124
+ assert_eq ! ( err, "Can't find an MPP route with no paths allowed." ) ;
4125
+ } else { panic ! ( ) ; }
4126
+ }
4127
+
4128
+ {
4129
+ // Attempt to route while setting max_mpp_path_count to 3 results in a failure.
4130
+ // This is the case because the minimal_value_contribution_msat would require each path
4131
+ // to account for 1/3 of the total value, which is violated by 2 out of 3 paths.
4132
+ let fail_payment_params = payment_params. clone ( ) . with_max_mpp_path_count ( 3 ) ;
4133
+ if let Err ( LightningError { err, action : ErrorAction :: IgnoreError } ) = get_route (
4134
+ & our_id, & fail_payment_params, & network_graph. read_only ( ) , None , 250_000 , 42 ,
4135
+ Arc :: clone ( & logger) , & scorer, & random_seed_bytes) {
4136
+ assert_eq ! ( err, "Failed to find a sufficient route to the given destination" ) ;
4113
4137
} else { panic ! ( ) ; }
4114
4138
}
4115
4139
4116
4140
{
4117
4141
// Now, attempt to route 250 sats (just a bit below the capacity).
4118
4142
// Our algorithm should provide us with these 3 paths.
4119
- let route = get_route ( & our_id, & payment_params, & network_graph. read_only ( ) , None , 250_000 , 42 , Arc :: clone ( & logger) , & scorer, & random_seed_bytes) . unwrap ( ) ;
4143
+ let route = get_route ( & our_id, & payment_params, & network_graph. read_only ( ) , None ,
4144
+ 250_000 , 42 , Arc :: clone ( & logger) , & scorer, & random_seed_bytes) . unwrap ( ) ;
4120
4145
assert_eq ! ( route. paths. len( ) , 3 ) ;
4121
4146
let mut total_amount_paid_msat = 0 ;
4122
4147
for path in & route. paths {
@@ -4129,7 +4154,8 @@ mod tests {
4129
4154
4130
4155
{
4131
4156
// Attempt to route an exact amount is also fine
4132
- let route = get_route ( & our_id, & payment_params, & network_graph. read_only ( ) , None , 290_000 , 42 , Arc :: clone ( & logger) , & scorer, & random_seed_bytes) . unwrap ( ) ;
4157
+ let route = get_route ( & our_id, & payment_params, & network_graph. read_only ( ) , None ,
4158
+ 290_000 , 42 , Arc :: clone ( & logger) , & scorer, & random_seed_bytes) . unwrap ( ) ;
4133
4159
assert_eq ! ( route. paths. len( ) , 3 ) ;
4134
4160
let mut total_amount_paid_msat = 0 ;
4135
4161
for path in & route. paths {
0 commit comments