- if $with_error_msg {
- match msg_events[1] {
- MessageSendEvent::HandleError { action: ErrorAction::SendErrorMessage { ref msg }, node_id: _ } => {
- // TODO: Check node_id
- Some(msg.clone())
- },
- _ => panic!("Unexpected event"),
+ }).collect()
+}
+
+/// Check that a channel's closing channel update has been broadcasted, and optionally
+/// check whether an error message event has occurred.
+///
+/// Don't use this, use the identically-named function instead.
+#[macro_export]
+macro_rules! check_closed_broadcast {
+ ($node: expr, $with_error_msg: expr) => {
+ $crate::ln::functional_test_utils::check_closed_broadcast(&$node, 1, $with_error_msg).pop()
+ }
+}
+
+/// Check that a channel's closing channel events has been issued
+pub fn check_closed_event(node: &Node, events_count: usize, expected_reason: ClosureReason, is_check_discard_funding: bool) {
+ let events = node.node.get_and_clear_pending_events();
+ assert_eq!(events.len(), events_count, "{:?}", events);
+ let mut issues_discard_funding = false;
+ for event in events {
+ match event {
+ Event::ChannelClosed { ref reason, .. } => {
+ assert_eq!(*reason, expected_reason);
+ },
+ Event::DiscardFunding { .. } => {
+ issues_discard_funding = true;