fn drop(&mut self) {
if !panicking() {
// Check that we processed all pending events
- assert!(self.node.get_and_clear_pending_msg_events().is_empty());
- assert!(self.node.get_and_clear_pending_events().is_empty());
- assert!(self.chain_monitor.added_monitors.lock().unwrap().is_empty());
+ let msg_events = self.node.get_and_clear_pending_msg_events();
+ if !msg_events.is_empty() {
+ panic!("Had excess message events on node {}: {:?}", self.logger.id, msg_events);
+ }
+ let events = self.node.get_and_clear_pending_events();
+ if !events.is_empty() {
+ panic!("Had excess events on node {}: {:?}", self.logger.id, events);
+ }
+ let added_monitors = self.chain_monitor.added_monitors.lock().unwrap().split_off(0);
+ if !added_monitors.is_empty() {
+ panic!("Had {} excess added monitors on node {}", added_monitors.len(), self.logger.id);
+ }
// Check that if we serialize the Router, we can deserialize it again.
{
pub struct TestLogger {
level: Level,
- #[cfg(feature = "std")]
- id: String,
- #[cfg(not(feature = "std"))]
- _id: String,
+ pub(crate) id: String,
pub lines: Mutex<HashMap<(String, String), usize>>,
}
pub fn with_id(id: String) -> TestLogger {
TestLogger {
level: Level::Trace,
- #[cfg(feature = "std")]
id,
- #[cfg(not(feature = "std"))]
- _id: id,
lines: Mutex::new(HashMap::new())
}
}
assert_eq!(l, count)
}
- /// Search for the number of occurrences of logged lines which
- /// 1. belong to the specified module and
- /// 2. match the given regex pattern.
- /// Assert that the number of occurrences equals the given `count`
+ /// Search for the number of occurrences of logged lines which
+ /// 1. belong to the specified module and
+ /// 2. match the given regex pattern.
+ /// Assert that the number of occurrences equals the given `count`
pub fn assert_log_regex(&self, module: String, pattern: regex::Regex, count: usize) {
let log_entries = self.lines.lock().unwrap();
let l: usize = log_entries.iter().filter(|&(&(ref m, ref l), _c)| {