@@ -1239,24 +1239,23 @@ macro_rules! check_warn_msg {
12391239
12401240/// Check that a channel's closing channel update has been broadcasted, and optionally
12411241/// 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 > {
12431243 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+ } ,
12531251 MessageSendEvent :: HandleError { action : msgs:: ErrorAction :: SendErrorMessage { ref msg } , node_id : _ } => {
1252+ assert ! ( with_error_msg) ;
12541253 // TODO: Check node_id
12551254 Some ( msg. clone ( ) )
12561255 } ,
12571256 _ => panic ! ( "Unexpected event" ) ,
12581257 }
1259- } else { None }
1258+ } ) . collect ( )
12601259}
12611260
12621261/// 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:
12661265#[ macro_export]
12671266macro_rules! check_closed_broadcast {
12681267 ( $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 ( )
12701269 }
12711270}
12721271
0 commit comments