From: Elias Rohrer Date: Wed, 20 Sep 2023 13:32:37 +0000 (+0200) Subject: Check `max_total_routing_fee` is reduced in `mpp_retry` test X-Git-Tag: v0.0.117-alpha2~5^2~2 X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=26b515c13cccd1d027e67d0c65d69321d235ce40;p=rust-lightning Check `max_total_routing_fee` is reduced in `mpp_retry` test We check that the `RouteParameters::max_total_routing_fee` field is reduced accordingly to our previously used fees. --- diff --git a/lightning/src/ln/functional_test_utils.rs b/lightning/src/ln/functional_test_utils.rs index f6684485d..8f27cf1ad 100644 --- a/lightning/src/ln/functional_test_utils.rs +++ b/lightning/src/ln/functional_test_utils.rs @@ -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); diff --git a/lightning/src/ln/payment_tests.rs b/lightning/src/ln/payment_tests.rs index f74fab255..1bd4a8fa9 100644 --- a/lightning/src/ln/payment_tests.rs +++ b/lightning/src/ln/payment_tests.rs @@ -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);