@@ -3224,12 +3224,13 @@ pub fn expect_probe_successful_events(
32243224}
32253225
32263226pub struct PaymentFailedConditions < ' a > {
3227- pub ( crate ) expected_htlc_error_data : Option < ( LocalHTLCFailureReason , & ' a [ u8 ] ) > ,
3228- pub ( crate ) expected_blamed_scid : Option < u64 > ,
3229- pub ( crate ) expected_blamed_chan_closed : Option < bool > ,
3230- pub ( crate ) expected_mpp_parts_remain : bool ,
3231- pub ( crate ) retry_expected : bool ,
3232- pub ( crate ) from_mon_update : bool ,
3227+ pub expected_htlc_error_data : Option < ( LocalHTLCFailureReason , & ' a [ u8 ] ) > ,
3228+ pub expected_blamed_scid : Option < u64 > ,
3229+ pub expected_blamed_chan_closed : Option < bool > ,
3230+ pub expected_mpp_parts_remain : bool ,
3231+ pub retry_expected : bool ,
3232+ pub from_mon_update : bool ,
3233+ pub reason : Option < PaymentFailureReason > ,
32333234}
32343235
32353236impl < ' a > PaymentFailedConditions < ' a > {
@@ -3241,6 +3242,7 @@ impl<'a> PaymentFailedConditions<'a> {
32413242 expected_mpp_parts_remain : false ,
32423243 retry_expected : false ,
32433244 from_mon_update : false ,
3245+ reason : None ,
32443246 }
32453247 }
32463248 pub fn mpp_parts_remain ( mut self ) -> Self {
@@ -3321,14 +3323,21 @@ pub fn expect_payment_failed_conditions_event<'a, 'b, 'c, 'd, 'e>(
33213323 * payment_failed_permanently, expected_payment_failed_permanently,
33223324 "unexpected payment_failed_permanently value"
33233325 ) ;
3324- {
3325- assert ! ( error_code. is_some( ) , "expected error_code.is_some() = true" ) ;
3326- assert ! ( error_data. is_some( ) , "expected error_data.is_some() = true" ) ;
3327- let reason: LocalHTLCFailureReason = error_code. unwrap ( ) . into ( ) ;
3328- if let Some ( ( code, data) ) = conditions. expected_htlc_error_data {
3329- assert_eq ! ( reason, code, "unexpected error code" ) ;
3330- assert_eq ! ( & error_data. as_ref( ) . unwrap( ) [ ..] , data, "unexpected error data" ) ;
3331- }
3326+ match failure {
3327+ PathFailure :: OnPath { .. } => {
3328+ assert ! ( error_code. is_some( ) , "expected error_code.is_some() = true" ) ;
3329+ assert ! ( error_data. is_some( ) , "expected error_data.is_some() = true" ) ;
3330+ let reason: LocalHTLCFailureReason = error_code. unwrap ( ) . into ( ) ;
3331+ if let Some ( ( code, data) ) = conditions. expected_htlc_error_data {
3332+ assert_eq ! ( reason, code, "unexpected error code" ) ;
3333+ assert_eq ! ( & error_data. as_ref( ) . unwrap( ) [ ..] , data) ;
3334+ }
3335+ } ,
3336+ PathFailure :: InitialSend { .. } => {
3337+ assert ! ( error_code. is_none( ) ) ;
3338+ assert ! ( error_data. is_none( ) ) ;
3339+ assert ! ( conditions. expected_htlc_error_data. is_none( ) ) ;
3340+ } ,
33323341 }
33333342
33343343 if let Some ( chan_closed) = conditions. expected_blamed_chan_closed {
@@ -3362,7 +3371,9 @@ pub fn expect_payment_failed_conditions_event<'a, 'b, 'c, 'd, 'e>(
33623371 assert_eq ! ( * payment_id, expected_payment_id) ;
33633372 assert_eq ! (
33643373 reason. unwrap( ) ,
3365- if expected_payment_failed_permanently {
3374+ if let Some ( expected_reason) = conditions. reason {
3375+ expected_reason
3376+ } else if expected_payment_failed_permanently {
33663377 PaymentFailureReason :: RecipientRejected
33673378 } else {
33683379 PaymentFailureReason :: RetriesExhausted
@@ -3414,7 +3425,7 @@ pub fn send_along_route_with_secret<'a, 'b, 'c>(
34143425 payment_id
34153426}
34163427
3417- fn fail_payment_along_path < ' a , ' b , ' c > ( expected_path : & [ & Node < ' a , ' b , ' c > ] ) {
3428+ pub fn fail_payment_along_path < ' a , ' b , ' c > ( expected_path : & [ & Node < ' a , ' b , ' c > ] ) {
34183429 let origin_node_id = expected_path[ 0 ] . node . get_our_node_id ( ) ;
34193430
34203431 // iterate from the receiving node to the origin node and handle update fail htlc.
0 commit comments