|
13 | 13 | use crate::chain::{BestBlock, ChannelMonitorUpdateStatus, Confirm, Listen, Watch, keysinterface::EntropySource}; |
14 | 14 | use crate::chain::channelmonitor::ChannelMonitor; |
15 | 15 | use crate::chain::transaction::OutPoint; |
16 | | -use crate::events::{ClosureReason, Event, HTLCDestination, MessageSendEvent, MessageSendEventsProvider, PathFailure, PaymentPurpose}; |
| 16 | +use crate::events::{ClosureReason, Event, HTLCDestination, MessageSendEvent, MessageSendEventsProvider, PathFailure, PaymentPurpose, PaymentFailureReason}; |
17 | 17 | use crate::ln::{PaymentPreimage, PaymentHash, PaymentSecret}; |
18 | 18 | use crate::ln::channelmanager::{ChainParameters, ChannelManager, ChannelManagerReadArgs, RAACommitmentOrder, PaymentSendFailure, RecipientOnionFields, PaymentId, MIN_CLTV_EXPIRY_DELTA}; |
19 | 19 | use crate::routing::gossip::{P2PGossipSync, NetworkGraph, NetworkUpdate}; |
@@ -1937,9 +1937,14 @@ pub fn expect_payment_failed_conditions_event<'a, 'b, 'c, 'd, 'e>( |
1937 | 1937 | }; |
1938 | 1938 | if !conditions.expected_mpp_parts_remain { |
1939 | 1939 | match &payment_failed_events[1] { |
1940 | | - Event::PaymentFailed { ref payment_hash, ref payment_id } => { |
| 1940 | + Event::PaymentFailed { ref payment_hash, ref payment_id, ref reason } => { |
1941 | 1941 | assert_eq!(*payment_hash, expected_payment_hash, "unexpected second payment_hash"); |
1942 | 1942 | assert_eq!(*payment_id, expected_payment_id); |
| 1943 | + assert_eq!(reason.unwrap(), if expected_payment_failed_permanently { |
| 1944 | + PaymentFailureReason::RecipientRejected |
| 1945 | + } else { |
| 1946 | + PaymentFailureReason::RetriesExhausted |
| 1947 | + }); |
1943 | 1948 | } |
1944 | 1949 | _ => panic!("Unexpected second event"), |
1945 | 1950 | } |
@@ -2240,10 +2245,10 @@ pub fn fail_payment_along_route<'a, 'b, 'c>(origin_node: &Node<'a, 'b, 'c>, expe |
2240 | 2245 | let expected_destinations: Vec<HTLCDestination> = repeat(HTLCDestination::FailedPayment { payment_hash: our_payment_hash }).take(expected_paths.len()).collect(); |
2241 | 2246 | expect_pending_htlcs_forwardable_and_htlc_handling_failed!(expected_paths[0].last().unwrap(), expected_destinations); |
2242 | 2247 |
|
2243 | | - pass_failed_payment_back(origin_node, expected_paths, skip_last, our_payment_hash); |
| 2248 | + pass_failed_payment_back(origin_node, expected_paths, skip_last, our_payment_hash, PaymentFailureReason::RecipientRejected); |
2244 | 2249 | } |
2245 | 2250 |
|
2246 | | -pub fn pass_failed_payment_back<'a, 'b, 'c>(origin_node: &Node<'a, 'b, 'c>, expected_paths_slice: &[&[&Node<'a, 'b, 'c>]], skip_last: bool, our_payment_hash: PaymentHash) { |
| 2251 | +pub fn pass_failed_payment_back<'a, 'b, 'c>(origin_node: &Node<'a, 'b, 'c>, expected_paths_slice: &[&[&Node<'a, 'b, 'c>]], skip_last: bool, our_payment_hash: PaymentHash, expected_fail_reason: PaymentFailureReason) { |
2247 | 2252 | let mut expected_paths: Vec<_> = expected_paths_slice.iter().collect(); |
2248 | 2253 | check_added_monitors!(expected_paths[0].last().unwrap(), expected_paths.len()); |
2249 | 2254 |
|
@@ -2329,9 +2334,10 @@ pub fn pass_failed_payment_back<'a, 'b, 'c>(origin_node: &Node<'a, 'b, 'c>, expe |
2329 | 2334 | }; |
2330 | 2335 | if i == expected_paths.len() - 1 { |
2331 | 2336 | match events[1] { |
2332 | | - Event::PaymentFailed { ref payment_hash, ref payment_id } => { |
| 2337 | + Event::PaymentFailed { ref payment_hash, ref payment_id, ref reason } => { |
2333 | 2338 | assert_eq!(*payment_hash, our_payment_hash, "unexpected second payment_hash"); |
2334 | 2339 | assert_eq!(*payment_id, expected_payment_id); |
| 2340 | + assert_eq!(reason.unwrap(), expected_fail_reason); |
2335 | 2341 | } |
2336 | 2342 | _ => panic!("Unexpected second event"), |
2337 | 2343 | } |
|
0 commit comments