@@ -1938,29 +1938,38 @@ macro_rules! expect_payment_path_successful {
1938
1938
}
1939
1939
}
1940
1940
1941
+ pub fn expect_payment_forwarded < CM : AChannelManager , H : NodeHolder < CM =CM > > (
1942
+ event : Event , node : & H , prev_node : & H , next_node : & H , expected_fee : Option < u64 > ,
1943
+ upstream_force_closed : bool , downstream_force_closed : bool
1944
+ ) {
1945
+ match event {
1946
+ Event :: PaymentForwarded {
1947
+ fee_earned_msat, prev_channel_id, claim_from_onchain_tx, next_channel_id,
1948
+ outbound_amount_forwarded_msat : _
1949
+ } => {
1950
+ assert_eq ! ( fee_earned_msat, expected_fee) ;
1951
+ if !upstream_force_closed {
1952
+ // Is the event prev_channel_id in one of the channels between the two nodes?
1953
+ assert ! ( node. node( ) . list_channels( ) . iter( ) . any( |x| x. counterparty. node_id == prev_node. node( ) . get_our_node_id( ) && x. channel_id == prev_channel_id. unwrap( ) ) ) ;
1954
+ }
1955
+ // We check for force closures since a force closed channel is removed from the
1956
+ // node's channel list
1957
+ if !downstream_force_closed {
1958
+ assert ! ( node. node( ) . list_channels( ) . iter( ) . any( |x| x. counterparty. node_id == next_node. node( ) . get_our_node_id( ) && x. channel_id == next_channel_id. unwrap( ) ) ) ;
1959
+ }
1960
+ assert_eq ! ( claim_from_onchain_tx, downstream_force_closed) ;
1961
+ } ,
1962
+ _ => panic ! ( "Unexpected event" ) ,
1963
+ }
1964
+ }
1965
+
1941
1966
macro_rules! expect_payment_forwarded {
1942
1967
( $node: expr, $prev_node: expr, $next_node: expr, $expected_fee: expr, $upstream_force_closed: expr, $downstream_force_closed: expr) => {
1943
- let events = $node. node. get_and_clear_pending_events( ) ;
1968
+ let mut events = $node. node. get_and_clear_pending_events( ) ;
1944
1969
assert_eq!( events. len( ) , 1 ) ;
1945
- match events[ 0 ] {
1946
- Event :: PaymentForwarded {
1947
- fee_earned_msat, prev_channel_id, claim_from_onchain_tx, next_channel_id,
1948
- outbound_amount_forwarded_msat: _
1949
- } => {
1950
- assert_eq!( fee_earned_msat, $expected_fee) ;
1951
- if !$upstream_force_closed {
1952
- // Is the event prev_channel_id in one of the channels between the two nodes?
1953
- assert!( $node. node. list_channels( ) . iter( ) . any( |x| x. counterparty. node_id == $prev_node. node. get_our_node_id( ) && x. channel_id == prev_channel_id. unwrap( ) ) ) ;
1954
- }
1955
- // We check for force closures since a force closed channel is removed from the
1956
- // node's channel list
1957
- if !$downstream_force_closed {
1958
- assert!( $node. node. list_channels( ) . iter( ) . any( |x| x. counterparty. node_id == $next_node. node. get_our_node_id( ) && x. channel_id == next_channel_id. unwrap( ) ) ) ;
1959
- }
1960
- assert_eq!( claim_from_onchain_tx, $downstream_force_closed) ;
1961
- } ,
1962
- _ => panic!( "Unexpected event" ) ,
1963
- }
1970
+ $crate:: ln:: functional_test_utils:: expect_payment_forwarded(
1971
+ events. pop( ) . unwrap( ) , & $node, & $prev_node, & $next_node, $expected_fee,
1972
+ $upstream_force_closed, $downstream_force_closed) ;
1964
1973
}
1965
1974
}
1966
1975
@@ -2311,7 +2320,7 @@ pub fn do_claim_payment_along_route_with_extra_penultimate_hop_fees<'a, 'b, 'c>(
2311
2320
}
2312
2321
} ;
2313
2322
if $idx == 1 { fee += expected_extra_fees[ i] ; }
2314
- expect_payment_forwarded!( $node, $next_node, $prev_node, Some ( fee as u64 ) , false , false ) ;
2323
+ expect_payment_forwarded!( * $node, $next_node, $prev_node, Some ( fee as u64 ) , false , false ) ;
2315
2324
expected_total_fee_msat += fee as u64 ;
2316
2325
check_added_monitors!( $node, 1 ) ;
2317
2326
let new_next_msgs = if $new_msgs {
0 commit comments