Merge pull request #26 from TheBlueMatt/master
[rust-lightning] / fuzz / fuzz_targets / msg_targets / msg_shutdown_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::msgs;
7 use lightning::util::reset_rng_state;
8
9 use lightning::ln::msgs::{MsgEncodable, MsgDecodable};
10
11 mod utils;
12 use utils::slice_to_be16;
13
14 #[inline]
15 pub fn do_test(data: &[u8]) {
16         reset_rng_state();
17         let mut read_pos = 0;
18         loop {
19                 test_msg!(msgs::Shutdown, data, read_pos);
20         }
21 }
22
23 #[cfg(feature = "afl")]
24 extern crate afl;
25 #[cfg(feature = "afl")]
26 fn main() {
27         afl::read_stdio_bytes(|data| {
28                 do_test(&data);
29         });
30 }
31
32 #[cfg(feature = "honggfuzz")]
33 #[macro_use] extern crate honggfuzz;
34 #[cfg(feature = "honggfuzz")]
35 fn main() {
36         loop {
37                 fuzz!(|data| {
38                         do_test(data);
39                 });
40         }
41 }
42
43 #[cfg(test)]
44 mod tests {
45         use utils::extend_vec_from_hex;
46         #[test]
47         fn duplicate_crash() {
48                 let mut a = Vec::new();
49                 extend_vec_from_hex("00", &mut a);
50                 super::do_test(&a);
51         }
52 }