Skip to content

Commit 2bc0d31

Browse files
committed
f Rename expect_pending_htlcs_forwardable_conditions
1 parent cc3c3ee commit 2bc0d31

File tree

9 files changed

+47
-62
lines changed

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
@@ -1081,7 +1081,7 @@ fn invalid_async_receive_with_retry<F1, F2>(
10811081
// Fail the HTLC backwards to enable us to more easily modify the now-Retryable outbound to test
10821082
// failures on the recipient's end.
10831083
nodes[2].node.fail_htlc_backwards(&payment_hash);
1084-
expect_pending_htlcs_forwardable_conditions(
1084+
expect_htlc_failure_conditions(
10851085
nodes[2].node.get_and_clear_pending_events(),
10861086
&[HTLCHandlingFailureType::Receive { payment_hash }],
10871087
);

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
@@ -1859,7 +1859,7 @@ fn test_monitor_update_fail_claim() {
18591859
let events = nodes[1].node.get_and_clear_pending_msg_events();
18601860
assert_eq!(events.len(), 0);
18611861
commitment_signed_dance!(nodes[1], nodes[2], payment_event.commitment_msg, false, true);
1862-
expect_pending_htlcs_forwardable_conditions(nodes[1].node.get_and_clear_pending_events(), &[]);
1862+
expect_htlc_failure_conditions(nodes[1].node.get_and_clear_pending_events(), &[]);
18631863

18641864
let (_, payment_hash_3, payment_secret_3) = get_payment_preimage_hash!(nodes[0]);
18651865
let id_3 = PaymentId(payment_hash_3.0);
@@ -2949,10 +2949,7 @@ fn do_test_reconnect_dup_htlc_claims(htlc_status: HTLCStatusAtDupClaim, second_f
29492949
if htlc_status == HTLCStatusAtDupClaim::HoldingCell {
29502950
nodes[1].node.handle_revoke_and_ack(node_a_id, &as_raa.unwrap());
29512951
check_added_monitors!(nodes[1], 1);
2952-
expect_pending_htlcs_forwardable_conditions(
2953-
nodes[1].node.get_and_clear_pending_events(),
2954-
&[],
2955-
); // We finally receive the second payment, but don't claim it
2952+
expect_htlc_failure_conditions(nodes[1].node.get_and_clear_pending_events(), &[]); // We finally receive the second payment, but don't claim it
29562953

29572954
bs_updates = Some(get_htlc_update_msgs!(nodes[1], node_a_id));
29582955
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
@@ -2376,7 +2376,7 @@ macro_rules! expect_htlc_handling_failed_destinations {
23762376
/// Checks that an [`Event::PendingHTLCsForwardable`] is available in the given events and, if
23772377
/// there are any [`Event::HTLCHandlingFailed`] events their [`HTLCHandlingFailureType`] is included in the
23782378
/// `expected_failures` set.
2379-
pub fn expect_pending_htlcs_forwardable_conditions(
2379+
pub fn expect_htlc_failure_conditions(
23802380
events: Vec<Event>, expected_failures: &[HTLCHandlingFailureType],
23812381
) {
23822382
assert_eq!(events.len(), expected_failures.len());
@@ -2389,7 +2389,7 @@ pub fn expect_pending_htlcs_forwardable_conditions(
23892389
/// Handles a PendingHTLCsForwardable and HTLCHandlingFailed event
23902390
macro_rules! process_htlcs_and_expect_htlc_handling_failed {
23912391
($node: expr, $expected_failures: expr) => {{
2392-
$crate::ln::functional_test_utils::expect_pending_htlcs_forwardable_conditions(
2392+
$crate::ln::functional_test_utils::expect_htlc_failure_conditions(
23932393
$node.node.get_and_clear_pending_events(),
23942394
&$expected_failures,
23952395
);

lightning/src/ln/functional_tests.rs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6898,7 +6898,7 @@ pub fn test_bump_penalty_txn_on_revoked_htlcs() {
68986898
);
68996899
connect_block(&nodes[0], &block_129);
69006900
let events = nodes[0].node.get_and_clear_pending_events();
6901-
expect_pending_htlcs_forwardable_conditions(
6901+
expect_htlc_failure_conditions(
69026902
events[0..1].to_vec(),
69036903
&[HTLCHandlingFailureType::Receive { payment_hash: failed_payment_hash }],
69046904
);
@@ -7209,7 +7209,7 @@ pub fn test_bump_txn_sanitize_tracking_maps() {
72097209

72107210
// Broadcast set of revoked txn on A
72117211
connect_blocks(&nodes[0], TEST_FINAL_CLTV + 2 - CHAN_CONFIRM_DEPTH);
7212-
expect_pending_htlcs_forwardable_conditions(
7212+
expect_htlc_failure_conditions(
72137213
nodes[0].node.get_and_clear_pending_events(),
72147214
&[HTLCHandlingFailureType::Receive { payment_hash: payment_hash_2 }],
72157215
);
@@ -9497,7 +9497,7 @@ fn do_test_dup_htlc_second_rejected(test_for_second_fail_panic: bool) {
94979497
// the first HTLC delivered above.
94989498
}
94999499

9500-
expect_pending_htlcs_forwardable_conditions(nodes[1].node.get_and_clear_pending_events(), &[]);
9500+
expect_htlc_failure_conditions(nodes[1].node.get_and_clear_pending_events(), &[]);
95019501
nodes[1].node.process_pending_htlc_forwards();
95029502

95039503
if test_for_second_fail_panic {
@@ -9508,7 +9508,7 @@ fn do_test_dup_htlc_second_rejected(test_for_second_fail_panic: bool) {
95089508
HTLCHandlingFailureType::Receive { payment_hash: our_payment_hash },
95099509
HTLCHandlingFailureType::Receive { payment_hash: our_payment_hash },
95109510
];
9511-
expect_pending_htlcs_forwardable_conditions(
9511+
expect_htlc_failure_conditions(
95129512
nodes[1].node.get_and_clear_pending_events(),
95139513
expected_destinations,
95149514
);
@@ -9542,7 +9542,7 @@ fn do_test_dup_htlc_second_rejected(test_for_second_fail_panic: bool) {
95429542
}
95439543
} else {
95449544
// Let the second HTLC fail and claim the first
9545-
expect_pending_htlcs_forwardable_conditions(
9545+
expect_htlc_failure_conditions(
95469546
nodes[1].node.get_and_clear_pending_events(),
95479547
&[HTLCHandlingFailureType::Receive { payment_hash: our_payment_hash }],
95489548
);
@@ -9672,13 +9672,10 @@ pub fn test_inconsistent_mpp_params() {
96729672
// amount. It will assume the second is a privacy attack (no longer particularly relevant
96739673
// post-payment_secrets) and fail back the new HTLC.
96749674
}
9675-
expect_pending_htlcs_forwardable_conditions(nodes[3].node.get_and_clear_pending_events(), &[]);
9675+
expect_htlc_failure_conditions(nodes[3].node.get_and_clear_pending_events(), &[]);
96769676
nodes[3].node.process_pending_htlc_forwards();
96779677
let fail_type = HTLCHandlingFailureType::Receive { payment_hash: hash };
9678-
expect_pending_htlcs_forwardable_conditions(
9679-
nodes[3].node.get_and_clear_pending_events(),
9680-
&[fail_type],
9681-
);
9678+
expect_htlc_failure_conditions(nodes[3].node.get_and_clear_pending_events(), &[fail_type]);
96829679
nodes[3].node.process_pending_htlc_forwards();
96839680

96849681
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
@@ -1182,7 +1182,7 @@ fn test_no_preimage_inbound_htlc_balances() {
11821182
let as_htlc_timeout_claim = nodes[0].tx_broadcaster.txn_broadcasted.lock().unwrap().split_off(0);
11831183
assert_eq!(as_htlc_timeout_claim.len(), 1);
11841184
check_spends!(as_htlc_timeout_claim[0], as_txn[0]);
1185-
expect_pending_htlcs_forwardable_conditions(nodes[0].node.get_and_clear_pending_events(), &[HTLCHandlingFailureType::Receive { payment_hash: to_a_failed_payment_hash }]);
1185+
expect_htlc_failure_conditions(nodes[0].node.get_and_clear_pending_events(), &[HTLCHandlingFailureType::Receive { payment_hash: to_a_failed_payment_hash }]);
11861186
nodes[0].node.process_pending_htlc_forwards();
11871187

11881188
assert_eq!(as_pre_spend_claims,
@@ -1200,7 +1200,7 @@ fn test_no_preimage_inbound_htlc_balances() {
12001200
// The next few blocks for B look the same as for A, though for the opposite HTLC
12011201
nodes[1].tx_broadcaster.txn_broadcasted.lock().unwrap().clear();
12021202
connect_blocks(&nodes[1], TEST_FINAL_CLTV - (ANTI_REORG_DELAY - 1));
1203-
expect_pending_htlcs_forwardable_conditions(nodes[1].node.get_and_clear_pending_events(), &[HTLCHandlingFailureType::Receive { payment_hash: to_b_failed_payment_hash }]);
1203+
expect_htlc_failure_conditions(nodes[1].node.get_and_clear_pending_events(), &[HTLCHandlingFailureType::Receive { payment_hash: to_b_failed_payment_hash }]);
12041204
nodes[1].node.process_pending_htlc_forwards();
12051205
let bs_htlc_timeout_claim = nodes[1].tx_broadcaster.txn_broadcasted.lock().unwrap().split_off(0);
12061206
assert_eq!(bs_htlc_timeout_claim.len(), 1);
@@ -1683,7 +1683,7 @@ fn do_test_revoked_counterparty_htlc_tx_balances(anchors: bool) {
16831683
// `COUNTERPARTY_CLAIMABLE_WITHIN_BLOCKS_PINNABLE` blocks, making us consider all the HTLCs
16841684
// pinnable claims, which the remainder of the test assumes.
16851685
connect_blocks(&nodes[0], TEST_FINAL_CLTV - COUNTERPARTY_CLAIMABLE_WITHIN_BLOCKS_PINNABLE);
1686-
expect_pending_htlcs_forwardable_conditions(nodes[0].node.get_and_clear_pending_events(),
1686+
expect_htlc_failure_conditions(nodes[0].node.get_and_clear_pending_events(),
16871687
&[HTLCHandlingFailureType::Receive { payment_hash: failed_payment_hash }]);
16881688
// A will generate justice tx from B's revoked commitment/HTLC tx
16891689
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)