From: Matt Corallo Date: Mon, 5 Aug 2024 23:39:37 +0000 (+0000) Subject: Don't depend on `bitcoinconsensus` in fuzzing X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=dd640ab4dc5672ceea6d0cae2bc47a3c62bff57b;p=rust-lightning Don't depend on `bitcoinconsensus` in fuzzing Its a bit annoying to deal with the C++ dependency in some fuzz build modes, and there's no reason for it, so we skip it here. --- diff --git a/lightning/Cargo.toml b/lightning/Cargo.toml index cf4a53294..4d17d0215 100644 --- a/lightning/Cargo.toml +++ b/lightning/Cargo.toml @@ -17,7 +17,7 @@ rustdoc-args = ["--cfg", "docsrs"] [features] # Internal test utilities exposed to other repo crates -_test_utils = ["regex", "bitcoin/bitcoinconsensus"] +_test_utils = ["regex"] # Unlog messages superior at targeted level. max_level_off = [] max_level_error = [] @@ -66,5 +66,9 @@ criterion = { version = "0.4", optional = true, default-features = false } [target.'cfg(taproot)'.dependencies] musig2 = { git = "https://github.com/arik-so/rust-musig2", rev = "739533fc" } +[target.'cfg(all(feature = "_test_utils", not(fuzzing)))'.dependencies.bitcoin] +version = "0.31.2" +features = ["bitcoinconsensus"] + [lints] workspace = true diff --git a/lightning/src/ln/functional_test_utils.rs b/lightning/src/ln/functional_test_utils.rs index 3af30a581..cad9b767c 100644 --- a/lightning/src/ln/functional_test_utils.rs +++ b/lightning/src/ln/functional_test_utils.rs @@ -1538,6 +1538,10 @@ pub fn do_check_spends Opti let min_fee = (tx.weight().to_wu() as u64 + 3) / 4; // One sat per vbyte (ie per weight/4, rounded up) // Input amount - output amount = fee, so check that out + min_fee is smaller than input assert!(total_value_out + min_fee <= total_value_in); + + // If we're fuzzing, we shouldn't ever get here, but transactions won't validate anyway (as + // we're not using valid signatures) so just skip the bitcoinconsensus step + #[cfg(not(fuzzing))] tx.verify(get_output).unwrap(); }