From: Matt Corallo Date: Wed, 7 Feb 2024 02:27:22 +0000 (+0000) Subject: [fuzz] Add fst coverage for `ChannelManager::update_channel_config` X-Git-Tag: v0.0.123-beta~71^2 X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=refs%2Fheads%2F2024-01-fuzz-gossip;p=rust-lightning [fuzz] Add fst coverage for `ChannelManager::update_channel_config` --- diff --git a/fuzz/src/full_stack.rs b/fuzz/src/full_stack.rs index a68cef1b9..2150bcfb7 100644 --- a/fuzz/src/full_stack.rs +++ b/fuzz/src/full_stack.rs @@ -48,7 +48,7 @@ use lightning::onion_message::messenger::{Destination, MessageRouter, OnionMessa use lightning::routing::gossip::{P2PGossipSync, NetworkGraph}; use lightning::routing::utxo::UtxoLookup; use lightning::routing::router::{InFlightHtlcs, PaymentParameters, Route, RouteParameters, Router}; -use lightning::util::config::UserConfig; +use lightning::util::config::{ChannelConfig, UserConfig}; use lightning::util::errors::APIError; use lightning::util::test_channel_signer::{TestChannelSigner, EnforcementState}; use lightning::util::logger::Logger; @@ -104,6 +104,16 @@ impl InputData { Some(&self.data[old_pos..old_pos + len]) } } +impl std::io::Read for &InputData { + fn read(&mut self, buf: &mut [u8]) -> std::io::Result { + if let Some(sl) = self.get_slice(buf.len()) { + buf.copy_from_slice(sl); + Ok(buf.len()) + } else { + Ok(0) + } + } +} struct FuzzEstimator { input: Arc, @@ -758,6 +768,16 @@ pub fn do_test(mut data: &[u8], logger: &Arc) { } } } + 35 => { + let config: ChannelConfig = + if let Ok(c) = Readable::read(&mut &*input) { c } else { return; }; + let chans = channelmanager.list_channels(); + if let Some(chan) = chans.get(0) { + let _ = channelmanager.update_channel_config( + &chan.counterparty.node_id, &[chan.channel_id], &config + ); + } + } _ => return, } loss_detector.handler.process_events();