Skip to content

Commit 919f984

Browse files
test_utils: add option of skipping initial claim to claim_payment
1 parent d8ee40c commit 919f984

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

lightning/src/ln/chanmon_update_fail_tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2051,7 +2051,7 @@ fn test_path_paused_mpp() {
20512051
assert_eq!(events.len(), 1);
20522052
pass_along_path(&nodes[0], &[&nodes[2], &nodes[3]], 200_000, payment_hash.clone(), Some(payment_secret), events.pop().unwrap(), true, None);
20532053

2054-
claim_payment_along_route(&nodes[0], &[&[&nodes[1], &nodes[3]], &[&nodes[2], &nodes[3]]], false, payment_preimage);
2054+
claim_payment_along_route(&nodes[0], &[&[&nodes[1], &nodes[3]], &[&nodes[2], &nodes[3]]], false, false, payment_preimage);
20552055
}
20562056

20572057
#[test]

lightning/src/ln/functional_test_utils.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1152,12 +1152,14 @@ pub fn send_along_route<'a, 'b, 'c>(origin_node: &Node<'a, 'b, 'c>, route: Route
11521152
(our_payment_preimage, our_payment_hash, our_payment_secret)
11531153
}
11541154

1155-
pub fn claim_payment_along_route<'a, 'b, 'c>(origin_node: &Node<'a, 'b, 'c>, expected_paths: &[&[&Node<'a, 'b, 'c>]], skip_last: bool, our_payment_preimage: PaymentPreimage) {
1155+
pub fn claim_payment_along_route<'a, 'b, 'c>(origin_node: &Node<'a, 'b, 'c>, expected_paths: &[&[&Node<'a, 'b, 'c>]], skip_last: bool, skip_initial_claim: bool, our_payment_preimage: PaymentPreimage) {
11561156
for path in expected_paths.iter() {
11571157
assert_eq!(path.last().unwrap().node.get_our_node_id(), expected_paths[0].last().unwrap().node.get_our_node_id());
11581158
}
1159-
assert!(expected_paths[0].last().unwrap().node.claim_funds(our_payment_preimage));
1160-
check_added_monitors!(expected_paths[0].last().unwrap(), expected_paths.len());
1159+
if !skip_initial_claim {
1160+
assert!(expected_paths[0].last().unwrap().node.claim_funds(our_payment_preimage));
1161+
check_added_monitors!(expected_paths[0].last().unwrap(), expected_paths.len());
1162+
}
11611163

11621164
macro_rules! msgs_from_ev {
11631165
($ev: expr) => {
@@ -1243,7 +1245,7 @@ pub fn claim_payment_along_route<'a, 'b, 'c>(origin_node: &Node<'a, 'b, 'c>, exp
12431245
}
12441246

12451247
pub fn claim_payment<'a, 'b, 'c>(origin_node: &Node<'a, 'b, 'c>, expected_route: &[&Node<'a, 'b, 'c>], our_payment_preimage: PaymentPreimage) {
1246-
claim_payment_along_route(origin_node, &[expected_route], false, our_payment_preimage);
1248+
claim_payment_along_route(origin_node, &[expected_route], false, false, our_payment_preimage);
12471249
}
12481250

12491251
pub const TEST_FINAL_CLTV: u32 = 70;

lightning/src/ln/functional_tests.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3307,7 +3307,7 @@ fn test_simple_peer_disconnect() {
33073307
nodes[0].node.peer_disconnected(&nodes[1].node.get_our_node_id(), false);
33083308
nodes[1].node.peer_disconnected(&nodes[0].node.get_our_node_id(), false);
33093309

3310-
claim_payment_along_route(&nodes[0], &[&[&nodes[1], &nodes[2]]], true, payment_preimage_3);
3310+
claim_payment_along_route(&nodes[0], &[&[&nodes[1], &nodes[2]]], true, false, payment_preimage_3);
33113311
fail_payment_along_route(&nodes[0], &[&nodes[1], &nodes[2]], true, payment_hash_5);
33123312

33133313
reconnect_nodes(&nodes[0], &nodes[1], (false, false), (0, 0), (0, 0), (0, 0), (1, 0), (1, 0), (false, false));
@@ -8121,7 +8121,7 @@ fn test_simple_mpp() {
81218121
route.paths[1][0].short_channel_id = chan_2_id;
81228122
route.paths[1][1].short_channel_id = chan_4_id;
81238123
send_along_route_with_secret(&nodes[0], route, &[&[&nodes[1], &nodes[3]], &[&nodes[2], &nodes[3]]], 200_000, payment_hash, payment_secret);
8124-
claim_payment_along_route(&nodes[0], &[&[&nodes[1], &nodes[3]], &[&nodes[2], &nodes[3]]], false, payment_preimage);
8124+
claim_payment_along_route(&nodes[0], &[&[&nodes[1], &nodes[3]], &[&nodes[2], &nodes[3]]], false, false, payment_preimage);
81258125
}
81268126

81278127
#[test]

0 commit comments

Comments
 (0)