Skip to content

Commit

Permalink
revert test-fuzz changes
Browse files Browse the repository at this point in the history
  • Loading branch information
klkvr committed Dec 11, 2024
1 parent 4247631 commit 558ae8b
Show file tree
Hide file tree
Showing 11 changed files with 39 additions and 45 deletions.
6 changes: 6 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/ethereum/primitives/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
1 change: 1 addition & 0 deletions crates/primitives-traits/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions crates/primitives/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions crates/prune/types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
1 change: 1 addition & 0 deletions crates/stages/types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 1 addition & 2 deletions crates/storage/codecs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand All @@ -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
Expand Down Expand Up @@ -74,7 +74,6 @@ test-utils = [
"arbitrary",
"dep:visibility",
"dep:arbitrary",
"dep:test-fuzz"
]
serde = [
"alloy-consensus?/serde",
Expand Down
31 changes: 13 additions & 18 deletions crates/storage/codecs/derive/src/compact/generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
}
};
Expand Down
34 changes: 13 additions & 21 deletions crates/storage/codecs/derive/src/compact/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<B>(&self, buf: &mut B) -> usize where B: reth_codecs::__private::bytes::BufMut + AsMut<[u8]> {
let mut flags = TestStructFlags::default();
Expand Down
3 changes: 0 additions & 3 deletions crates/storage/codecs/src/private.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
pub use modular_bitfield;

pub use bytes::{self, Buf};

#[cfg(feature = "test-utils")]
pub use test_fuzz;
1 change: 1 addition & 0 deletions crates/storage/db-models/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ arbitrary = { workspace = true, features = ["derive"] }

proptest.workspace = true
proptest-arbitrary-interop.workspace = true
test-fuzz.workspace = true

[features]
test-utils = [
Expand Down

0 comments on commit 558ae8b

Please sign in to comment.