diff --git a/Cargo.lock b/Cargo.lock index 24ec4eb9d831..e191b69ebf53 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7097,6 +7097,7 @@ dependencies = [ "reth-codecs", "reth-primitives-traits", "serde", + "test-fuzz", ] [[package]] @@ -7641,6 +7642,7 @@ dependencies = [ "reth-primitives-traits", "reth-zstd-compressors", "serde", + "test-fuzz", ] [[package]] @@ -8762,6 +8764,7 @@ dependencies = [ "serde", "serde_json", "serde_with", + "test-fuzz", ] [[package]] @@ -8789,6 +8792,7 @@ dependencies = [ "serde", "serde_json", "serde_with", + "test-fuzz", ] [[package]] @@ -8887,6 +8891,7 @@ dependencies = [ "reth-codecs", "serde", "serde_json", + "test-fuzz", "thiserror 2.0.5", "toml", ] @@ -9340,6 +9345,7 @@ dependencies = [ "reth-codecs", "reth-trie-common", "serde", + "test-fuzz", ] [[package]] diff --git a/crates/ethereum/primitives/Cargo.toml b/crates/ethereum/primitives/Cargo.toml index 61f9f0672cfa..15190219cae8 100644 --- a/crates/ethereum/primitives/Cargo.toml +++ b/crates/ethereum/primitives/Cargo.toml @@ -28,7 +28,7 @@ modular-bitfield = { workspace = true, optional = true } serde.workspace = true [dev-dependencies] -reth-codecs = { workspace = true, features = ["test-utils"] } +test-fuzz.workspace = true [features] default = ["std"] diff --git a/crates/primitives-traits/Cargo.toml b/crates/primitives-traits/Cargo.toml index 9c4be07fd7da..459fdbde1a70 100644 --- a/crates/primitives-traits/Cargo.toml +++ b/crates/primitives-traits/Cargo.toml @@ -51,6 +51,7 @@ proptest-arbitrary-interop.workspace = true proptest.workspace = true rand.workspace = true serde_json.workspace = true +test-fuzz.workspace = true modular-bitfield.workspace = true serde.workspace = true diff --git a/crates/primitives/Cargo.toml b/crates/primitives/Cargo.toml index 7fb4b783cb0e..109b20ec2bcc 100644 --- a/crates/primitives/Cargo.toml +++ b/crates/primitives/Cargo.toml @@ -79,6 +79,7 @@ proptest-arbitrary-interop.workspace = true proptest.workspace = true rand.workspace = true serde_json.workspace = true +test-fuzz.workspace = true rstest.workspace = true criterion.workspace = true diff --git a/crates/prune/types/Cargo.toml b/crates/prune/types/Cargo.toml index 7477124caf84..75093511310d 100644 --- a/crates/prune/types/Cargo.toml +++ b/crates/prune/types/Cargo.toml @@ -27,6 +27,7 @@ assert_matches.workspace = true proptest.workspace = true proptest-arbitrary-interop.workspace = true serde_json.workspace = true +test-fuzz.workspace = true toml.workspace = true [features] diff --git a/crates/stages/types/Cargo.toml b/crates/stages/types/Cargo.toml index 8927ec2955ec..0243415942b5 100644 --- a/crates/stages/types/Cargo.toml +++ b/crates/stages/types/Cargo.toml @@ -29,6 +29,7 @@ arbitrary = { workspace = true, features = ["derive"] } modular-bitfield.workspace = true proptest.workspace = true proptest-arbitrary-interop.workspace = true +test-fuzz.workspace = true rand.workspace = true bytes.workspace = true diff --git a/crates/storage/codecs/Cargo.toml b/crates/storage/codecs/Cargo.toml index cfb54691bac4..6fd0764c22ad 100644 --- a/crates/storage/codecs/Cargo.toml +++ b/crates/storage/codecs/Cargo.toml @@ -30,7 +30,6 @@ modular-bitfield.workspace = true visibility = { version = "0.1.1", optional = true} serde.workspace = true arbitrary = { workspace = true, features = ["derive"], optional = true } -test-fuzz = { workspace = true, optional = true} [dev-dependencies] alloy-eips = { workspace = true, default-features = false, features = [ @@ -46,6 +45,7 @@ alloy-consensus = { workspace = true, features = ["arbitrary"] } serde_json.workspace = true arbitrary = { workspace = true, features = ["derive"] } +test-fuzz.workspace = true proptest.workspace = true proptest-arbitrary-interop.workspace = true rstest.workspace = true @@ -74,7 +74,6 @@ test-utils = [ "arbitrary", "dep:visibility", "dep:arbitrary", - "dep:test-fuzz" ] serde = [ "alloy-consensus?/serde", diff --git a/crates/storage/codecs/derive/src/compact/generator.rs b/crates/storage/codecs/derive/src/compact/generator.rs index 4537a267a7d4..a84913f59e81 100644 --- a/crates/storage/codecs/derive/src/compact/generator.rs +++ b/crates/storage/codecs/derive/src/compact/generator.rs @@ -55,25 +55,20 @@ pub fn generate_from_to( } else { quote! { #[cfg(test)] - mod #test { - use super::*; - use #reth_codecs::__private::test_fuzz; - - #[allow(dead_code)] - #[test_fuzz::test_fuzz] - fn #fuzz(obj: #ident) { - use #reth_codecs::Compact; - let mut buf = vec![]; - let len = obj.clone().to_compact(&mut buf); - let (same_obj, buf) = #ident::from_compact(buf.as_ref(), len); - assert_eq!(obj, same_obj); - } + #[allow(dead_code)] + #[test_fuzz::test_fuzz] + fn #fuzz(obj: #ident) { + use #reth_codecs::Compact; + let mut buf = vec![]; + let len = obj.clone().to_compact(&mut buf); + let (same_obj, buf) = #ident::from_compact(buf.as_ref(), len); + assert_eq!(obj, same_obj); + } - #[test] - #[allow(missing_docs)] - pub fn #test() { - #fuzz(#ident::default()) - } + #[test] + #[allow(missing_docs)] + pub fn #test() { + #fuzz(#ident::default()) } } }; diff --git a/crates/storage/codecs/derive/src/compact/mod.rs b/crates/storage/codecs/derive/src/compact/mod.rs index e91bbed5aef4..ab9ed78e164e 100644 --- a/crates/storage/codecs/derive/src/compact/mod.rs +++ b/crates/storage/codecs/derive/src/compact/mod.rs @@ -284,29 +284,21 @@ mod tests { } } } - #[cfg(test)] - mod fuzz_test_struct { - use super::*; - use reth_codecs::__private::test_fuzz; - - #[allow(dead_code)] - #[test_fuzz::test_fuzz] - fn fuzz_test_test_struct(obj: TestStruct) { - use reth_codecs::Compact; - let mut buf = vec![]; - let len = obj.clone().to_compact(&mut buf); - let (same_obj, buf) = TestStruct::from_compact(buf.as_ref(), len); - assert_eq!(obj, same_obj); - } - - #[test] - #[allow(missing_docs)] - pub fn fuzz_test_struct() { - fuzz_test_test_struct(TestStruct::default()) - } + #[allow(dead_code)] + #[test_fuzz::test_fuzz] + fn fuzz_test_test_struct(obj: TestStruct) { + use reth_codecs::Compact; + let mut buf = vec![]; + let len = obj.clone().to_compact(&mut buf); + let (same_obj, buf) = TestStruct::from_compact(buf.as_ref(), len); + assert_eq!(obj, same_obj); + } + #[test] + #[allow(missing_docs)] + pub fn fuzz_test_struct() { + fuzz_test_test_struct(TestStruct::default()) } - impl reth_codecs::Compact for TestStruct { fn to_compact(&self, buf: &mut B) -> usize where B: reth_codecs::__private::bytes::BufMut + AsMut<[u8]> { let mut flags = TestStructFlags::default(); diff --git a/crates/storage/codecs/src/private.rs b/crates/storage/codecs/src/private.rs index 0729fd5e30aa..440310ffd3df 100644 --- a/crates/storage/codecs/src/private.rs +++ b/crates/storage/codecs/src/private.rs @@ -1,6 +1,3 @@ pub use modular_bitfield; pub use bytes::{self, Buf}; - -#[cfg(feature = "test-utils")] -pub use test_fuzz; diff --git a/crates/storage/db-models/Cargo.toml b/crates/storage/db-models/Cargo.toml index fd37231283bd..0997c08b784d 100644 --- a/crates/storage/db-models/Cargo.toml +++ b/crates/storage/db-models/Cargo.toml @@ -39,6 +39,7 @@ arbitrary = { workspace = true, features = ["derive"] } proptest.workspace = true proptest-arbitrary-interop.workspace = true +test-fuzz.workspace = true [features] test-utils = [