mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 19:09:54 +00:00
chore: remove proptest arbitrary from codec derive and tests (#8968)
This commit is contained in:
@ -15,7 +15,7 @@ workspace = true
|
||||
reth-codecs-derive = { path = "./derive", default-features = false }
|
||||
|
||||
# eth
|
||||
alloy-consensus = { workspace = true, optional = true }
|
||||
alloy-consensus = { workspace = true, optional = true, features = ["arbitrary"] }
|
||||
alloy-eips = { workspace = true, optional = true }
|
||||
alloy-genesis = { workspace = true, optional = true }
|
||||
alloy-primitives.workspace = true
|
||||
@ -37,6 +37,7 @@ serde_json.workspace = true
|
||||
arbitrary = { workspace = true, features = ["derive"] }
|
||||
proptest.workspace = true
|
||||
proptest-derive.workspace = true
|
||||
proptest-arbitrary-interop.workspace = true
|
||||
|
||||
[features]
|
||||
default = ["std", "alloy"]
|
||||
|
||||
@ -87,12 +87,13 @@ pub fn maybe_generate_tests(args: TokenStream, ast: &DeriveInput) -> TokenStream
|
||||
#[cfg(test)]
|
||||
mod #mod_tests {
|
||||
#(#traits)*
|
||||
use proptest_arbitrary_interop::arb;
|
||||
|
||||
#[test]
|
||||
fn proptest() {
|
||||
let mut config = proptest::prelude::ProptestConfig::with_cases(#default_cases as u32);
|
||||
|
||||
proptest::proptest!(config, |(field: super::#type_ident)| {
|
||||
proptest::proptest!(config, |(field in arb::<super::#type_ident>())| {
|
||||
#(#roundtrips)*
|
||||
});
|
||||
}
|
||||
|
||||
@ -69,7 +69,7 @@ pub fn main_codec(args: TokenStream, input: TokenStream) -> TokenStream {
|
||||
derive_arbitrary(TokenStream::from_iter(args), compact)
|
||||
}
|
||||
|
||||
/// Adds `Arbitrary` and `proptest::Arbitrary` imports into scope and derives the struct/enum.
|
||||
/// Adds `Arbitrary` imports into scope and derives the struct/enum.
|
||||
///
|
||||
/// If `compact` or `rlp` is passed to `derive_arbitrary`, there will be proptest roundtrip tests
|
||||
/// generated. An integer value passed will limit the number of proptest cases generated (default:
|
||||
@ -89,17 +89,13 @@ pub fn derive_arbitrary(args: TokenStream, input: TokenStream) -> TokenStream {
|
||||
let tests = arbitrary::maybe_generate_tests(args, &ast);
|
||||
|
||||
// Avoid duplicate names
|
||||
let prop_import = format_ident!("{}PropTestArbitrary", ast.ident);
|
||||
let arb_import = format_ident!("{}Arbitrary", ast.ident);
|
||||
|
||||
quote! {
|
||||
#[cfg(any(test, feature = "arbitrary"))]
|
||||
use proptest_derive::Arbitrary as #prop_import;
|
||||
|
||||
#[cfg(any(test, feature = "arbitrary"))]
|
||||
use arbitrary::Arbitrary as #arb_import;
|
||||
|
||||
#[cfg_attr(any(test, feature = "arbitrary"), derive(#prop_import, #arb_import))]
|
||||
#[cfg_attr(any(test, feature = "arbitrary"), derive(#arb_import))]
|
||||
#ast
|
||||
|
||||
#tests
|
||||
|
||||
@ -26,10 +26,11 @@ impl Compact for Request {
|
||||
mod tests {
|
||||
use super::*;
|
||||
use proptest::proptest;
|
||||
use proptest_arbitrary_interop::arb;
|
||||
|
||||
proptest! {
|
||||
#[test]
|
||||
fn roundtrip(request: Request) {
|
||||
fn roundtrip(request in arb::<Request>()) {
|
||||
let mut buf = Vec::<u8>::new();
|
||||
request.to_compact(&mut buf);
|
||||
let (decoded, _) = Request::from_compact(&buf, buf.len());
|
||||
|
||||
@ -36,7 +36,6 @@ bytes.workspace = true
|
||||
# arbitrary utils
|
||||
arbitrary = { workspace = true, features = ["derive"], optional = true }
|
||||
proptest = { workspace = true, optional = true }
|
||||
proptest-derive = { workspace = true, optional = true }
|
||||
|
||||
[dev-dependencies]
|
||||
# reth libs with arbitrary
|
||||
@ -58,6 +57,7 @@ iai-callgrind.workspace = true
|
||||
|
||||
arbitrary = { workspace = true, features = ["derive"] }
|
||||
proptest.workspace = true
|
||||
proptest-arbitrary-interop.workspace = true
|
||||
proptest-derive.workspace = true
|
||||
|
||||
paste.workspace = true
|
||||
@ -70,6 +70,5 @@ arbitrary = [
|
||||
"reth-primitives/arbitrary",
|
||||
"dep:arbitrary",
|
||||
"dep:proptest",
|
||||
"dep:proptest-derive",
|
||||
]
|
||||
optimism = []
|
||||
|
||||
Reference in New Issue
Block a user