Skip to content

Commit a20e68d

Browse files
authored
Merge pull request #4240 from valentinewallace/2025-11-test-expose-process-upd-adds
2 parents e2ca5ba + 8ec37c9 commit a20e68d

File tree

4 files changed

+17
-9
lines changed

4 files changed

+17
-9
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6794,7 +6794,15 @@ where
67946794
Ok(())
67956795
}
67966796

6797-
pub(crate) fn process_pending_update_add_htlcs(&self) -> bool {
6797+
#[cfg(any(test, feature = "_test_utils"))]
6798+
/// Process any pending inbound [`msgs::UpdateAddHTLC`] messages, decoding the onion and placing
6799+
/// the pending HTLC in `ChannelManager::forward_htlcs` or
6800+
/// `ChannelManager::pending_intercepted_htlcs` as well as generating relevant [`Event`]s.
6801+
pub fn test_process_pending_update_add_htlcs(&self) -> bool {
6802+
self.process_pending_update_add_htlcs()
6803+
}
6804+
6805+
fn process_pending_update_add_htlcs(&self) -> bool {
67986806
let mut should_persist = false;
67996807
let mut decode_update_add_htlcs = new_hash_map();
68006808
mem::swap(&mut decode_update_add_htlcs, &mut self.decode_update_add_htlcs.lock().unwrap());

lightning/src/ln/onion_route_tests.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1172,7 +1172,7 @@ fn test_onion_failure() {
11721172
&payment_secret,
11731173
|_| {},
11741174
|| {
1175-
nodes[1].node.process_pending_update_add_htlcs();
1175+
nodes[1].node.test_process_pending_update_add_htlcs();
11761176
for (_, pending_forwards) in nodes[1].node.forward_htlcs.lock().unwrap().iter_mut() {
11771177
for f in pending_forwards.iter_mut() {
11781178
match f {
@@ -1201,7 +1201,7 @@ fn test_onion_failure() {
12011201
&payment_secret,
12021202
|_| {},
12031203
|| {
1204-
nodes[1].node.process_pending_update_add_htlcs();
1204+
nodes[1].node.test_process_pending_update_add_htlcs();
12051205
// violate amt_to_forward > msg.amount_msat
12061206
for (_, pending_forwards) in nodes[1].node.forward_htlcs.lock().unwrap().iter_mut() {
12071207
for f in pending_forwards.iter_mut() {
@@ -2440,7 +2440,7 @@ fn test_phantom_onion_hmac_failure() {
24402440
nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &update_add);
24412441
commitment_signed_dance!(nodes[1], nodes[0], &update_0.commitment_signed, false, true);
24422442
expect_htlc_failure_conditions(nodes[1].node.get_and_clear_pending_events(), &[]);
2443-
nodes[1].node.process_pending_update_add_htlcs();
2443+
nodes[1].node.test_process_pending_update_add_htlcs();
24442444

24452445
// Modify the payload so the phantom hop's HMAC is bogus.
24462446
let sha256_of_onion = {
@@ -2513,7 +2513,7 @@ fn test_phantom_invalid_onion_payload() {
25132513
nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &update_add);
25142514
commitment_signed_dance!(nodes[1], nodes[0], &update_0.commitment_signed, false, true);
25152515
expect_htlc_failure_conditions(nodes[1].node.get_and_clear_pending_events(), &[]);
2516-
nodes[1].node.process_pending_update_add_htlcs();
2516+
nodes[1].node.test_process_pending_update_add_htlcs();
25172517

25182518
// Modify the onion packet to have an invalid payment amount.
25192519
for (_, pending_forwards) in nodes[1].node.forward_htlcs.lock().unwrap().iter_mut() {
@@ -2612,7 +2612,7 @@ fn test_phantom_final_incorrect_cltv_expiry() {
26122612
nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &update_add);
26132613
commitment_signed_dance!(nodes[1], nodes[0], &update_0.commitment_signed, false, true);
26142614
expect_htlc_failure_conditions(nodes[1].node.get_and_clear_pending_events(), &[]);
2615-
nodes[1].node.process_pending_update_add_htlcs();
2615+
nodes[1].node.test_process_pending_update_add_htlcs();
26162616

26172617
// Modify the payload so the phantom hop's HMAC is bogus.
26182618
for (_, pending_forwards) in nodes[1].node.forward_htlcs.lock().unwrap().iter_mut() {

lightning/src/ln/payment_tests.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,7 @@ fn test_reject_mpp_keysend_htlc_mismatching_secret() {
633633
nodes[3].node.handle_update_add_htlc(node_b_id, &update_add_1);
634634
commitment_signed_dance!(nodes[3], nodes[1], update_1.commitment_signed, false, true);
635635
expect_htlc_failure_conditions(nodes[3].node.get_and_clear_pending_events(), &[]);
636-
nodes[3].node.process_pending_update_add_htlcs();
636+
nodes[3].node.test_process_pending_update_add_htlcs();
637637

638638
assert!(nodes[3].node.get_and_clear_pending_msg_events().is_empty());
639639
for (_, pending_forwards) in nodes[3].node.forward_htlcs.lock().unwrap().iter_mut() {
@@ -682,7 +682,7 @@ fn test_reject_mpp_keysend_htlc_mismatching_secret() {
682682
nodes[3].node.handle_update_add_htlc(node_c_id, &update_add_3);
683683
commitment_signed_dance!(nodes[3], nodes[2], update_3.commitment_signed, false, true);
684684
expect_htlc_failure_conditions(nodes[3].node.get_and_clear_pending_events(), &[]);
685-
nodes[3].node.process_pending_update_add_htlcs();
685+
nodes[3].node.test_process_pending_update_add_htlcs();
686686

687687
assert!(nodes[3].node.get_and_clear_pending_msg_events().is_empty());
688688
for (_, pending_forwards) in nodes[3].node.forward_htlcs.lock().unwrap().iter_mut() {

lightning/src/ln/reload_tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -966,7 +966,7 @@ fn do_forwarded_payment_no_manager_persistence(use_cs_commitment: bool, claim_ht
966966
let mut intercept_id = None;
967967
let mut expected_outbound_amount_msat = None;
968968
if use_intercept {
969-
nodes[1].node.process_pending_update_add_htlcs();
969+
nodes[1].node.test_process_pending_update_add_htlcs();
970970
let events = nodes[1].node.get_and_clear_pending_events();
971971
assert_eq!(events.len(), 1);
972972
match events[0] {

0 commit comments

Comments
 (0)