+#[test]
+fn preflight_probes_yield_event_skip_private_hop() {
+ let chanmon_cfgs = create_chanmon_cfgs(5);
+ let node_cfgs = create_node_cfgs(5, &chanmon_cfgs);
+
+ // We alleviate the HTLC max-in-flight limit, as otherwise we'd always be limited through that.
+ let mut no_htlc_limit_config = test_default_channel_config();
+ no_htlc_limit_config.channel_handshake_config.max_inbound_htlc_value_in_flight_percent_of_channel = 100;
+
+ let user_configs = std::iter::repeat(no_htlc_limit_config).take(5).map(|c| Some(c)).collect::<Vec<Option<UserConfig>>>();
+ let node_chanmgrs = create_node_chanmgrs(5, &node_cfgs, &user_configs);
+ let nodes = create_network(5, &node_cfgs, &node_chanmgrs);
+
+ // Setup channel topology:
+ // N0 -(1M:0)- N1 -(1M:0)- N2 -(70k:0)- N3 -(50k:0)- N4
+
+ create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 1_000_000, 0);
+ create_announced_chan_between_nodes_with_value(&nodes, 1, 2, 1_000_000, 0);
+ create_announced_chan_between_nodes_with_value(&nodes, 2, 3, 70_000, 0);
+ create_unannounced_chan_between_nodes_with_value(&nodes, 3, 4, 50_000, 0);
+
+ let mut invoice_features = Bolt11InvoiceFeatures::empty();
+ invoice_features.set_basic_mpp_optional();
+
+ let payment_params = PaymentParameters::from_node_id(nodes[3].node.get_our_node_id(), TEST_FINAL_CLTV)
+ .with_bolt11_features(invoice_features).unwrap();
+
+ let recv_value = 50_000_000;
+ let route_params = RouteParameters::from_payment_params_and_value(payment_params, recv_value);
+ let res = nodes[0].node.send_preflight_probes(route_params, None).unwrap();
+
+ let expected_route: &[&[&Node]] = &[&[&nodes[1], &nodes[2], &nodes[3]]];
+
+ assert_eq!(res.len(), expected_route.len());
+
+ send_probe_along_route(&nodes[0], expected_route);
+
+ expect_probe_successful_events(&nodes[0], res.clone());
+
+ assert!(!nodes[0].node.has_pending_payments());
+}
+
+#[test]
+fn preflight_probes_yield_event() {
+ let chanmon_cfgs = create_chanmon_cfgs(4);
+ let node_cfgs = create_node_cfgs(4, &chanmon_cfgs);
+
+ // We alleviate the HTLC max-in-flight limit, as otherwise we'd always be limited through that.
+ let mut no_htlc_limit_config = test_default_channel_config();
+ no_htlc_limit_config.channel_handshake_config.max_inbound_htlc_value_in_flight_percent_of_channel = 100;
+
+ let user_configs = std::iter::repeat(no_htlc_limit_config).take(4).map(|c| Some(c)).collect::<Vec<Option<UserConfig>>>();
+ let node_chanmgrs = create_node_chanmgrs(4, &node_cfgs, &user_configs);
+ let nodes = create_network(4, &node_cfgs, &node_chanmgrs);
+
+ // Setup channel topology:
+ // (1M:0)- N1 -(30k:0)
+ // / \
+ // N0 N4
+ // \ /
+ // (1M:0)- N2 -(70k:0)
+ //
+ create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 1_000_000, 0);
+ create_announced_chan_between_nodes_with_value(&nodes, 0, 2, 1_000_000, 0);
+ create_announced_chan_between_nodes_with_value(&nodes, 1, 3, 30_000, 0);
+ create_announced_chan_between_nodes_with_value(&nodes, 2, 3, 70_000, 0);
+
+ let mut invoice_features = Bolt11InvoiceFeatures::empty();
+ invoice_features.set_basic_mpp_optional();
+
+ let payment_params = PaymentParameters::from_node_id(nodes[3].node.get_our_node_id(), TEST_FINAL_CLTV)
+ .with_bolt11_features(invoice_features).unwrap();
+
+ let recv_value = 50_000_000;
+ let route_params = RouteParameters::from_payment_params_and_value(payment_params, recv_value);
+ let res = nodes[0].node.send_preflight_probes(route_params, None).unwrap();
+
+ let expected_route: &[&[&Node]] = &[&[&nodes[1], &nodes[3]], &[&nodes[2], &nodes[3]]];
+
+ assert_eq!(res.len(), expected_route.len());
+
+ send_probe_along_route(&nodes[0], expected_route);
+
+ expect_probe_successful_events(&nodes[0], res.clone());
+
+ assert!(!nodes[0].node.has_pending_payments());
+}
+