@@ -56,6 +56,8 @@ use sync::{Arc, Mutex};
56
56
use ln::functional_test_utils::*;
57
57
use ln::chan_utils::CommitmentTransaction;
58
58
59
+ use crate::ln::channelmanager::MPP_TIMEOUT_TICKS;
60
+
59
61
#[test]
60
62
fn test_insane_channel_opens() {
61
63
// Stand up a network of 2 nodes
@@ -9913,3 +9915,46 @@ fn test_max_dust_htlc_exposure() {
9913
9915
do_test_max_dust_htlc_exposure(false, ExposureEvent::AtUpdateFeeOutbound, false);
9914
9916
do_test_max_dust_htlc_exposure(false, ExposureEvent::AtUpdateFeeOutbound, true);
9915
9917
}
9918
+
9919
+ #[test]
9920
+ fn test_mpp_receive_timeout() {
9921
+ let chanmon_cfgs = create_chanmon_cfgs(2);
9922
+ let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
9923
+ let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]);
9924
+ let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
9925
+
9926
+ let chan_id = create_announced_chan_between_nodes(&nodes, 0, 1, InitFeatures::known(), InitFeatures::known()).0.contents.short_channel_id;
9927
+
9928
+ let (mut route, payment_hash, _payment_preimage, payment_secret) = get_route_and_payment_hash!(&nodes[0], nodes[1], 100000);
9929
+ let path = route.paths[0].clone();
9930
+ route.paths.push(path);
9931
+ route.paths[0][0].pubkey = nodes[1].node.get_our_node_id();
9932
+ route.paths[0][0].short_channel_id = chan_id;
9933
+
9934
+ let cur_height = CHAN_CONFIRM_DEPTH + 1; // route_payment calls send_payment, which adds 1 to the current height. So we do the same here to match.
9935
+ let payment_id = PaymentId([42; 32]);
9936
+
9937
+ nodes[0].node.send_payment_along_path(&route.paths[0], &route.payment_params, &payment_hash, &Some(payment_secret), 200000, cur_height, payment_id, &None).unwrap();
9938
+ check_added_monitors!(nodes[0], 1);
9939
+ let mut events = nodes[0].node.get_and_clear_pending_msg_events();
9940
+ assert_eq!(events.len(), 1);
9941
+
9942
+ // Now do the relevant commitment_signed/RAA dances along the path, noting that the final
9943
+ // hop should *not* yet generate any PaymentReceived event(s).
9944
+ pass_along_path(&nodes[0], &[&nodes[1]], 100000, payment_hash, Some(payment_secret), events.drain(..).next().unwrap(), false, None);
9945
+
9946
+ for _ in 0..MPP_TIMEOUT_TICKS {
9947
+ nodes[1].node.timer_tick_occurred();
9948
+ }
9949
+
9950
+ expect_pending_htlcs_forwardable!(nodes[1]);
9951
+
9952
+ let htlc_fail_updates = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id());
9953
+ assert_eq!(htlc_fail_updates.update_fail_htlcs.len(), 1);
9954
+
9955
+ nodes[0].node.handle_update_fail_htlc(&nodes[1].node.get_our_node_id(), &htlc_fail_updates.update_fail_htlcs[0]);
9956
+ check_added_monitors!(nodes[1], 1);
9957
+
9958
+ commitment_signed_dance!(nodes[0], nodes[1], htlc_fail_updates.commitment_signed, true, true);
9959
+ expect_payment_failed!(nodes[0], payment_hash, false, 23, &[][..]);
9960
+ }
0 commit comments