@@ -1467,27 +1467,66 @@ macro_rules! check_closed_broadcast {
14671467	} 
14681468} 
14691469
1470- /// Check that a channel's closing channel events has been issued 
1471- pub  fn  check_closed_event ( node :  & Node ,  events_count :  usize ,  expected_reason :  ClosureReason ,  is_check_discard_funding :  bool , 
1472- 	expected_counterparty_node_ids :  & [ PublicKey ] ,  expected_channel_capacity :  u64 )  { 
1473- 	let  events = node. node . get_and_clear_pending_events ( ) ; 
1474- 	assert_eq ! ( events. len( ) ,  events_count,  "{:?}" ,  events) ; 
1475- 	let  mut  issues_discard_funding = false ; 
1476- 	for  event in  events { 
1477- 		match  event { 
1478- 			Event :: ChannelClosed  {  ref  reason,  counterparty_node_id, 
1479- 				channel_capacity_sats,  .. }  => { 
1480- 				assert_eq ! ( * reason,  expected_reason) ; 
1481- 				assert ! ( expected_counterparty_node_ids. iter( ) . any( |id| id == & counterparty_node_id. unwrap( ) ) ) ; 
1482- 				assert_eq ! ( channel_capacity_sats. unwrap( ) ,  expected_channel_capacity) ; 
1483- 			} , 
1484- 			Event :: DiscardFunding  {  .. }  => { 
1485- 				issues_discard_funding = true ; 
1486- 			} 
1487- 			_ => panic ! ( "Unexpected event" ) , 
1470+ pub  struct  ExpectedCloseEvent  { 
1471+ 	pub  channel_capacity_sats :  Option < u64 > , 
1472+ 	pub  channel_id :  Option < ChannelId > , 
1473+ 	pub  counterparty_node_id :  Option < PublicKey > , 
1474+ 	pub  discard_funding :  bool , 
1475+ 	pub  reason :  Option < ClosureReason > , 
1476+ } 
1477+ 
1478+ impl  Default  for  ExpectedCloseEvent  { 
1479+ 	fn  default ( )  -> Self  { 
1480+ 		Self  { 
1481+ 			channel_capacity_sats :  None , 
1482+ 			channel_id :  None , 
1483+ 			counterparty_node_id :  None , 
1484+ 			discard_funding :  false , 
1485+ 			reason :  None , 
14881486		} 
14891487	} 
1490- 	assert_eq ! ( is_check_discard_funding,  issues_discard_funding) ; 
1488+ } 
1489+ 
1490+ /// Check that multiple channel closing events have been issued. 
1491+ pub  fn  check_closed_events ( node :  & Node ,  expected_close_events :  & [ ExpectedCloseEvent ] )  { 
1492+ 	let  closed_events_count = expected_close_events. len ( ) ; 
1493+ 	let  discard_events_count = expected_close_events. iter ( ) . filter ( |e| e. discard_funding ) . count ( ) ; 
1494+ 	let  events = node. node . get_and_clear_pending_events ( ) ; 
1495+ 	assert_eq ! ( events. len( ) ,  closed_events_count + discard_events_count,  "{:?}" ,  events) ; 
1496+ 	for  expected_event in  expected_close_events { 
1497+ 		assert ! ( events. iter( ) . any( |e| matches!( 
1498+ 			e, 
1499+ 			Event :: ChannelClosed  { 
1500+ 				channel_id, 
1501+ 				reason, 
1502+ 				counterparty_node_id, 
1503+ 				channel_capacity_sats, 
1504+ 				..
1505+ 			}  if  ( 
1506+ 				expected_event. channel_id. map( |expected| * channel_id == expected) . unwrap_or( true )  &&
1507+ 				expected_event. reason. as_ref( ) . map( |expected| reason == expected) . unwrap_or( true )  &&
1508+ 				expected_event. counterparty_node_id. map( |expected| * counterparty_node_id == Some ( expected) ) . unwrap_or( true )  &&
1509+ 				expected_event. channel_capacity_sats. map( |expected| * channel_capacity_sats == Some ( expected) ) . unwrap_or( true ) 
1510+ 			) 
1511+ 		) ) ) ; 
1512+ 	} 
1513+ 	assert_eq ! ( events. iter( ) . filter( |e| matches!( 
1514+ 		e, 
1515+ 		Event :: DiscardFunding  {  .. } , 
1516+ 	) ) . count( ) ,  discard_events_count) ; 
1517+ } 
1518+ 
1519+ /// Check that a channel's closing channel events has been issued 
1520+ pub  fn  check_closed_event ( node :  & Node ,  _events_count :  usize ,  expected_reason :  ClosureReason ,  is_check_discard_funding :  bool , 
1521+ 	expected_counterparty_node_ids :  & [ PublicKey ] ,  expected_channel_capacity :  u64 )  { 
1522+ 	let  expected_close_events = expected_counterparty_node_ids. iter ( ) . map ( |node_id| ExpectedCloseEvent  { 
1523+ 		channel_capacity_sats :  Some ( expected_channel_capacity) , 
1524+ 		channel_id :  None , 
1525+ 		counterparty_node_id :  Some ( * node_id) , 
1526+ 		discard_funding :  is_check_discard_funding, 
1527+ 		reason :  Some ( expected_reason. clone ( ) ) , 
1528+ 	} ) . collect :: < Vec < _ > > ( ) ; 
1529+ 	check_closed_events ( node,  expected_close_events. as_slice ( ) ) ; 
14911530} 
14921531
14931532/// Check that a channel's closing channel events has been issued 
0 commit comments