Skip to content

Commit 5acde17

Browse files
committed
f rebase on new test dry'ing
1 parent fdc4fa3 commit 5acde17

File tree

2 files changed

+10
-18
lines changed

2 files changed

+10
-18
lines changed

lightning/src/ln/functional_test_utils.rs

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1211,6 +1211,7 @@ pub struct PaymentFailedConditions<'a> {
12111211
pub(crate) expected_htlc_error_data: Option<(u16, &'a [u8])>,
12121212
pub(crate) expected_blamed_scid: Option<u64>,
12131213
pub(crate) expected_blamed_chan_closed: Option<bool>,
1214+
pub(crate) expected_mpp_parts_remain: bool,
12141215
}
12151216

12161217
impl<'a> PaymentFailedConditions<'a> {
@@ -1219,8 +1220,13 @@ impl<'a> PaymentFailedConditions<'a> {
12191220
expected_htlc_error_data: None,
12201221
expected_blamed_scid: None,
12211222
expected_blamed_chan_closed: None,
1223+
expected_mpp_parts_remain: false,
12221224
}
12231225
}
1226+
pub fn mpp_parts_remain(mut self) -> Self {
1227+
self.expected_mpp_parts_remain = true;
1228+
self
1229+
}
12241230
pub fn blamed_scid(mut self, scid: u64) -> Self {
12251231
self.expected_blamed_scid = Some(scid);
12261232
self
@@ -1246,9 +1252,7 @@ macro_rules! expect_payment_failed_with_update {
12461252
#[cfg(test)]
12471253
macro_rules! expect_payment_failed {
12481254
($node: expr, $expected_payment_hash: expr, $rejected_by_dest: expr $(, $expected_error_code: expr, $expected_error_data: expr)*) => {
1249-
expect_payment_failed!($node, $expected_payment_hash, $rejected_by_dest, false $(, $expected_error_code, $expected_error_data)*);
1250-
};
1251-
($node: expr, $expected_payment_hash: expr, $rejected_by_dest: expr, $mpp_parts_remain: expr $(, $expected_error_code: expr, $expected_error_data: expr)*) => {
1255+
#[allow(unused_mut)]
12521256
let mut conditions = $crate::ln::functional_test_utils::PaymentFailedConditions::new();
12531257
$(
12541258
conditions = conditions.expected_htlc_error_data($expected_error_code, &$expected_error_data);
@@ -1312,18 +1316,6 @@ macro_rules! expect_payment_failed_conditions {
13121316
_ => panic!("Unexpected second event"),
13131317
}
13141318
}
1315-
if !$mpp_parts_remain {
1316-
$node.node.no_further_payment_retries(our_payment_id);
1317-
let events = $node.node.get_and_clear_pending_events();
1318-
assert_eq!(events.len(), 1);
1319-
match events[0] {
1320-
Event::PaymentFailed { ref payment_hash, ref payment_id } => {
1321-
assert_eq!(*payment_hash, $expected_payment_hash, "unexpected second payment_hash");
1322-
assert_eq!(*payment_id, our_payment_id);
1323-
}
1324-
_ => panic!("Unexpected second event"),
1325-
}
1326-
}
13271319
}
13281320
}
13291321

lightning/src/ln/payment_tests.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ fn retry_single_path_payment() {
6767
check_added_monitors!(nodes[1], 1);
6868
nodes[0].node.handle_update_fail_htlc(&nodes[1].node.get_our_node_id(), &htlc_updates.update_fail_htlcs[0]);
6969
commitment_signed_dance!(nodes[0], nodes[1], htlc_updates.commitment_signed, false);
70-
expect_payment_failed!(nodes[0], payment_hash, false, true);
70+
expect_payment_failed_conditions!(nodes[0], payment_hash, false, PaymentFailedConditions::new().mpp_parts_remain());
7171

7272
// Rebalance the channel so the retry succeeds.
7373
send_payment(&nodes[2], &vec!(&nodes[1])[..], 3_000_000);
@@ -170,7 +170,7 @@ fn mpp_retry() {
170170
check_added_monitors!(nodes[2], 1);
171171
nodes[0].node.handle_update_fail_htlc(&nodes[2].node.get_our_node_id(), &htlc_updates.update_fail_htlcs[0]);
172172
commitment_signed_dance!(nodes[0], nodes[2], htlc_updates.commitment_signed, false);
173-
expect_payment_failed!(nodes[0], payment_hash, false, true);
173+
expect_payment_failed_conditions!(nodes[0], payment_hash, false, PaymentFailedConditions::new().mpp_parts_remain());
174174

175175
// Rebalance the channel so the second half of the payment can succeed.
176176
send_payment(&nodes[3], &vec!(&nodes[2])[..], 1_500_000);
@@ -437,7 +437,7 @@ fn do_retry_with_no_persist(confirm_before_reload: bool) {
437437
confirm_transaction(&nodes[0], &as_htlc_timeout_txn[0]);
438438
}
439439
nodes[0].tx_broadcaster.txn_broadcasted.lock().unwrap().clear();
440-
expect_payment_failed!(nodes[0], payment_hash, false, true);
440+
expect_payment_failed_conditions!(nodes[0], payment_hash, false, PaymentFailedConditions::new().mpp_parts_remain());
441441

442442
// Finally, retry the payment (which was reloaded from the ChannelMonitor when nodes[0] was
443443
// reloaded) via a route over the new channel, which work without issue and eventually be

0 commit comments

Comments
 (0)