Skip to content

Commit 6c7a6aa

Browse files
test utils: add optional PaymentPreimage param to pass_along_path
This will allow keysend tests to assert that the PaymentReceived payment preimage is as expected in upcoming commits.
1 parent 740e522 commit 6c7a6aa

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

lightning/src/ln/chanmon_update_fail_tests.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1972,15 +1972,15 @@ fn test_path_paused_mpp() {
19721972
// Pass the first HTLC of the payment along to nodes[3].
19731973
let mut events = nodes[0].node.get_and_clear_pending_msg_events();
19741974
assert_eq!(events.len(), 1);
1975-
pass_along_path(&nodes[0], &[&nodes[1], &nodes[3]], 0, payment_hash.clone(), payment_secret, events.pop().unwrap(), false);
1975+
pass_along_path(&nodes[0], &[&nodes[1], &nodes[3]], 0, payment_hash.clone(), payment_secret, events.pop().unwrap(), false, None);
19761976

19771977
// And check that, after we successfully update the monitor for chan_2 we can pass the second
19781978
// HTLC along to nodes[3] and claim the whole payment back to nodes[0].
19791979
let (outpoint, latest_update) = nodes[0].chain_monitor.latest_monitor_update_id.lock().unwrap().get(&chan_2_id).unwrap().clone();
19801980
nodes[0].node.channel_monitor_updated(&outpoint, latest_update);
19811981
let mut events = nodes[0].node.get_and_clear_pending_msg_events();
19821982
assert_eq!(events.len(), 1);
1983-
pass_along_path(&nodes[0], &[&nodes[2], &nodes[3]], 200_000, payment_hash.clone(), payment_secret, events.pop().unwrap(), true);
1983+
pass_along_path(&nodes[0], &[&nodes[2], &nodes[3]], 200_000, payment_hash.clone(), payment_secret, events.pop().unwrap(), true, None);
19841984

19851985
claim_payment_along_route(&nodes[0], &[&[&nodes[1], &nodes[3]], &[&nodes[2], &nodes[3]]], false, payment_preimage);
19861986
}

lightning/src/ln/functional_test_utils.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1024,7 +1024,7 @@ pub fn send_along_route_with_secret<'a, 'b, 'c>(origin_node: &Node<'a, 'b, 'c>,
10241024
pass_along_route(origin_node, expected_paths, recv_value, our_payment_hash, our_payment_secret);
10251025
}
10261026

1027-
pub fn pass_along_path<'a, 'b, 'c>(origin_node: &Node<'a, 'b, 'c>, expected_path: &[&Node<'a, 'b, 'c>], recv_value: u64, our_payment_hash: PaymentHash, our_payment_secret: PaymentSecret, ev: MessageSendEvent, payment_received_expected: bool) {
1027+
pub fn pass_along_path<'a, 'b, 'c>(origin_node: &Node<'a, 'b, 'c>, expected_path: &[&Node<'a, 'b, 'c>], recv_value: u64, our_payment_hash: PaymentHash, our_payment_secret: PaymentSecret, ev: MessageSendEvent, payment_received_expected: bool, expected_preimage: Option<PaymentPreimage>) {
10281028
let mut payment_event = SendEvent::from_event(ev);
10291029
let mut prev_node = origin_node;
10301030

@@ -1044,7 +1044,7 @@ pub fn pass_along_path<'a, 'b, 'c>(origin_node: &Node<'a, 'b, 'c>, expected_path
10441044
match events_2[0] {
10451045
Event::PaymentReceived { ref payment_hash, ref payment_preimage, ref payment_secret, amt, user_payment_id: _ } => {
10461046
assert_eq!(our_payment_hash, *payment_hash);
1047-
assert!(payment_preimage.is_none());
1047+
assert_eq!(expected_preimage, *payment_preimage);
10481048
assert_eq!(our_payment_secret, *payment_secret);
10491049
assert_eq!(amt, recv_value);
10501050
},
@@ -1072,7 +1072,7 @@ pub fn pass_along_route<'a, 'b, 'c>(origin_node: &Node<'a, 'b, 'c>, expected_rou
10721072
// Once we've gotten through all the HTLCs, the last one should result in a
10731073
// PaymentReceived (but each previous one should not!), .
10741074
let expect_payment = path_idx == expected_route.len() - 1;
1075-
pass_along_path(origin_node, expected_path, recv_value, our_payment_hash.clone(), our_payment_secret, ev, expect_payment);
1075+
pass_along_path(origin_node, expected_path, recv_value, our_payment_hash.clone(), our_payment_secret, ev, expect_payment, None);
10761076
}
10771077
}
10781078

lightning/src/ln/functional_tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4137,7 +4137,7 @@ fn do_test_htlc_timeout(send_partial_mpp: bool) {
41374137
assert_eq!(events.len(), 1);
41384138
// Now do the relevant commitment_signed/RAA dances along the path, noting that the final
41394139
// hop should *not* yet generate any PaymentReceived event(s).
4140-
pass_along_path(&nodes[0], &[&nodes[1]], 100000, our_payment_hash, payment_secret, events.drain(..).next().unwrap(), false);
4140+
pass_along_path(&nodes[0], &[&nodes[1]], 100000, our_payment_hash, payment_secret, events.drain(..).next().unwrap(), false, None);
41414141
our_payment_hash
41424142
} else {
41434143
route_payment(&nodes[0], &[&nodes[1]], 100000).1

0 commit comments

Comments
 (0)