-
Notifications
You must be signed in to change notification settings - Fork 973
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test: use concrete type for arbitrary strategy #3632
Conversation
ffs the tuple type does not work
... |
@mattsse the strategy is diff --git a/crates/storage/db/src/tables/utils.rs b/crates/storage/db/src/tables/utils.rs
index 93705555..7a5e9d5d 100644
--- a/crates/storage/db/src/tables/utils.rs
+++ b/crates/storage/db/src/tables/utils.rs
@@ -1,16 +1,15 @@
-//! Small database table utilities and helper functions
+//! Small database table utilities and helper functions.
+
use crate::{
table::{Decode, Decompress, Table},
DatabaseError,
};
-
use std::borrow::Cow;
+/// Implements the `Arbitrary` trait for types with fixed array types.
#[macro_export]
-/// Implements the `Arbitrary` trait for types with fixed array
-/// types.
macro_rules! impl_fixed_arbitrary {
- ($name:tt, $size:tt) => {
+ ($name:ident, $size:tt) => {
#[cfg(any(test, feature = "arbitrary"))]
use arbitrary::{Arbitrary, Unstructured};
@@ -19,22 +18,20 @@ macro_rules! impl_fixed_arbitrary {
fn arbitrary(u: &mut Unstructured<'a>) -> Result<Self, arbitrary::Error> {
let mut buffer = vec![0; $size];
u.fill_buffer(buffer.as_mut_slice())?;
-
Decode::decode(buffer).map_err(|_| arbitrary::Error::IncorrectFormat)
}
}
- #[cfg(any(test, feature = "arbitrary"))]
- use proptest::strategy::Strategy;
#[cfg(any(test, feature = "arbitrary"))]
impl proptest::prelude::Arbitrary for $name {
type Parameters = ();
type Strategy = proptest::strategy::Map<
- proptest::collection::VecStrategy<$name>,
- fn(<S as Strategy>::Value) -> T,
+ proptest::collection::VecStrategy<<u8 as proptest::arbitrary::Arbitrary>::Strategy>,
+ fn(Vec<u8>) -> Self,
>;
fn arbitrary_with(args: Self::Parameters) -> Self::Strategy {
+ use proptest::strategy::Strategy;
proptest::collection::vec(proptest::arbitrary::any_with::<u8>(args), $size)
.prop_map(move |vec| Decode::decode(vec).unwrap())
} |
sorry but idk what this means, can't follow. not sure how to interpret the diff |
It means I fixed it for you :) |
hehe, tysm for this champ! |
Codecov Report
... and 14 files with indirect coverage changes
Flags with carried forward coverage won't be shown. Click here to find out more.
|
get rid of boxed strategy
h/t @DaniPopes