#[inline]
pub fn do_test(data: &[u8]) {
reset_rng_state();
- let logger = Arc::new(test_logger::TestLogger{});
+ let logger = Arc::new(test_logger::TestLogger::new("".to_owned()));
if let Ok((latest_block_hash, monitor)) = <(Sha256dHash, channelmonitor::ChannelMonitor)>::read(&mut Cursor::new(data), logger.clone()) {
let mut w = VecWriter(Vec::new());
monitor.write_for_disk(&mut w).unwrap();
#[cfg(feature = "afl")]
fn main() {
fuzz!(|data| {
- let logger: Arc<Logger> = Arc::new(test_logger::TestLogger{});
+ let logger: Arc<Logger> = Arc::new(test_logger::TestLogger::new("".to_owned()));
do_test(data, &logger);
});
}
fn main() {
loop {
fuzz!(|data| {
- let logger: Arc<Logger> = Arc::new(test_logger::TestLogger{});
+ let logger: Arc<Logger> = Arc::new(test_logger::TestLogger::new("".to_owned()));
do_test(data, &logger);
});
}
#[macro_use] extern crate libfuzzer_sys;
#[cfg(feature = "libfuzzer_fuzz")]
fuzz_target!(|data: &[u8]| {
- let logger: Arc<Logger> = Arc::new(test_logger::TestLogger{});
+ let logger: Arc<Logger> = Arc::new(test_logger::TestLogger::new("".to_owned()));
do_test(data, &logger);
});
#[test]
fn duplicate_crash() {
- let logger: Arc<Logger> = Arc::new(test_logger::TestLogger{});
+ let logger: Arc<Logger> = Arc::new(test_logger::TestLogger::new("".to_owned()));
super::do_test(&::hex::decode("00").unwrap(), &logger);
}
}
}
- let logger: Arc<Logger> = Arc::new(test_logger::TestLogger{});
+ let logger: Arc<Logger> = Arc::new(test_logger::TestLogger::new("".to_owned()));
let chain_monitor = Arc::new(DummyChainWatcher {
input: Arc::clone(&input),
});
use lightning::util::logger::{Logger, Record};
+pub struct TestLogger {
+ #[cfg(test)]
+ id: String,
+}
-pub struct TestLogger {}
+impl TestLogger {
+ pub fn new(_id: String) -> TestLogger {
+ TestLogger {
+ #[cfg(test)]
+ id: _id
+ }
+ }
+}
impl Logger for TestLogger {
fn log(&self, record: &Record) {
#[cfg(test)]
- println!("{:<5} [{} : {}, {}] {}", record.level.to_string(), record.module_path, record.file, record.line, record.args);
+ println!("{:<5} {} [{} : {}, {}] {}", record.level.to_string(), self.id, record.module_path, record.file, record.line, record.args);
#[cfg(not(test))]
let _ = format!("{}", record.args);
}