Skip to content

Commit c8d379a

Browse files
committed
f Rename expect_pending_htlcs_forwardable_conditions
1 parent 36cf43d commit c8d379a

9 files changed

+47
-62
lines changed

lightning/src/ln/async_payments_tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -915,7 +915,7 @@ fn invalid_async_receive_with_retry<F1, F2>(
915915
// Fail the HTLC backwards to enable us to more easily modify the now-Retryable outbound to test
916916
// failures on the recipient's end.
917917
nodes[2].node.fail_htlc_backwards(&payment_hash);
918-
expect_pending_htlcs_forwardable_conditions(
918+
expect_htlc_failure_conditions(
919919
nodes[2].node.get_and_clear_pending_events(),
920920
&[HTLCHandlingFailureType::Receive { payment_hash }],
921921
);

lightning/src/ln/blinded_payment_tests.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -743,7 +743,7 @@ fn do_blinded_intercept_payment(intercept_node_fails: bool) {
743743

744744
if intercept_node_fails {
745745
nodes[1].node.fail_intercepted_htlc(intercept_id).unwrap();
746-
expect_pending_htlcs_forwardable_conditions(nodes[1].node.get_and_clear_pending_events(), &[HTLCHandlingFailureType::InvalidForward { requested_forward_scid: intercept_scid }]);
746+
expect_htlc_failure_conditions(nodes[1].node.get_and_clear_pending_events(), &[HTLCHandlingFailureType::InvalidForward { requested_forward_scid: intercept_scid }]);
747747
nodes[1].node.process_pending_htlc_forwards();
748748
check_added_monitors!(&nodes[1], 1);
749749
fail_blinded_htlc_backwards(payment_hash, 1, &[&nodes[0], &nodes[1]], false);
@@ -847,7 +847,7 @@ fn three_hop_blinded_path_fail() {
847847
pass_along_route(&nodes[0], &[&[&nodes[1], &nodes[2], &nodes[3]]], amt_msat, payment_hash, payment_secret);
848848

849849
nodes[3].node.fail_htlc_backwards(&payment_hash);
850-
expect_pending_htlcs_forwardable_conditions(
850+
expect_htlc_failure_conditions(
851851
nodes[3].node.get_and_clear_pending_events(), &[HTLCHandlingFailureType::Receive { payment_hash }]
852852
);
853853
nodes[3].node.process_pending_htlc_forwards();
@@ -975,7 +975,7 @@ fn do_multi_hop_receiver_fail(check: ReceiveCheckFail) {
975975
None, nodes[2].node.get_our_node_id()
976976
);
977977
nodes[2].node.fail_htlc_backwards(&payment_hash);
978-
expect_pending_htlcs_forwardable_conditions(
978+
expect_htlc_failure_conditions(
979979
nodes[2].node.get_and_clear_pending_events(), &[HTLCHandlingFailureType::Receive { payment_hash }]
980980
);
981981
nodes[2].node.process_pending_htlc_forwards();
@@ -1042,7 +1042,7 @@ fn do_multi_hop_receiver_fail(check: ReceiveCheckFail) {
10421042
do_commitment_signed_dance(&nodes[2], &nodes[1], &payment_event_1_2.commitment_msg, true, true);
10431043
nodes[2].node.process_pending_htlc_forwards();
10441044
nodes[2].node.process_pending_htlc_forwards();
1045-
expect_pending_htlcs_forwardable_conditions(nodes[2].node.get_and_clear_pending_events(), &[HTLCHandlingFailureType::Receive { payment_hash }]);
1045+
expect_htlc_failure_conditions(nodes[2].node.get_and_clear_pending_events(), &[HTLCHandlingFailureType::Receive { payment_hash }]);
10461046
check_added_monitors!(nodes[2], 1);
10471047
},
10481048
ReceiveCheckFail::PaymentConstraints => {
@@ -1138,7 +1138,7 @@ fn blinded_path_retries() {
11381138
macro_rules! fail_payment_back {
11391139
($intro_node: expr) => {
11401140
nodes[3].node.fail_htlc_backwards(&payment_hash);
1141-
expect_pending_htlcs_forwardable_conditions(
1141+
expect_htlc_failure_conditions(
11421142
nodes[3].node.get_and_clear_pending_events(), &[HTLCHandlingFailureType::Receive { payment_hash }]
11431143
);
11441144
nodes[3].node.process_pending_htlc_forwards();

lightning/src/ln/chanmon_update_fail_tests.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1856,7 +1856,7 @@ fn test_monitor_update_fail_claim() {
18561856
let events = nodes[1].node.get_and_clear_pending_msg_events();
18571857
assert_eq!(events.len(), 0);
18581858
commitment_signed_dance!(nodes[1], nodes[2], payment_event.commitment_msg, false, true);
1859-
expect_pending_htlcs_forwardable_conditions(nodes[1].node.get_and_clear_pending_events(), &[]);
1859+
expect_htlc_failure_conditions(nodes[1].node.get_and_clear_pending_events(), &[]);
18601860

18611861
let (_, payment_hash_3, payment_secret_3) = get_payment_preimage_hash!(nodes[0]);
18621862
let id_3 = PaymentId(payment_hash_3.0);
@@ -2946,10 +2946,7 @@ fn do_test_reconnect_dup_htlc_claims(htlc_status: HTLCStatusAtDupClaim, second_f
29462946
if htlc_status == HTLCStatusAtDupClaim::HoldingCell {
29472947
nodes[1].node.handle_revoke_and_ack(node_a_id, &as_raa.unwrap());
29482948
check_added_monitors!(nodes[1], 1);
2949-
expect_pending_htlcs_forwardable_conditions(
2950-
nodes[1].node.get_and_clear_pending_events(),
2951-
&[],
2952-
); // We finally receive the second payment, but don't claim it
2949+
expect_htlc_failure_conditions(nodes[1].node.get_and_clear_pending_events(), &[]); // We finally receive the second payment, but don't claim it
29532950

29542951
bs_updates = Some(get_htlc_update_msgs!(nodes[1], node_a_id));
29552952
assert_eq!(bs_updates.as_ref().unwrap().update_fulfill_htlcs.len(), 1);

lightning/src/ln/functional_test_utils.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2448,7 +2448,7 @@ macro_rules! expect_htlc_handling_failed_destinations {
24482448
/// Checks that an [`Event::PendingHTLCsForwardable`] is available in the given events and, if
24492449
/// there are any [`Event::HTLCHandlingFailed`] events their [`HTLCHandlingFailureType`] is included in the
24502450
/// `expected_failures` set.
2451-
pub fn expect_pending_htlcs_forwardable_conditions(
2451+
pub fn expect_htlc_failure_conditions(
24522452
events: Vec<Event>, expected_failures: &[HTLCHandlingFailureType],
24532453
) {
24542454
assert_eq!(events.len(), expected_failures.len());
@@ -2461,7 +2461,7 @@ pub fn expect_pending_htlcs_forwardable_conditions(
24612461
/// Handles a PendingHTLCsForwardable and HTLCHandlingFailed event
24622462
macro_rules! process_htlcs_and_expect_htlc_handling_failed {
24632463
($node: expr, $expected_failures: expr) => {{
2464-
$crate::ln::functional_test_utils::expect_pending_htlcs_forwardable_conditions(
2464+
$crate::ln::functional_test_utils::expect_htlc_failure_conditions(
24652465
$node.node.get_and_clear_pending_events(),
24662466
&$expected_failures,
24672467
);

lightning/src/ln/functional_tests.rs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6913,7 +6913,7 @@ pub fn test_bump_penalty_txn_on_revoked_htlcs() {
69136913
);
69146914
connect_block(&nodes[0], &block_129);
69156915
let events = nodes[0].node.get_and_clear_pending_events();
6916-
expect_pending_htlcs_forwardable_conditions(
6916+
expect_htlc_failure_conditions(
69176917
events[0..1].to_vec(),
69186918
&[HTLCHandlingFailureType::Receive { payment_hash: failed_payment_hash }],
69196919
);
@@ -7224,7 +7224,7 @@ pub fn test_bump_txn_sanitize_tracking_maps() {
72247224

72257225
// Broadcast set of revoked txn on A
72267226
connect_blocks(&nodes[0], TEST_FINAL_CLTV + 2 - CHAN_CONFIRM_DEPTH);
7227-
expect_pending_htlcs_forwardable_conditions(
7227+
expect_htlc_failure_conditions(
72287228
nodes[0].node.get_and_clear_pending_events(),
72297229
&[HTLCHandlingFailureType::Receive { payment_hash: payment_hash_2 }],
72307230
);
@@ -9509,7 +9509,7 @@ fn do_test_dup_htlc_second_rejected(test_for_second_fail_panic: bool) {
95099509
// the first HTLC delivered above.
95109510
}
95119511

9512-
expect_pending_htlcs_forwardable_conditions(nodes[1].node.get_and_clear_pending_events(), &[]);
9512+
expect_htlc_failure_conditions(nodes[1].node.get_and_clear_pending_events(), &[]);
95139513
nodes[1].node.process_pending_htlc_forwards();
95149514

95159515
if test_for_second_fail_panic {
@@ -9520,7 +9520,7 @@ fn do_test_dup_htlc_second_rejected(test_for_second_fail_panic: bool) {
95209520
HTLCHandlingFailureType::Receive { payment_hash: our_payment_hash },
95219521
HTLCHandlingFailureType::Receive { payment_hash: our_payment_hash },
95229522
];
9523-
expect_pending_htlcs_forwardable_conditions(
9523+
expect_htlc_failure_conditions(
95249524
nodes[1].node.get_and_clear_pending_events(),
95259525
expected_destinations,
95269526
);
@@ -9554,7 +9554,7 @@ fn do_test_dup_htlc_second_rejected(test_for_second_fail_panic: bool) {
95549554
}
95559555
} else {
95569556
// Let the second HTLC fail and claim the first
9557-
expect_pending_htlcs_forwardable_conditions(
9557+
expect_htlc_failure_conditions(
95589558
nodes[1].node.get_and_clear_pending_events(),
95599559
&[HTLCHandlingFailureType::Receive { payment_hash: our_payment_hash }],
95609560
);
@@ -9684,13 +9684,10 @@ pub fn test_inconsistent_mpp_params() {
96849684
// amount. It will assume the second is a privacy attack (no longer particularly relevant
96859685
// post-payment_secrets) and fail back the new HTLC.
96869686
}
9687-
expect_pending_htlcs_forwardable_conditions(nodes[3].node.get_and_clear_pending_events(), &[]);
9687+
expect_htlc_failure_conditions(nodes[3].node.get_and_clear_pending_events(), &[]);
96889688
nodes[3].node.process_pending_htlc_forwards();
96899689
let fail_type = HTLCHandlingFailureType::Receive { payment_hash: hash };
9690-
expect_pending_htlcs_forwardable_conditions(
9691-
nodes[3].node.get_and_clear_pending_events(),
9692-
&[fail_type],
9693-
);
9690+
expect_htlc_failure_conditions(nodes[3].node.get_and_clear_pending_events(), &[fail_type]);
96949691
nodes[3].node.process_pending_htlc_forwards();
96959692

96969693
check_added_monitors(&nodes[3], 1);

lightning/src/ln/monitor_tests.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1219,7 +1219,7 @@ fn test_no_preimage_inbound_htlc_balances() {
12191219
let as_htlc_timeout_claim = nodes[0].tx_broadcaster.txn_broadcasted.lock().unwrap().split_off(0);
12201220
assert_eq!(as_htlc_timeout_claim.len(), 1);
12211221
check_spends!(as_htlc_timeout_claim[0], as_txn[0]);
1222-
expect_pending_htlcs_forwardable_conditions(nodes[0].node.get_and_clear_pending_events(), &[HTLCHandlingFailureType::Receive { payment_hash: to_a_failed_payment_hash }]);
1222+
expect_htlc_failure_conditions(nodes[0].node.get_and_clear_pending_events(), &[HTLCHandlingFailureType::Receive { payment_hash: to_a_failed_payment_hash }]);
12231223
nodes[0].node.process_pending_htlc_forwards();
12241224

12251225
assert_eq!(as_pre_spend_claims,
@@ -1237,7 +1237,7 @@ fn test_no_preimage_inbound_htlc_balances() {
12371237
// The next few blocks for B look the same as for A, though for the opposite HTLC
12381238
nodes[1].tx_broadcaster.txn_broadcasted.lock().unwrap().clear();
12391239
connect_blocks(&nodes[1], TEST_FINAL_CLTV - (ANTI_REORG_DELAY - 1));
1240-
expect_pending_htlcs_forwardable_conditions(nodes[1].node.get_and_clear_pending_events(), &[HTLCHandlingFailureType::Receive { payment_hash: to_b_failed_payment_hash }]);
1240+
expect_htlc_failure_conditions(nodes[1].node.get_and_clear_pending_events(), &[HTLCHandlingFailureType::Receive { payment_hash: to_b_failed_payment_hash }]);
12411241
nodes[1].node.process_pending_htlc_forwards();
12421242
let bs_htlc_timeout_claim = nodes[1].tx_broadcaster.txn_broadcasted.lock().unwrap().split_off(0);
12431243
assert_eq!(bs_htlc_timeout_claim.len(), 1);
@@ -1738,7 +1738,7 @@ fn do_test_revoked_counterparty_htlc_tx_balances(anchors: bool) {
17381738
// `COUNTERPARTY_CLAIMABLE_WITHIN_BLOCKS_PINNABLE` blocks, making us consider all the HTLCs
17391739
// pinnable claims, which the remainder of the test assumes.
17401740
connect_blocks(&nodes[0], TEST_FINAL_CLTV - COUNTERPARTY_CLAIMABLE_WITHIN_BLOCKS_PINNABLE);
1741-
expect_pending_htlcs_forwardable_conditions(nodes[0].node.get_and_clear_pending_events(),
1741+
expect_htlc_failure_conditions(nodes[0].node.get_and_clear_pending_events(),
17421742
&[HTLCHandlingFailureType::Receive { payment_hash: failed_payment_hash }]);
17431743
// A will generate justice tx from B's revoked commitment/HTLC tx
17441744
mine_transaction(&nodes[0], &revoked_local_txn[0]);

lightning/src/ln/onion_route_tests.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2438,7 +2438,7 @@ fn test_phantom_onion_hmac_failure() {
24382438

24392439
nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &update_add);
24402440
commitment_signed_dance!(nodes[1], nodes[0], &update_0.commitment_signed, false, true);
2441-
expect_pending_htlcs_forwardable_conditions(nodes[1].node.get_and_clear_pending_events(), &[]);
2441+
expect_htlc_failure_conditions(nodes[1].node.get_and_clear_pending_events(), &[]);
24422442
nodes[1].node.process_pending_update_add_htlcs();
24432443

24442444
// Modify the payload so the phantom hop's HMAC is bogus.
@@ -2461,7 +2461,7 @@ fn test_phantom_onion_hmac_failure() {
24612461
}
24622462
};
24632463
nodes[1].node.process_pending_htlc_forwards();
2464-
expect_pending_htlcs_forwardable_conditions(
2464+
expect_htlc_failure_conditions(
24652465
nodes[1].node.get_and_clear_pending_events(),
24662466
&[HTLCHandlingFailureType::Receive { payment_hash }],
24672467
);
@@ -2511,7 +2511,7 @@ fn test_phantom_invalid_onion_payload() {
25112511

25122512
nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &update_add);
25132513
commitment_signed_dance!(nodes[1], nodes[0], &update_0.commitment_signed, false, true);
2514-
expect_pending_htlcs_forwardable_conditions(nodes[1].node.get_and_clear_pending_events(), &[]);
2514+
expect_htlc_failure_conditions(nodes[1].node.get_and_clear_pending_events(), &[]);
25152515
nodes[1].node.process_pending_update_add_htlcs();
25162516

25172517
// Modify the onion packet to have an invalid payment amount.
@@ -2562,7 +2562,7 @@ fn test_phantom_invalid_onion_payload() {
25622562
}
25632563
}
25642564
nodes[1].node.process_pending_htlc_forwards();
2565-
expect_pending_htlcs_forwardable_conditions(
2565+
expect_htlc_failure_conditions(
25662566
nodes[1].node.get_and_clear_pending_events(),
25672567
&[HTLCHandlingFailureType::Receive { payment_hash }],
25682568
);
@@ -2610,7 +2610,7 @@ fn test_phantom_final_incorrect_cltv_expiry() {
26102610

26112611
nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &update_add);
26122612
commitment_signed_dance!(nodes[1], nodes[0], &update_0.commitment_signed, false, true);
2613-
expect_pending_htlcs_forwardable_conditions(nodes[1].node.get_and_clear_pending_events(), &[]);
2613+
expect_htlc_failure_conditions(nodes[1].node.get_and_clear_pending_events(), &[]);
26142614
nodes[1].node.process_pending_update_add_htlcs();
26152615

26162616
// Modify the payload so the phantom hop's HMAC is bogus.
@@ -2628,7 +2628,7 @@ fn test_phantom_final_incorrect_cltv_expiry() {
26282628
}
26292629
}
26302630
nodes[1].node.process_pending_htlc_forwards();
2631-
expect_pending_htlcs_forwardable_conditions(
2631+
expect_htlc_failure_conditions(
26322632
nodes[1].node.get_and_clear_pending_events(),
26332633
&[HTLCHandlingFailureType::Receive { payment_hash }],
26342634
);
@@ -2680,9 +2680,9 @@ fn test_phantom_failure_too_low_cltv() {
26802680
nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &update_add);
26812681
commitment_signed_dance!(nodes[1], nodes[0], &update_0.commitment_signed, false, true);
26822682

2683-
expect_pending_htlcs_forwardable_conditions(nodes[1].node.get_and_clear_pending_events(), &[]);
2683+
expect_htlc_failure_conditions(nodes[1].node.get_and_clear_pending_events(), &[]);
26842684
nodes[1].node.process_pending_htlc_forwards();
2685-
expect_pending_htlcs_forwardable_conditions(
2685+
expect_htlc_failure_conditions(
26862686
nodes[1].node.get_and_clear_pending_events(),
26872687
&[HTLCHandlingFailureType::Receive { payment_hash }],
26882688
);
@@ -2838,11 +2838,11 @@ fn test_phantom_failure_too_low_recv_amt() {
28382838
nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &update_add);
28392839
commitment_signed_dance!(nodes[1], nodes[0], &update_0.commitment_signed, false, true);
28402840

2841-
expect_pending_htlcs_forwardable_conditions(nodes[1].node.get_and_clear_pending_events(), &[]);
2841+
expect_htlc_failure_conditions(nodes[1].node.get_and_clear_pending_events(), &[]);
28422842
nodes[1].node.process_pending_htlc_forwards();
2843-
expect_pending_htlcs_forwardable_conditions(nodes[1].node.get_and_clear_pending_events(), &[]);
2843+
expect_htlc_failure_conditions(nodes[1].node.get_and_clear_pending_events(), &[]);
28442844
nodes[1].node.process_pending_htlc_forwards();
2845-
expect_pending_htlcs_forwardable_conditions(
2845+
expect_htlc_failure_conditions(
28462846
nodes[1].node.get_and_clear_pending_events(),
28472847
&[HTLCHandlingFailureType::Receive { payment_hash: payment_hash.clone() }],
28482848
);
@@ -2958,9 +2958,9 @@ fn test_phantom_failure_reject_payment() {
29582958
nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &update_add);
29592959
commitment_signed_dance!(nodes[1], nodes[0], &update_0.commitment_signed, false, true);
29602960

2961-
expect_pending_htlcs_forwardable_conditions(nodes[1].node.get_and_clear_pending_events(), &[]);
2961+
expect_htlc_failure_conditions(nodes[1].node.get_and_clear_pending_events(), &[]);
29622962
nodes[1].node.process_pending_htlc_forwards();
2963-
expect_pending_htlcs_forwardable_conditions(nodes[1].node.get_and_clear_pending_events(), &[]);
2963+
expect_htlc_failure_conditions(nodes[1].node.get_and_clear_pending_events(), &[]);
29642964
nodes[1].node.process_pending_htlc_forwards();
29652965
expect_payment_claimable!(
29662966
nodes[1],
@@ -2971,7 +2971,7 @@ fn test_phantom_failure_reject_payment() {
29712971
route.paths[0].hops.last().unwrap().pubkey
29722972
);
29732973
nodes[1].node.fail_htlc_backwards(&payment_hash);
2974-
expect_pending_htlcs_forwardable_conditions(
2974+
expect_htlc_failure_conditions(
29752975
nodes[1].node.get_and_clear_pending_events(),
29762976
&[HTLCHandlingFailureType::Receive { payment_hash }],
29772977
);

0 commit comments

Comments
 (0)