@@ -1239,24 +1239,23 @@ macro_rules! check_warn_msg {
1239
1239
1240
1240
/// Check that a channel's closing channel update has been broadcasted, and optionally
1241
1241
/// check whether an error message event has occurred.
1242
- pub fn check_closed_broadcast ( node : & Node , with_error_msg : bool ) -> Option < msgs:: ErrorMessage > {
1242
+ pub fn check_closed_broadcast ( node : & Node , num_channels : usize , with_error_msg : bool ) -> Vec < msgs:: ErrorMessage > {
1243
1243
let msg_events = node. node . get_and_clear_pending_msg_events ( ) ;
1244
- assert_eq ! ( msg_events. len( ) , if with_error_msg { 2 } else { 1 } ) ;
1245
- match msg_events[ 0 ] {
1246
- MessageSendEvent :: BroadcastChannelUpdate { ref msg } => {
1247
- assert_eq ! ( msg. contents. flags & 2 , 2 ) ;
1248
- } ,
1249
- _ => panic ! ( "Unexpected event" ) ,
1250
- }
1251
- if with_error_msg {
1252
- match msg_events[ 1 ] {
1244
+ assert_eq ! ( msg_events. len( ) , if with_error_msg { num_channels * 2 } else { num_channels } ) ;
1245
+ msg_events. into_iter ( ) . filter_map ( |msg_event| {
1246
+ match msg_event {
1247
+ MessageSendEvent :: BroadcastChannelUpdate { ref msg } => {
1248
+ assert_eq ! ( msg. contents. flags & 2 , 2 ) ;
1249
+ None
1250
+ } ,
1253
1251
MessageSendEvent :: HandleError { action : msgs:: ErrorAction :: SendErrorMessage { ref msg } , node_id : _ } => {
1252
+ assert ! ( with_error_msg) ;
1254
1253
// TODO: Check node_id
1255
1254
Some ( msg. clone ( ) )
1256
1255
} ,
1257
1256
_ => panic ! ( "Unexpected event" ) ,
1258
1257
}
1259
- } else { None }
1258
+ } ) . collect ( )
1260
1259
}
1261
1260
1262
1261
/// Check that a channel's closing channel update has been broadcasted, and optionally
@@ -1266,7 +1265,7 @@ pub fn check_closed_broadcast(node: &Node, with_error_msg: bool) -> Option<msgs:
1266
1265
#[ macro_export]
1267
1266
macro_rules! check_closed_broadcast {
1268
1267
( $node: expr, $with_error_msg: expr) => {
1269
- $crate:: ln:: functional_test_utils:: check_closed_broadcast( & $node, $with_error_msg)
1268
+ $crate:: ln:: functional_test_utils:: check_closed_broadcast( & $node, 1 , $with_error_msg) . pop ( )
1270
1269
}
1271
1270
}
1272
1271
0 commit comments