Check `max_total_routing_fee` is reduced in `mpp_retry` test
authorElias Rohrer <dev@tnull.de>
Wed, 20 Sep 2023 13:32:37 +0000 (15:32 +0200)
committerElias Rohrer <dev@tnull.de>
Tue, 26 Sep 2023 18:12:30 +0000 (20:12 +0200)
We check that the `RouteParameters::max_total_routing_fee` field is reduced accordingly
to our previously used fees.

lightning/src/ln/functional_test_utils.rs
lightning/src/ln/payment_tests.rs

index f6684485dba0d69964686b145b9fd3b383c854cc..8f27cf1ad53979344e98e8a9d5eede2c5f338d49 100644 (file)
@@ -1878,7 +1878,11 @@ macro_rules! get_route_and_payment_hash {
                $crate::get_route_and_payment_hash!($send_node, $recv_node, payment_params, $recv_value)
        }};
        ($send_node: expr, $recv_node: expr, $payment_params: expr, $recv_value: expr) => {{
-               let route_params = $crate::routing::router::RouteParameters::from_payment_params_and_value($payment_params, $recv_value);
+               $crate::get_route_and_payment_hash!($send_node, $recv_node, $payment_params, $recv_value, None)
+       }};
+       ($send_node: expr, $recv_node: expr, $payment_params: expr, $recv_value: expr, $max_total_routing_fee_msat: expr) => {{
+               let mut route_params = $crate::routing::router::RouteParameters::from_payment_params_and_value($payment_params, $recv_value);
+               route_params.max_total_routing_fee_msat = $max_total_routing_fee_msat;
                let (payment_preimage, payment_hash, payment_secret) =
                        $crate::ln::functional_test_utils::get_payment_preimage_hash(&$recv_node, Some($recv_value), None);
                let route = $crate::ln::functional_test_utils::get_route(&$send_node, &route_params);
index f74fab255e6e7916a2fb334c1a518c51bf23c8b1..1bd4a8fa91f680caf97db9f2c0631b8cc4cd4354 100644 (file)
@@ -83,7 +83,11 @@ fn mpp_retry() {
        send_payment(&nodes[3], &vec!(&nodes[2])[..], 1_500_000);
 
        let amt_msat = 1_000_000;
-       let (mut route, payment_hash, payment_preimage, payment_secret) = get_route_and_payment_hash!(nodes[0], nodes[3], amt_msat);
+       let max_total_routing_fee_msat = 50_000;
+       let payment_params = PaymentParameters::from_node_id(nodes[3].node.get_our_node_id(), TEST_FINAL_CLTV)
+               .with_bolt11_features(nodes[3].node.invoice_features()).unwrap();
+       let (mut route, payment_hash, payment_preimage, payment_secret) = get_route_and_payment_hash!(
+               nodes[0], nodes[3], payment_params, amt_msat, Some(max_total_routing_fee_msat));
        let path = route.paths[0].clone();
        route.paths.push(path);
        route.paths[0].hops[0].pubkey = nodes[1].node.get_our_node_id();
@@ -150,6 +154,9 @@ fn mpp_retry() {
        route.paths.remove(0);
        route_params.final_value_msat = 1_000_000;
        route_params.payment_params.previously_failed_channels.push(chan_4_update.contents.short_channel_id);
+       // Check the remaining max total routing fee for the second attempt is 50_000 - 1_000 msat fee
+       // used by the first path
+       route_params.max_total_routing_fee_msat = Some(max_total_routing_fee_msat - 1_000);
        nodes[0].router.expect_find_route(route_params, Ok(route));
        nodes[0].node.process_pending_htlc_forwards();
        check_added_monitors!(nodes[0], 1);