1 // This file is auto-generated by gen_target.sh based on msg_target_template.txt
2 // To modify it, modify msg_target_template.txt and run gen_target.sh instead.
4 extern crate lightning;
6 use lightning::ln::channelmonitor;
7 use lightning::util::reset_rng_state;
8 use lightning::util::ser::{Readable, Writer};
12 struct VecWriter(Vec<u8>);
13 impl Writer for VecWriter {
14 fn write_all(&mut self, buf: &[u8]) -> Result<(), ::std::io::Error> {
15 self.0.extend_from_slice(buf);
18 fn size_hint(&mut self, size: usize) {
19 self.0.reserve_exact(size);
24 pub fn do_test(data: &[u8]) {
26 if let Ok(monitor) = channelmonitor::ChannelMonitor::read(&mut Cursor::new(data)) {
27 let mut w = VecWriter(Vec::new());
28 monitor.write_for_disk(&mut w).unwrap();
29 assert!(channelmonitor::ChannelMonitor::read(&mut Cursor::new(&w.0)).unwrap() == monitor);
31 monitor.write_for_watchtower(&mut w).unwrap();
35 #[cfg(feature = "afl")]
36 #[macro_use] extern crate afl;
37 #[cfg(feature = "afl")]
44 #[cfg(feature = "honggfuzz")]
45 #[macro_use] extern crate honggfuzz;
46 #[cfg(feature = "honggfuzz")]
60 fn duplicate_crash() {
61 super::do_test(&::hex::decode("00").unwrap());