@@ -2839,11 +2839,13 @@ macro_rules! expect_payment_claimed {
2839
2839
} ;
2840
2840
}
2841
2841
2842
+ /// Inspect events to assert that a payment was sent. If this was a BOLT 12 payment, the BOLT 12 invoice is returned. If
2843
+ /// per-path claims are expected, the events for each path are returned as well.
2842
2844
pub fn expect_payment_sent < CM : AChannelManager , H : NodeHolder < CM = CM > > (
2843
2845
node : & H , expected_payment_preimage : PaymentPreimage ,
2844
2846
expected_fee_msat_opt : Option < Option < u64 > > , expect_per_path_claims : bool ,
2845
2847
expect_post_ev_mon_update : bool ,
2846
- ) -> Option < PaidBolt12Invoice > {
2848
+ ) -> ( Option < PaidBolt12Invoice > , Vec < Event > ) {
2847
2849
let events = node. node ( ) . get_and_clear_pending_events ( ) ;
2848
2850
let expected_payment_hash = PaymentHash (
2849
2851
bitcoin:: hashes:: sha256:: Hash :: hash ( & expected_payment_preimage. 0 ) . to_byte_array ( ) ,
@@ -2858,6 +2860,7 @@ pub fn expect_payment_sent<CM: AChannelManager, H: NodeHolder<CM = CM>>(
2858
2860
}
2859
2861
// We return the invoice because some test may want to check the invoice details.
2860
2862
let invoice;
2863
+ let mut path_events = Vec :: new ( ) ;
2861
2864
let expected_payment_id = match events[ 0 ] {
2862
2865
Event :: PaymentSent {
2863
2866
ref payment_id,
@@ -2886,12 +2889,14 @@ pub fn expect_payment_sent<CM: AChannelManager, H: NodeHolder<CM = CM>>(
2886
2889
Event :: PaymentPathSuccessful { payment_id, payment_hash, .. } => {
2887
2890
assert_eq ! ( payment_id, expected_payment_id) ;
2888
2891
assert_eq ! ( payment_hash, Some ( expected_payment_hash) ) ;
2892
+
2893
+ path_events. push ( events[ i] . clone ( ) ) ;
2889
2894
} ,
2890
2895
_ => panic ! ( "Unexpected event" ) ,
2891
2896
}
2892
2897
}
2893
2898
}
2894
- invoice
2899
+ ( invoice, path_events )
2895
2900
}
2896
2901
2897
2902
#[ macro_export]
@@ -3903,15 +3908,17 @@ pub fn pass_claimed_payment_along_route(args: ClaimAlongRouteArgs) -> u64 {
3903
3908
3904
3909
expected_total_fee_msat
3905
3910
}
3906
- pub fn claim_payment_along_route ( args : ClaimAlongRouteArgs ) -> Option < PaidBolt12Invoice > {
3911
+ pub fn claim_payment_along_route (
3912
+ args : ClaimAlongRouteArgs ,
3913
+ ) -> ( Option < PaidBolt12Invoice > , Vec < Event > ) {
3907
3914
let origin_node = args. origin_node ;
3908
3915
let payment_preimage = args. payment_preimage ;
3909
3916
let skip_last = args. skip_last ;
3910
3917
let expected_total_fee_msat = do_claim_payment_along_route ( args) ;
3911
3918
if !skip_last {
3912
3919
expect_payment_sent ! ( origin_node, payment_preimage, Some ( expected_total_fee_msat) )
3913
3920
} else {
3914
- None
3921
+ ( None , Vec :: new ( ) )
3915
3922
}
3916
3923
}
3917
3924
@@ -3924,6 +3931,7 @@ pub fn claim_payment<'a, 'b, 'c>(
3924
3931
& [ expected_route] ,
3925
3932
our_payment_preimage,
3926
3933
) )
3934
+ . 0
3927
3935
}
3928
3936
3929
3937
pub const TEST_FINAL_CLTV : u32 = 70 ;
0 commit comments