From 7aa06d25f280cb9063c851fb1e329dafb335a443 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Wed, 7 Feb 2024 02:27:22 +0000 Subject: [PATCH] [fuzz] Add fst coverage for `ChannelManager::update_channel_config` --- fuzz/src/full_stack.rs | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) 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(); -- 2.39.5