Skip to content

Commit dfc71ea

Browse files
committed
Add failure test cases for max_mpp_path_count.
1 parent be095a2 commit dfc71ea

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

lightning/src/routing/router.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4111,6 +4111,26 @@ mod tests {
41114111
} else { panic!(); }
41124112
}
41134113

4114+
{
4115+
// Attempt to route while setting max_mpp_path_count to 0 results in a failure..
4116+
let zero_payment_params = payment_params.clone().with_max_mpp_path_count(0);
4117+
if let Err(LightningError{err, action: ErrorAction::IgnoreError}) = get_route(
4118+
&our_id, &zero_payment_params, &network_graph.read_only(), None, 100, 42, Arc::clone(&logger), &scorer, &random_seed_bytes) {
4119+
assert_eq!(err, "Can't find an MPP route with no paths allowed.");
4120+
} else { panic!(); }
4121+
}
4122+
4123+
{
4124+
// Attempt to route while setting max_mpp_path_count to 3 results in a failure..
4125+
// This is the case because the minimal_value_contribution_msat would require each path
4126+
// to account for 1/3 of the total value, which is violated by 2 out of 3 paths.
4127+
let fail_payment_params = payment_params.clone().with_max_mpp_path_count(3);
4128+
if let Err(LightningError{err, action: ErrorAction::IgnoreError}) = get_route(
4129+
&our_id, &fail_payment_params, &network_graph.read_only(), None, 250_000, 42, Arc::clone(&logger), &scorer, &random_seed_bytes) {
4130+
assert_eq!(err, "Failed to find a sufficient route to the given destination");
4131+
} else { panic!(); }
4132+
}
4133+
41144134
{
41154135
// Now, attempt to route 250 sats (just a bit below the capacity).
41164136
// Our algorithm should provide us with these 3 paths.

0 commit comments

Comments
 (0)