]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Track min HTLC overpay separately from skimmed fees in test utils
authorValentine Wallace <vwallace@protonmail.com>
Tue, 30 Jan 2024 19:43:59 +0000 (14:43 -0500)
committerElias Rohrer <dev@tnull.de>
Wed, 31 Jan 2024 12:22:19 +0000 (13:22 +0100)
lightning/src/ln/functional_test_utils.rs
lightning/src/ln/payment_tests.rs

index 0e18e3f3f315440162126ee7abb969ca414d84dd..0dbf0f01cb73ebe3ec4bb373e9038d0654eec963 100644 (file)
@@ -2566,6 +2566,7 @@ pub struct ClaimAlongRouteArgs<'a, 'b, 'c, 'd> {
        pub origin_node: &'a Node<'b, 'c, 'd>,
        pub expected_paths: &'a [&'a [&'a Node<'b, 'c, 'd>]],
        pub expected_extra_fees: Vec<u32>,
+       pub expected_min_htlc_overpay: Vec<u32>,
        pub skip_last: bool,
        pub payment_preimage: PaymentPreimage,
 }
@@ -2577,7 +2578,7 @@ impl<'a, 'b, 'c, 'd> ClaimAlongRouteArgs<'a, 'b, 'c, 'd> {
        ) -> Self {
                Self {
                        origin_node, expected_paths, expected_extra_fees: vec![0; expected_paths.len()],
-                       skip_last: false, payment_preimage,
+                       expected_min_htlc_overpay: vec![0; expected_paths.len()], skip_last: false, payment_preimage,
                }
        }
        pub fn skip_last(mut self, skip_last: bool) -> Self {
@@ -2588,11 +2589,15 @@ impl<'a, 'b, 'c, 'd> ClaimAlongRouteArgs<'a, 'b, 'c, 'd> {
                self.expected_extra_fees = extra_fees;
                self
        }
+       pub fn with_expected_min_htlc_overpay(mut self, extra_fees: Vec<u32>) -> Self {
+               self.expected_min_htlc_overpay = extra_fees;
+               self
+       }
 }
 
 pub fn pass_claimed_payment_along_route<'a, 'b, 'c, 'd>(args: ClaimAlongRouteArgs) -> u64 {
        let ClaimAlongRouteArgs {
-               origin_node, expected_paths, expected_extra_fees, skip_last,
+               origin_node, expected_paths, expected_extra_fees, expected_min_htlc_overpay, skip_last,
                payment_preimage: our_payment_preimage
        } = args;
        let claim_event = expected_paths[0].last().unwrap().node.get_and_clear_pending_events();
@@ -2691,7 +2696,10 @@ pub fn pass_claimed_payment_along_route<'a, 'b, 'c, 'd>(args: ClaimAlongRouteArg
                                                        channel.context().config().forwarding_fee_base_msat
                                                }
                                        };
-                                       if $idx == 1 { fee += expected_extra_fees[i]; }
+                                       if $idx == 1 {
+                                               fee += expected_extra_fees[i];
+                                               fee += expected_min_htlc_overpay[i];
+                                       }
                                        expect_payment_forwarded!(*$node, $next_node, $prev_node, Some(fee as u64), false, false);
                                        expected_total_fee_msat += fee as u64;
                                        check_added_monitors!($node, 1);
index aee26e98671d77ee7e20cf7559f6e5bfcdc24dd5..09c022a4c87b1f3e8d106126fde4fd212c22b75a 100644 (file)
@@ -281,7 +281,7 @@ fn mpp_retry_overpay() {
        let extra_fees = vec![0, total_overpaid_amount];
        let expected_route = &[&[&nodes[1], &nodes[3]][..], &[&nodes[2], &nodes[3]][..]];
        let args = ClaimAlongRouteArgs::new(&nodes[0], &expected_route[..], payment_preimage)
-               .with_expected_extra_fees(extra_fees);
+               .with_expected_min_htlc_overpay(extra_fees);
        let expected_total_fee_msat = pass_claimed_payment_along_route(args);
        expect_payment_sent!(&nodes[0], payment_preimage, Some(expected_total_fee_msat));
 }