Add fuzz targets for Writeable messages/migrate fuzz test
[rust-lightning] / fuzz / fuzz_targets / msg_targets / msg_funding_created_target.rs
index 2420e921ecff8775ac9a93f0bcd298bfd0d306eb..b9c67ae33504b27e7820cb0b17095d73200d2264 100644 (file)
@@ -6,26 +6,20 @@ extern crate lightning;
 use lightning::ln::msgs;
 use lightning::util::reset_rng_state;
 
-use lightning::ln::msgs::{MsgEncodable, MsgDecodable};
-
 mod utils;
-use utils::slice_to_be16;
 
 #[inline]
 pub fn do_test(data: &[u8]) {
        reset_rng_state();
-       let mut read_pos = 0;
-       loop {
-               test_msg!(msgs::FundingCreated, data, read_pos);
-       }
+       test_msg!(msgs::FundingCreated, data);
 }
 
 #[cfg(feature = "afl")]
-extern crate afl;
+#[macro_use] extern crate afl;
 #[cfg(feature = "afl")]
 fn main() {
-       afl::read_stdio_bytes(|data| {
-               do_test(&data);
+       fuzz!(|data| {
+               do_test(data);
        });
 }
 
@@ -40,13 +34,11 @@ fn main() {
        }
 }
 
+extern crate hex;
 #[cfg(test)]
 mod tests {
-       use utils::extend_vec_from_hex;
        #[test]
        fn duplicate_crash() {
-               let mut a = Vec::new();
-               extend_vec_from_hex("00", &mut a);
-               super::do_test(&a);
+               super::do_test(&::hex::decode("00").unwrap());
        }
 }