diff --git a/lightning/src/ln/functional_test_utils.rs b/lightning/src/ln/functional_test_utils.rs index 4a1f1065d33..984f42fea71 100644 --- a/lightning/src/ln/functional_test_utils.rs +++ b/lightning/src/ln/functional_test_utils.rs @@ -2426,6 +2426,9 @@ pub struct PassAlongPathArgs<'a, 'b, 'c, 'd> { pub clear_recipient_events: bool, pub expected_preimage: Option, pub is_probe: bool, + // Allow overpayment to the recipient up to this amount. Useful for payments to blinded paths + // where rounding errors during `BlindedPayInfo` aggregation may result in overpayment. + pub overpay_limit: u64, } impl<'a, 'b, 'c, 'd> PassAlongPathArgs<'a, 'b, 'c, 'd> { @@ -2436,7 +2439,7 @@ impl<'a, 'b, 'c, 'd> PassAlongPathArgs<'a, 'b, 'c, 'd> { Self { origin_node, expected_path, recv_value, payment_hash, payment_secret: None, event, payment_claimable_expected: true, clear_recipient_events: true, expected_preimage: None, - is_probe: false, + is_probe: false, overpay_limit: 0, } } pub fn clear_recipient_events(mut self, clear_recipient_events: bool) -> Self { @@ -2460,13 +2463,17 @@ impl<'a, 'b, 'c, 'd> PassAlongPathArgs<'a, 'b, 'c, 'd> { self.expected_preimage = Some(payment_preimage); self } + pub fn with_overpay_limit(mut self, overpay_limit: u64) -> Self { + self.overpay_limit = overpay_limit; + self + } } pub fn do_pass_along_path<'a, 'b, 'c>(args: PassAlongPathArgs) -> Option { let PassAlongPathArgs { origin_node, expected_path, recv_value, payment_hash: our_payment_hash, payment_secret: our_payment_secret, event: ev, payment_claimable_expected, - clear_recipient_events, expected_preimage, is_probe + clear_recipient_events, expected_preimage, is_probe, overpay_limit, } = args; let mut payment_event = SendEvent::from_event(ev); @@ -2510,7 +2517,8 @@ pub fn do_pass_along_path<'a, 'b, 'c>(args: PassAlongPathArgs) -> Option assert_eq!(our_payment_secret, onion_fields.as_ref().unwrap().payment_secret); }, } - assert_eq!(*amount_msat, recv_value); + assert!(*amount_msat >= recv_value); + assert!(*amount_msat <= recv_value + overpay_limit); assert!(node.node.list_channels().iter().any(|details| details.channel_id == via_channel_id.unwrap())); assert!(node.node.list_channels().iter().any(|details| details.user_channel_id == via_user_channel_id.unwrap())); assert!(claim_deadline.unwrap() > node.best_block_info().1);