2018-07-23 00:59:16 +00:00
|
|
|
// This file is auto-generated by gen_target.sh based on msg_target_template.txt
|
|
|
|
// To modify it, modify msg_target_template.txt and run gen_target.sh instead.
|
|
|
|
|
|
|
|
extern crate lightning;
|
|
|
|
|
|
|
|
use lightning::ln::msgs;
|
|
|
|
use lightning::util::reset_rng_state;
|
|
|
|
|
|
|
|
use lightning::ln::msgs::{MsgEncodable, MsgDecodable};
|
|
|
|
|
|
|
|
#[inline]
|
|
|
|
pub fn do_test(data: &[u8]) {
|
|
|
|
reset_rng_state();
|
2018-08-25 15:03:59 -04:00
|
|
|
if let Ok(msg) = msgs::ErrorMessage::decode(data){
|
|
|
|
let enc = msg.encode();
|
|
|
|
assert_eq!(&data[0..32], &enc[0..32]);
|
|
|
|
assert_eq!(&data[34..enc.len()], &enc[34..]);
|
|
|
|
}
|
2018-07-23 00:59:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(feature = "afl")]
|
2018-08-16 14:20:34 -04:00
|
|
|
#[macro_use] extern crate afl;
|
2018-07-23 00:59:16 +00:00
|
|
|
#[cfg(feature = "afl")]
|
|
|
|
fn main() {
|
2018-08-16 14:20:34 -04:00
|
|
|
fuzz!(|data| {
|
|
|
|
do_test(data);
|
2018-07-23 00:59:16 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(feature = "honggfuzz")]
|
|
|
|
#[macro_use] extern crate honggfuzz;
|
|
|
|
#[cfg(feature = "honggfuzz")]
|
|
|
|
fn main() {
|
|
|
|
loop {
|
|
|
|
fuzz!(|data| {
|
|
|
|
do_test(data);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-28 09:44:15 -07:00
|
|
|
extern crate hex;
|
2018-07-23 00:59:16 +00:00
|
|
|
#[cfg(test)]
|
|
|
|
mod tests {
|
|
|
|
#[test]
|
|
|
|
fn duplicate_crash() {
|
2018-07-28 09:44:15 -07:00
|
|
|
super::do_test(&::hex::decode("00").unwrap());
|
2018-07-23 00:59:16 +00:00
|
|
|
}
|
|
|
|
}
|