@@ -1965,29 +1965,38 @@ macro_rules! expect_payment_path_successful {
1965
1965
}
1966
1966
}
1967
1967
1968
+ pub fn expect_payment_forwarded < CM : AChannelManager , H : NodeHolder < CM =CM > > (
1969
+ event : Event , node : & H , prev_node : & H , next_node : & H , expected_fee : Option < u64 > ,
1970
+ upstream_force_closed : bool , downstream_force_closed : bool
1971
+ ) {
1972
+ match event {
1973
+ Event :: PaymentForwarded {
1974
+ fee_earned_msat, prev_channel_id, claim_from_onchain_tx, next_channel_id,
1975
+ outbound_amount_forwarded_msat : _
1976
+ } => {
1977
+ assert_eq ! ( fee_earned_msat, expected_fee) ;
1978
+ if !upstream_force_closed {
1979
+ // Is the event prev_channel_id in one of the channels between the two nodes?
1980
+ 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( ) ) ) ;
1981
+ }
1982
+ // We check for force closures since a force closed channel is removed from the
1983
+ // node's channel list
1984
+ if !downstream_force_closed {
1985
+ 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( ) ) ) ;
1986
+ }
1987
+ assert_eq ! ( claim_from_onchain_tx, downstream_force_closed) ;
1988
+ } ,
1989
+ _ => panic ! ( "Unexpected event" ) ,
1990
+ }
1991
+ }
1992
+
1968
1993
macro_rules! expect_payment_forwarded {
1969
1994
( $node: expr, $prev_node: expr, $next_node: expr, $expected_fee: expr, $upstream_force_closed: expr, $downstream_force_closed: expr) => {
1970
- let events = $node. node. get_and_clear_pending_events( ) ;
1995
+ let mut events = $node. node. get_and_clear_pending_events( ) ;
1971
1996
assert_eq!( events. len( ) , 1 ) ;
1972
- match events[ 0 ] {
1973
- Event :: PaymentForwarded {
1974
- fee_earned_msat, prev_channel_id, claim_from_onchain_tx, next_channel_id,
1975
- outbound_amount_forwarded_msat: _
1976
- } => {
1977
- assert_eq!( fee_earned_msat, $expected_fee) ;
1978
- if !$upstream_force_closed {
1979
- // Is the event prev_channel_id in one of the channels between the two nodes?
1980
- 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( ) ) ) ;
1981
- }
1982
- // We check for force closures since a force closed channel is removed from the
1983
- // node's channel list
1984
- if !$downstream_force_closed {
1985
- 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( ) ) ) ;
1986
- }
1987
- assert_eq!( claim_from_onchain_tx, $downstream_force_closed) ;
1988
- } ,
1989
- _ => panic!( "Unexpected event" ) ,
1990
- }
1997
+ $crate:: ln:: functional_test_utils:: expect_payment_forwarded(
1998
+ events. pop( ) . unwrap( ) , & $node, & $prev_node, & $next_node, $expected_fee,
1999
+ $upstream_force_closed, $downstream_force_closed) ;
1991
2000
}
1992
2001
}
1993
2002
@@ -2338,7 +2347,7 @@ pub fn do_claim_payment_along_route_with_extra_penultimate_hop_fees<'a, 'b, 'c>(
2338
2347
}
2339
2348
} ;
2340
2349
if $idx == 1 { fee += expected_extra_fees[ i] ; }
2341
- expect_payment_forwarded!( $node, $next_node, $prev_node, Some ( fee as u64 ) , false , false ) ;
2350
+ expect_payment_forwarded!( * $node, $next_node, $prev_node, Some ( fee as u64 ) , false , false ) ;
2342
2351
expected_total_fee_msat += fee as u64 ;
2343
2352
check_added_monitors!( $node, 1 ) ;
2344
2353
let new_next_msgs = if $new_msgs {
0 commit comments