Ensure we build if a downstream crate sets `--cfg=fuzzing` 2023-06-fix-fuzz-dep
authorMatt Corallo <git@bluematt.me>
Tue, 20 Jun 2023 17:14:21 +0000 (17:14 +0000)
committerMatt Corallo <git@bluematt.me>
Tue, 20 Jun 2023 23:22:15 +0000 (23:22 +0000)
Downstream crates building fur fuzzing will usually set
`--cfg=fuzzing` as a side-effect of the Rust fuzzing tooling. Thus,
we should ensure we build without failure in such cases.

We do this here by simply relying on the `_test_utils` feature,
rather than conditionally-compiling in modules based on the
`fuzzing` flag.

lightning/src/chain/chainmonitor.rs
lightning/src/lib.rs
lightning/src/ln/channelmanager.rs
lightning/src/util/mod.rs
lightning/src/util/test_utils.rs

index 261e5593b5b4600ad661142a4579308b68903316..8ce59597d846b960d5bb11d843ace21b20d0ee53 100644 (file)
@@ -502,7 +502,7 @@ where C::Target: chain::Filter,
                self.event_notifier.notify();
        }
 
-       #[cfg(any(test, fuzzing, feature = "_test_utils"))]
+       #[cfg(any(test, feature = "_test_utils"))]
        pub fn get_and_clear_pending_events(&self) -> Vec<events::Event> {
                use crate::events::EventsProvider;
                let events = core::cell::RefCell::new(Vec::new());
index cea15b21ad2fba1b6f1937b030d59551bede682c..cf0a04aab081f458b586e1c9f87c0ab7cc305e55 100644 (file)
@@ -38,7 +38,7 @@
 //!     * `max_level_trace`
 
 #![cfg_attr(not(any(test, fuzzing, feature = "_test_utils")), deny(missing_docs))]
-#![cfg_attr(not(any(test, fuzzing, feature = "_test_utils")), forbid(unsafe_code))]
+#![cfg_attr(not(any(test, feature = "_test_utils")), forbid(unsafe_code))]
 
 // Prefix these with `rustdoc::` when we update our MSRV to be >= 1.52 to remove warnings.
 #![deny(broken_intra_doc_links)]
@@ -67,7 +67,7 @@ extern crate bitcoin;
 extern crate core;
 
 #[cfg(any(test, feature = "_test_utils"))] extern crate hex;
-#[cfg(any(test, fuzzing, feature = "_test_utils"))] extern crate regex;
+#[cfg(any(test, feature = "_test_utils"))] extern crate regex;
 
 #[cfg(not(feature = "std"))] extern crate core2;
 
index 595fad60ff2a321d773455c4a9cb54b8c4471bf8..7bcc75c01c3e1c8be16f758eeee763e8219c7eb4 100644 (file)
@@ -6171,7 +6171,7 @@ where
                inflight_htlcs
        }
 
-       #[cfg(any(test, fuzzing, feature = "_test_utils"))]
+       #[cfg(any(test, feature = "_test_utils"))]
        pub fn get_and_clear_pending_events(&self) -> Vec<events::Event> {
                let events = core::cell::RefCell::new(Vec::new());
                let event_handler = |event: events::Event| events.borrow_mut().push(event);
index 3dbf4f89634b9b2c7330f774b8f0bd624414dd2c..dd9d2744e1c7927ba82bab9244a355020b5d9660 100644 (file)
@@ -50,11 +50,11 @@ pub(crate) mod crypto;
 pub mod logger;
 pub mod config;
 
-#[cfg(any(test, fuzzing, feature = "_test_utils"))]
+#[cfg(any(test, feature = "_test_utils"))]
 pub mod test_utils;
 
 /// impls of traits that add exra enforcement on the way they're called. Useful for detecting state
 /// machine errors and used in fuzz targets and tests.
-#[cfg(any(test, fuzzing, feature = "_test_utils"))]
+#[cfg(any(test, feature = "_test_utils"))]
 pub mod enforcing_trait_impls;
 
index fe61e9c7214e25a8ad901f5242aea701e03950fe..24979036ee3ceb7ecb2fa24af1586ba2adaa35e8 100644 (file)
@@ -45,6 +45,7 @@ use bitcoin::secp256k1::{SecretKey, PublicKey, Secp256k1, ecdsa::Signature, Scal
 use bitcoin::secp256k1::ecdh::SharedSecret;
 use bitcoin::secp256k1::ecdsa::RecoverableSignature;
 
+#[cfg(any(test, feature = "_test_utils"))]
 use regex;
 
 use crate::io;
@@ -738,6 +739,7 @@ impl TestLogger {
        /// 1. belong to the specified module and
        /// 2. match the given regex pattern.
        /// Assert that the number of occurrences equals the given `count`
+       #[cfg(any(test, feature = "_test_utils"))]
        pub fn assert_log_regex(&self, module: &str, pattern: regex::Regex, count: usize) {
                let log_entries = self.lines.lock().unwrap();
                let l: usize = log_entries.iter().filter(|&(&(ref m, ref l), _c)| {