Upgrade AFL to 0.4 with persistent mode fuzzing
[rust-lightning] / fuzz / fuzz_targets / chanmon_deser_target.rs
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.
3
4 extern crate lightning;
5
6 use lightning::ln::channelmonitor;
7 use lightning::util::reset_rng_state;
8
9 #[inline]
10 pub fn do_test(data: &[u8]) {
11         reset_rng_state();
12         if let Some(monitor) = channelmonitor::ChannelMonitor::deserialize(data) {
13                 assert!(channelmonitor::ChannelMonitor::deserialize(&monitor.serialize_for_disk()[..]).unwrap() == monitor);
14                 monitor.serialize_for_watchtower();
15         }
16 }
17
18 #[cfg(feature = "afl")]
19 #[macro_use] extern crate afl;
20 #[cfg(feature = "afl")]
21 fn main() {
22         fuzz!(|data| {
23                 do_test(data);
24         });
25 }
26
27 #[cfg(feature = "honggfuzz")]
28 #[macro_use] extern crate honggfuzz;
29 #[cfg(feature = "honggfuzz")]
30 fn main() {
31         loop {
32                 fuzz!(|data| {
33                         do_test(data);
34                 });
35         }
36 }
37
38 extern crate hex;
39 #[cfg(test)]
40 mod tests {
41
42         #[test]
43         fn duplicate_crash() {
44                 super::do_test(&::hex::decode("00").unwrap());
45         }
46 }