@@ -1765,7 +1765,7 @@ fn during_funding_monitor_fail() {
1765
1765
1766
1766
#[ test]
1767
1767
fn test_path_paused_mpp ( ) {
1768
- // Simple test of sending a multi-path payment where one path is currently blocked awaiting
1768
+ // Simple test of sending a multi-part payment where one path is currently blocked awaiting
1769
1769
// monitor update
1770
1770
let chanmon_cfgs = create_chanmon_cfgs ( 4 ) ;
1771
1771
let node_cfgs = create_node_cfgs ( 4 , & chanmon_cfgs) ;
@@ -1780,6 +1780,8 @@ fn test_path_paused_mpp() {
1780
1780
let ( payment_preimage, payment_hash) = get_payment_preimage_hash ! ( & nodes[ 0 ] ) ;
1781
1781
let payment_secret = PaymentSecret ( [ 0xdb ; 32 ] ) ;
1782
1782
let mut route = nodes[ 0 ] . router . get_route ( & nodes[ 3 ] . node . get_our_node_id ( ) , None , & [ ] , 100000 , TEST_FINAL_CLTV ) . unwrap ( ) ;
1783
+
1784
+ // Set us up to take multiple routes, one 0 -> 1 -> 3 and one 0 -> 2 -> 3:
1783
1785
let path = route. paths [ 0 ] . clone ( ) ;
1784
1786
route. paths . push ( path) ;
1785
1787
route. paths [ 0 ] [ 0 ] . pubkey = nodes[ 1 ] . node . get_our_node_id ( ) ;
@@ -1789,21 +1791,29 @@ fn test_path_paused_mpp() {
1789
1791
route. paths [ 1 ] [ 0 ] . short_channel_id = chan_2_ann. contents . short_channel_id ;
1790
1792
route. paths [ 1 ] [ 1 ] . short_channel_id = chan_4_id;
1791
1793
1794
+ // Set it so that the first monitor update (for the path 0 -> 1 -> 3) succeeds, but the second
1795
+ // (for the path 0 -> 2 -> 3) fails.
1792
1796
* nodes[ 0 ] . chan_monitor . update_ret . lock ( ) . unwrap ( ) = Ok ( ( ) ) ;
1793
1797
* nodes[ 0 ] . chan_monitor . next_update_ret . lock ( ) . unwrap ( ) = Some ( Err ( ChannelMonitorUpdateErr :: TemporaryFailure ) ) ;
1794
1798
1795
- if let Err ( PaymentSendFailure :: PartialFailure ( fails) ) = nodes[ 0 ] . node . send_payment ( & route, payment_hash, & Some ( payment_secret) ) {
1796
- assert_eq ! ( fails. len( ) , 2 ) ;
1797
- if let Ok ( ( ) ) = fails[ 0 ] { } else { panic ! ( ) ; }
1798
- if let Err ( APIError :: MonitorUpdateFailed ) = fails[ 1 ] { } else { panic ! ( ) ; }
1799
+ // Now check that we get the right return value, indicating that the first path succeeded but
1800
+ // the second got a MonitorUpdateFailed err. This implies PaymentSendFailure::PartialFailure as
1801
+ // some paths succeeded, preventing retry.
1802
+ if let Err ( PaymentSendFailure :: PartialFailure ( results) ) = nodes[ 0 ] . node . send_payment ( & route, payment_hash, & Some ( payment_secret) ) {
1803
+ assert_eq ! ( results. len( ) , 2 ) ;
1804
+ if let Ok ( ( ) ) = results[ 0 ] { } else { panic ! ( ) ; }
1805
+ if let Err ( APIError :: MonitorUpdateFailed ) = results[ 1 ] { } else { panic ! ( ) ; }
1799
1806
} else { panic ! ( ) ; }
1800
1807
check_added_monitors ! ( nodes[ 0 ] , 2 ) ;
1801
1808
* nodes[ 0 ] . chan_monitor . update_ret . lock ( ) . unwrap ( ) = Ok ( ( ) ) ;
1802
1809
1810
+ // Pass the first HTLC of the payment along to nodes[3].
1803
1811
let mut events = nodes[ 0 ] . node . get_and_clear_pending_msg_events ( ) ;
1804
1812
assert_eq ! ( events. len( ) , 1 ) ;
1805
1813
pass_along_path ( & nodes[ 0 ] , & [ & nodes[ 1 ] , & nodes[ 3 ] ] , 0 , payment_hash. clone ( ) , Some ( payment_secret) , events. pop ( ) . unwrap ( ) , false ) ;
1806
1814
1815
+ // And check that, after we successfully update the monitor for chan_2 we can pass the second
1816
+ // HTLC along to nodes[3] and claim the whole payment back to nodes[0].
1807
1817
let ( outpoint, latest_update) = nodes[ 0 ] . chan_monitor . latest_monitor_update_id . lock ( ) . unwrap ( ) . get ( & chan_2_id) . unwrap ( ) . clone ( ) ;
1808
1818
nodes[ 0 ] . node . channel_monitor_updated ( & outpoint, latest_update) ;
1809
1819
let mut events = nodes[ 0 ] . node . get_and_clear_pending_msg_events ( ) ;
0 commit comments