Skip to content

Commit dd127a8

Browse files
authored
Merge pull request #4253 from valentinewallace/2025-12-test-expose-process-upd-adds
Expose `process_pending_update_add_htlcs` in tests
2 parents 3e186bc + aa6a64b commit dd127a8

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
@@ -6833,7 +6833,15 @@ where
68336833
Ok(())
68346834
}
68356835

6836-
pub(crate) fn process_pending_update_add_htlcs(&self) -> bool {
6836+
#[cfg(any(test, feature = "_test_utils"))]
6837+
/// Process any pending inbound [`msgs::UpdateAddHTLC`] messages, decoding the onion and placing
6838+
/// the pending HTLC in `ChannelManager::forward_htlcs` or
6839+
/// `ChannelManager::pending_intercepted_htlcs` as well as generating relevant [`Event`]s.
6840+
pub fn test_process_pending_update_add_htlcs(&self) -> bool {
6841+
self.process_pending_update_add_htlcs()
6842+
}
6843+
6844+
fn process_pending_update_add_htlcs(&self) -> bool {
68376845
let mut should_persist = false;
68386846
let mut decode_update_add_htlcs = new_hash_map();
68396847
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
@@ -1174,7 +1174,7 @@ fn test_onion_failure() {
11741174
&payment_secret,
11751175
|_| {},
11761176
|| {
1177-
nodes[1].node.process_pending_update_add_htlcs();
1177+
nodes[1].node.test_process_pending_update_add_htlcs();
11781178
for (_, pending_forwards) in nodes[1].node.forward_htlcs.lock().unwrap().iter_mut() {
11791179
for f in pending_forwards.iter_mut() {
11801180
match f {
@@ -1203,7 +1203,7 @@ fn test_onion_failure() {
12031203
&payment_secret,
12041204
|_| {},
12051205
|| {
1206-
nodes[1].node.process_pending_update_add_htlcs();
1206+
nodes[1].node.test_process_pending_update_add_htlcs();
12071207
// violate amt_to_forward > msg.amount_msat
12081208
for (_, pending_forwards) in nodes[1].node.forward_htlcs.lock().unwrap().iter_mut() {
12091209
for f in pending_forwards.iter_mut() {
@@ -2442,7 +2442,7 @@ fn test_phantom_onion_hmac_failure() {
24422442
nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &update_add);
24432443
do_commitment_signed_dance(&nodes[1], &nodes[0], &update_0.commitment_signed, false, true);
24442444
expect_htlc_failure_conditions(nodes[1].node.get_and_clear_pending_events(), &[]);
2445-
nodes[1].node.process_pending_update_add_htlcs();
2445+
nodes[1].node.test_process_pending_update_add_htlcs();
24462446

24472447
// Modify the payload so the phantom hop's HMAC is bogus.
24482448
let sha256_of_onion = {
@@ -2515,7 +2515,7 @@ fn test_phantom_invalid_onion_payload() {
25152515
nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &update_add);
25162516
do_commitment_signed_dance(&nodes[1], &nodes[0], &update_0.commitment_signed, false, true);
25172517
expect_htlc_failure_conditions(nodes[1].node.get_and_clear_pending_events(), &[]);
2518-
nodes[1].node.process_pending_update_add_htlcs();
2518+
nodes[1].node.test_process_pending_update_add_htlcs();
25192519

25202520
// Modify the onion packet to have an invalid payment amount.
25212521
for (_, pending_forwards) in nodes[1].node.forward_htlcs.lock().unwrap().iter_mut() {
@@ -2614,7 +2614,7 @@ fn test_phantom_final_incorrect_cltv_expiry() {
26142614
nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &update_add);
26152615
do_commitment_signed_dance(&nodes[1], &nodes[0], &update_0.commitment_signed, false, true);
26162616
expect_htlc_failure_conditions(nodes[1].node.get_and_clear_pending_events(), &[]);
2617-
nodes[1].node.process_pending_update_add_htlcs();
2617+
nodes[1].node.test_process_pending_update_add_htlcs();
26182618

26192619
// Modify the payload so the phantom hop's HMAC is bogus.
26202620
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
@@ -635,7 +635,7 @@ fn test_reject_mpp_keysend_htlc_mismatching_secret() {
635635
nodes[3].node.handle_update_add_htlc(node_b_id, &update_add_1);
636636
do_commitment_signed_dance(&nodes[3], &nodes[1], &update_1.commitment_signed, false, true);
637637
expect_htlc_failure_conditions(nodes[3].node.get_and_clear_pending_events(), &[]);
638-
nodes[3].node.process_pending_update_add_htlcs();
638+
nodes[3].node.test_process_pending_update_add_htlcs();
639639

640640
assert!(nodes[3].node.get_and_clear_pending_msg_events().is_empty());
641641
for (_, pending_forwards) in nodes[3].node.forward_htlcs.lock().unwrap().iter_mut() {
@@ -684,7 +684,7 @@ fn test_reject_mpp_keysend_htlc_mismatching_secret() {
684684
nodes[3].node.handle_update_add_htlc(node_c_id, &update_add_3);
685685
do_commitment_signed_dance(&nodes[3], &nodes[2], &update_3.commitment_signed, false, true);
686686
expect_htlc_failure_conditions(nodes[3].node.get_and_clear_pending_events(), &[]);
687-
nodes[3].node.process_pending_update_add_htlcs();
687+
nodes[3].node.test_process_pending_update_add_htlcs();
688688

689689
assert!(nodes[3].node.get_and_clear_pending_msg_events().is_empty());
690690
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)