@@ -2862,11 +2862,13 @@ macro_rules! expect_payment_claimed {
28622862 } ;
28632863}
28642864
2865+ /// Inspect events to assert that a payment was sent. If this was a BOLT 12 payment, the BOLT 12 invoice is returned. If
2866+ /// per-path claims are expected, the events for each path are returned as well.
28652867pub fn expect_payment_sent < CM : AChannelManager , H : NodeHolder < CM = CM > > (
28662868 node : & H , expected_payment_preimage : PaymentPreimage ,
28672869 expected_fee_msat_opt : Option < Option < u64 > > , expect_per_path_claims : bool ,
28682870 expect_post_ev_mon_update : bool ,
2869- ) -> Option < PaidBolt12Invoice > {
2871+ ) -> ( Option < PaidBolt12Invoice > , Vec < Event > ) {
28702872 let events = node. node ( ) . get_and_clear_pending_events ( ) ;
28712873 let expected_payment_hash = PaymentHash (
28722874 bitcoin:: hashes:: sha256:: Hash :: hash ( & expected_payment_preimage. 0 ) . to_byte_array ( ) ,
@@ -2881,6 +2883,7 @@ pub fn expect_payment_sent<CM: AChannelManager, H: NodeHolder<CM = CM>>(
28812883 }
28822884 // We return the invoice because some test may want to check the invoice details.
28832885 let invoice;
2886+ let mut path_events = Vec :: new ( ) ;
28842887 let expected_payment_id = match events[ 0 ] {
28852888 Event :: PaymentSent {
28862889 ref payment_id,
@@ -2909,12 +2912,14 @@ pub fn expect_payment_sent<CM: AChannelManager, H: NodeHolder<CM = CM>>(
29092912 Event :: PaymentPathSuccessful { payment_id, payment_hash, .. } => {
29102913 assert_eq ! ( payment_id, expected_payment_id) ;
29112914 assert_eq ! ( payment_hash, Some ( expected_payment_hash) ) ;
2915+
2916+ path_events. push ( events[ i] . clone ( ) ) ;
29122917 } ,
29132918 _ => panic ! ( "Unexpected event" ) ,
29142919 }
29152920 }
29162921 }
2917- invoice
2922+ ( invoice, path_events )
29182923}
29192924
29202925#[ macro_export]
@@ -3926,15 +3931,17 @@ pub fn pass_claimed_payment_along_route(args: ClaimAlongRouteArgs) -> u64 {
39263931
39273932 expected_total_fee_msat
39283933}
3929- pub fn claim_payment_along_route ( args : ClaimAlongRouteArgs ) -> Option < PaidBolt12Invoice > {
3934+ pub fn claim_payment_along_route (
3935+ args : ClaimAlongRouteArgs ,
3936+ ) -> ( Option < PaidBolt12Invoice > , Vec < Event > ) {
39303937 let origin_node = args. origin_node ;
39313938 let payment_preimage = args. payment_preimage ;
39323939 let skip_last = args. skip_last ;
39333940 let expected_total_fee_msat = do_claim_payment_along_route ( args) ;
39343941 if !skip_last {
39353942 expect_payment_sent ! ( origin_node, payment_preimage, Some ( expected_total_fee_msat) )
39363943 } else {
3937- None
3944+ ( None , Vec :: new ( ) )
39383945 }
39393946}
39403947
@@ -3947,6 +3954,7 @@ pub fn claim_payment<'a, 'b, 'c>(
39473954 & [ expected_route] ,
39483955 our_payment_preimage,
39493956 ) )
3957+ . 0
39503958}
39513959
39523960pub const TEST_FINAL_CLTV : u32 = 70 ;
0 commit comments