@@ -2862,11 +2862,13 @@ macro_rules! expect_payment_claimed {
2862
2862
} ;
2863
2863
}
2864
2864
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.
2865
2867
pub fn expect_payment_sent < CM : AChannelManager , H : NodeHolder < CM = CM > > (
2866
2868
node : & H , expected_payment_preimage : PaymentPreimage ,
2867
2869
expected_fee_msat_opt : Option < Option < u64 > > , expect_per_path_claims : bool ,
2868
2870
expect_post_ev_mon_update : bool ,
2869
- ) -> Option < PaidBolt12Invoice > {
2871
+ ) -> ( Option < PaidBolt12Invoice > , Vec < Event > ) {
2870
2872
let events = node. node ( ) . get_and_clear_pending_events ( ) ;
2871
2873
let expected_payment_hash = PaymentHash (
2872
2874
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>>(
2881
2883
}
2882
2884
// We return the invoice because some test may want to check the invoice details.
2883
2885
let invoice;
2886
+ let mut path_events = Vec :: new ( ) ;
2884
2887
let expected_payment_id = match events[ 0 ] {
2885
2888
Event :: PaymentSent {
2886
2889
ref payment_id,
@@ -2909,12 +2912,14 @@ pub fn expect_payment_sent<CM: AChannelManager, H: NodeHolder<CM = CM>>(
2909
2912
Event :: PaymentPathSuccessful { payment_id, payment_hash, .. } => {
2910
2913
assert_eq ! ( payment_id, expected_payment_id) ;
2911
2914
assert_eq ! ( payment_hash, Some ( expected_payment_hash) ) ;
2915
+
2916
+ path_events. push ( events[ i] . clone ( ) ) ;
2912
2917
} ,
2913
2918
_ => panic ! ( "Unexpected event" ) ,
2914
2919
}
2915
2920
}
2916
2921
}
2917
- invoice
2922
+ ( invoice, path_events )
2918
2923
}
2919
2924
2920
2925
#[ macro_export]
@@ -3926,15 +3931,17 @@ pub fn pass_claimed_payment_along_route(args: ClaimAlongRouteArgs) -> u64 {
3926
3931
3927
3932
expected_total_fee_msat
3928
3933
}
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 > ) {
3930
3937
let origin_node = args. origin_node ;
3931
3938
let payment_preimage = args. payment_preimage ;
3932
3939
let skip_last = args. skip_last ;
3933
3940
let expected_total_fee_msat = do_claim_payment_along_route ( args) ;
3934
3941
if !skip_last {
3935
3942
expect_payment_sent ! ( origin_node, payment_preimage, Some ( expected_total_fee_msat) )
3936
3943
} else {
3937
- None
3944
+ ( None , Vec :: new ( ) )
3938
3945
}
3939
3946
}
3940
3947
@@ -3947,6 +3954,7 @@ pub fn claim_payment<'a, 'b, 'c>(
3947
3954
& [ expected_route] ,
3948
3955
our_payment_preimage,
3949
3956
) )
3957
+ . 0
3950
3958
}
3951
3959
3952
3960
pub const TEST_FINAL_CLTV : u32 = 70 ;
0 commit comments