- let amt = seed as u64 % 1_000_000;
- if let Ok(route) = get_route(&payer, ¶ms, &graph.read_only(), Some(&[&first_hop]),
- amt, &TestLogger::new(), &scorer, score_params, &random_seed_bytes,
- ) {
- routes.push(route);
- route_endpoints.push((first_hop, params, amt));
- continue 'load_endpoints;
- }
- }
- }
+ let amt = starting_amount + seed % 1_000_000;
+ let path_exists =
+ get_route(&payer, ¶ms, &graph.read_only(), Some(&[&first_hop]),
+ amt, &TestLogger::new(), &scorer, score_params, &random_seed_bytes).is_ok();
+ if path_exists {
+ // ...and seed the scorer with success and failure data...
+ seed = seed.overflowing_mul(6364136223846793005).0.overflowing_add(1).0;
+ let mut score_amt = seed % 1_000_000_000;
+ loop {
+ // Generate fail/success paths for a wider range of potential amounts with
+ // MPP enabled to give us a chance to apply penalties for more potential
+ // routes.
+ let mpp_features = channelmanager::provided_invoice_features(&UserConfig::default());
+ let params = PaymentParameters::from_node_id(dst, 42)
+ .with_bolt11_features(mpp_features).unwrap();
+
+ let route_res = get_route(&payer, ¶ms, &graph.read_only(),
+ Some(&[&first_hop]), score_amt, &TestLogger::new(), &scorer,
+ score_params, &random_seed_bytes);
+ if let Ok(route) = route_res {
+ for path in route.paths {
+ if seed & 0x80 == 0 {
+ scorer.payment_path_successful(&path);
+ } else {
+ let short_channel_id = path.hops[path.hops.len() / 2].short_channel_id;
+ scorer.payment_path_failed(&path, short_channel_id);
+ }
+ seed = seed.overflowing_mul(6364136223846793005).0.overflowing_add(1).0;
+ }
+ break;
+ }
+ // If we couldn't find a path with a higer amount, reduce and try again.
+ score_amt /= 100;
+ }