@@ -4084,6 +4084,34 @@ fn test_no_txn_manager_serialize_deserialize() {
40844084 send_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] ] , 1000000 ) ;
40854085}
40864086
4087+ #[ test]
4088+ fn mpp_failure ( ) {
4089+ let chanmon_cfgs = create_chanmon_cfgs ( 4 ) ;
4090+ let node_cfgs = create_node_cfgs ( 4 , & chanmon_cfgs) ;
4091+ let node_chanmgrs = create_node_chanmgrs ( 4 , & node_cfgs, & [ None , None , None , None ] ) ;
4092+ let nodes = create_network ( 4 , & node_cfgs, & node_chanmgrs) ;
4093+
4094+ let chan_1_id = create_announced_chan_between_nodes ( & nodes, 0 , 1 , InitFeatures :: known ( ) , InitFeatures :: known ( ) ) . 0 . contents . short_channel_id ;
4095+ let chan_2_id = create_announced_chan_between_nodes ( & nodes, 0 , 2 , InitFeatures :: known ( ) , InitFeatures :: known ( ) ) . 0 . contents . short_channel_id ;
4096+ let chan_3_id = create_announced_chan_between_nodes ( & nodes, 1 , 3 , InitFeatures :: known ( ) , InitFeatures :: known ( ) ) . 0 . contents . short_channel_id ;
4097+ let chan_4_id = create_announced_chan_between_nodes ( & nodes, 2 , 3 , InitFeatures :: known ( ) , InitFeatures :: known ( ) ) . 0 . contents . short_channel_id ;
4098+ let logger = test_utils:: TestLogger :: new ( ) ;
4099+
4100+ let ( _, payment_hash, payment_secret) = get_payment_preimage_hash ! ( & nodes[ 3 ] ) ;
4101+ let net_graph_msg_handler = & nodes[ 0 ] . net_graph_msg_handler ;
4102+ let mut route = get_route ( & nodes[ 0 ] . node . get_our_node_id ( ) , & net_graph_msg_handler. network_graph , & nodes[ 3 ] . node . get_our_node_id ( ) , Some ( InvoiceFeatures :: known ( ) ) , None , & [ ] , 100000 , TEST_FINAL_CLTV , & logger) . unwrap ( ) ;
4103+ let path = route. paths [ 0 ] . clone ( ) ;
4104+ route. paths . push ( path) ;
4105+ route. paths [ 0 ] [ 0 ] . pubkey = nodes[ 1 ] . node . get_our_node_id ( ) ;
4106+ route. paths [ 0 ] [ 0 ] . short_channel_id = chan_1_id;
4107+ route. paths [ 0 ] [ 1 ] . short_channel_id = chan_3_id;
4108+ route. paths [ 1 ] [ 0 ] . pubkey = nodes[ 2 ] . node . get_our_node_id ( ) ;
4109+ route. paths [ 1 ] [ 0 ] . short_channel_id = chan_2_id;
4110+ route. paths [ 1 ] [ 1 ] . short_channel_id = chan_4_id;
4111+ send_along_route_with_secret ( & nodes[ 0 ] , route, & [ & [ & nodes[ 1 ] , & nodes[ 3 ] ] , & [ & nodes[ 2 ] , & nodes[ 3 ] ] ] , 200_000 , payment_hash, payment_secret) ;
4112+ fail_payment_along_route ( & nodes[ 0 ] , & [ & [ & nodes[ 1 ] , & nodes[ 3 ] ] , & [ & nodes[ 2 ] , & nodes[ 3 ] ] ] , false , payment_hash) ;
4113+ }
4114+
40874115#[ test]
40884116fn test_dup_htlc_onchain_fails_on_reload ( ) {
40894117 // When a Channel is closed, any outbound HTLCs which were relayed through it are simply
@@ -5914,9 +5942,10 @@ fn test_fail_holding_cell_htlc_upon_free() {
59145942 let events = nodes[ 0 ] . node . get_and_clear_pending_events ( ) ;
59155943 assert_eq ! ( events. len( ) , 1 ) ;
59165944 match & events[ 0 ] {
5917- & Event :: PaymentFailed { ref payment_hash, ref rejected_by_dest, ref network_update, ref error_code, ref error_data } => {
5945+ & Event :: PaymentFailed { ref payment_hash, ref rejected_by_dest, ref network_update, ref error_code, ref error_data, ref all_paths_failed } => {
59185946 assert_eq ! ( our_payment_hash. clone( ) , * payment_hash) ;
59195947 assert_eq ! ( * rejected_by_dest, false ) ;
5948+ assert_eq ! ( * all_paths_failed, true ) ;
59205949 assert_eq ! ( * network_update, None ) ;
59215950 assert_eq ! ( * error_code, None ) ;
59225951 assert_eq ! ( * error_data, None ) ;
@@ -6000,9 +6029,10 @@ fn test_free_and_fail_holding_cell_htlcs() {
60006029 let events = nodes[ 0 ] . node . get_and_clear_pending_events ( ) ;
60016030 assert_eq ! ( events. len( ) , 1 ) ;
60026031 match & events[ 0 ] {
6003- & Event :: PaymentFailed { ref payment_hash, ref rejected_by_dest, ref network_update, ref error_code, ref error_data } => {
6032+ & Event :: PaymentFailed { ref payment_hash, ref rejected_by_dest, ref network_update, ref error_code, ref error_data, ref all_paths_failed } => {
60046033 assert_eq ! ( payment_hash_2. clone( ) , * payment_hash) ;
60056034 assert_eq ! ( * rejected_by_dest, false ) ;
6035+ assert_eq ! ( * all_paths_failed, true ) ;
60066036 assert_eq ! ( * network_update, None ) ;
60076037 assert_eq ! ( * error_code, None ) ;
60086038 assert_eq ! ( * error_data, None ) ;
0 commit comments