Skip to content

Commit b75ee3b

Browse files
Support overpayment in test util pass_along_path.
Useful for payments to blinded paths where rounding errors during BlindedPayInfo aggregation may result in overpayment.
1 parent 72adcfe commit b75ee3b

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

lightning/src/ln/functional_test_utils.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2412,6 +2412,9 @@ pub struct PassAlongPathArgs<'a, 'b, 'c, 'd> {
24122412
pub clear_recipient_events: bool,
24132413
pub expected_preimage: Option<PaymentPreimage>,
24142414
pub is_probe: bool,
2415+
// Allow overpayment to the recipient up to this amount. Useful for payments to blinded paths
2416+
// where rounding errors during `BlindedPayInfo` aggregation may result in overpayment.
2417+
pub overpay_limit: u64,
24152418
}
24162419

24172420
impl<'a, 'b, 'c, 'd> PassAlongPathArgs<'a, 'b, 'c, 'd> {
@@ -2422,7 +2425,7 @@ impl<'a, 'b, 'c, 'd> PassAlongPathArgs<'a, 'b, 'c, 'd> {
24222425
Self {
24232426
origin_node, expected_path, recv_value, payment_hash, payment_secret: None, event,
24242427
payment_claimable_expected: true, clear_recipient_events: true, expected_preimage: None,
2425-
is_probe: false,
2428+
is_probe: false, overpay_limit: 0,
24262429
}
24272430
}
24282431
pub fn clear_recipient_events(mut self, clear_recipient_events: bool) -> Self {
@@ -2446,13 +2449,17 @@ impl<'a, 'b, 'c, 'd> PassAlongPathArgs<'a, 'b, 'c, 'd> {
24462449
self.expected_preimage = Some(payment_preimage);
24472450
self
24482451
}
2452+
pub fn with_overpay_limit(mut self, overpay_limit: u64) -> Self {
2453+
self.overpay_limit = overpay_limit;
2454+
self
2455+
}
24492456
}
24502457

24512458
pub fn do_pass_along_path<'a, 'b, 'c>(args: PassAlongPathArgs) -> Option<Event> {
24522459
let PassAlongPathArgs {
24532460
origin_node, expected_path, recv_value, payment_hash: our_payment_hash,
24542461
payment_secret: our_payment_secret, event: ev, payment_claimable_expected,
2455-
clear_recipient_events, expected_preimage, is_probe
2462+
clear_recipient_events, expected_preimage, is_probe, overpay_limit,
24562463
} = args;
24572464

24582465
let mut payment_event = SendEvent::from_event(ev);
@@ -2496,7 +2503,8 @@ pub fn do_pass_along_path<'a, 'b, 'c>(args: PassAlongPathArgs) -> Option<Event>
24962503
assert_eq!(our_payment_secret, onion_fields.as_ref().unwrap().payment_secret);
24972504
},
24982505
}
2499-
assert_eq!(*amount_msat, recv_value);
2506+
assert!(*amount_msat >= recv_value);
2507+
assert!(*amount_msat <= recv_value + overpay_limit);
25002508
assert!(node.node.list_channels().iter().any(|details| details.channel_id == via_channel_id.unwrap()));
25012509
assert!(node.node.list_channels().iter().any(|details| details.user_channel_id == via_user_channel_id.unwrap()));
25022510
assert!(claim_deadline.unwrap() > node.best_block_info().1);

0 commit comments

Comments
 (0)