X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=fuzz%2Fsrc%2Fchanmon_deser.rs;h=8c8f4aedf7a438d2a6ecf7b0f9a2eb95d9c6877d;hb=c90aac26ad3edf6a3878f63b50c5e9ee425c8f56;hp=fd326cc2ec85bdc72670da4cae4f7388366c05af;hpb=9c7c3b99210676793b1d35575d8538979cc1b349;p=rust-lightning diff --git a/fuzz/src/chanmon_deser.rs b/fuzz/src/chanmon_deser.rs index fd326cc2..8c8f4aed 100644 --- a/fuzz/src/chanmon_deser.rs +++ b/fuzz/src/chanmon_deser.rs @@ -4,10 +4,11 @@ use bitcoin::hash_types::BlockHash; use lightning::chain::channelmonitor; -use lightning::util::enforcing_trait_impls::EnforcingChannelKeys; -use lightning::util::ser::{Readable, Writer}; +use lightning::util::enforcing_trait_impls::EnforcingSigner; +use lightning::util::ser::{ReadableArgs, Writer, Writeable}; +use lightning::util::test_utils::OnlyReadsKeysInterface; -use utils::test_logger; +use crate::utils::test_logger; use std::io::Cursor; @@ -17,17 +18,14 @@ impl Writer for VecWriter { self.0.extend_from_slice(buf); Ok(()) } - fn size_hint(&mut self, size: usize) { - self.0.reserve_exact(size); - } } #[inline] pub fn do_test(data: &[u8], _out: Out) { - if let Ok((latest_block_hash, monitor)) = <(BlockHash, channelmonitor::ChannelMonitor)>::read(&mut Cursor::new(data)) { + if let Ok((latest_block_hash, monitor)) = <(BlockHash, channelmonitor::ChannelMonitor)>::read(&mut Cursor::new(data), &OnlyReadsKeysInterface {}) { let mut w = VecWriter(Vec::new()); - monitor.serialize_for_disk(&mut w).unwrap(); - let deserialized_copy = <(BlockHash, channelmonitor::ChannelMonitor)>::read(&mut Cursor::new(&w.0)).unwrap(); + monitor.write(&mut w).unwrap(); + let deserialized_copy = <(BlockHash, channelmonitor::ChannelMonitor)>::read(&mut Cursor::new(&w.0), &OnlyReadsKeysInterface {}).unwrap(); assert!(latest_block_hash == deserialized_copy.0); assert!(monitor == deserialized_copy.1); }