Make rand a dev-dep by having the user randomize HTLC forward delay
[rust-lightning] / fuzz / fuzz_targets / msg_targets / msg_update_fulfill_htlc_target.rs
index edddfb54cbab41d96673cdce097adb5d999241d4..f0c936d1e330e5a89d8c0dca5e0395a04e2d7aa2 100644 (file)
@@ -4,28 +4,21 @@
 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;
+use utils::VecWriter;
 
 #[inline]
 pub fn do_test(data: &[u8]) {
-       reset_rng_state();
-       let mut read_pos = 0;
-       loop {
-               test_msg!(msgs::UpdateFulfillHTLC, data, read_pos);
-       }
+       test_msg!(msgs::UpdateFulfillHTLC, 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 +33,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());
        }
 }