From: Valentine Wallace Date: Tue, 30 Jan 2024 19:43:59 +0000 (-0500) Subject: Track min HTLC overpay separately from skimmed fees in test utils X-Git-Tag: v0.0.123-beta~87^2~2 X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=2616f020167891f9dcb770571776fb40167c1d48;p=rust-lightning Track min HTLC overpay separately from skimmed fees in test utils --- diff --git a/lightning/src/ln/functional_test_utils.rs b/lightning/src/ln/functional_test_utils.rs index 0e18e3f3f..0dbf0f01c 100644 --- a/lightning/src/ln/functional_test_utils.rs +++ b/lightning/src/ln/functional_test_utils.rs @@ -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, + pub expected_min_htlc_overpay: Vec, 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) -> 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); diff --git a/lightning/src/ln/payment_tests.rs b/lightning/src/ln/payment_tests.rs index aee26e986..09c022a4c 100644 --- a/lightning/src/ln/payment_tests.rs +++ b/lightning/src/ln/payment_tests.rs @@ -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)); }