diff --git a/units/src/weight.rs b/units/src/weight.rs index 4c8f1627b9..f3ab73cb21 100644 --- a/units/src/weight.rs +++ b/units/src/weight.rs @@ -8,6 +8,9 @@ use core::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Sub, SubAssign}; #[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; +#[cfg(feature = "arbitrary")] +use arbitrary::{Arbitrary, Unstructured}; + /// The factor that non-witness serialization data is multiplied by during weight calculation. pub const WITNESS_SCALE_FACTOR: usize = 4; @@ -204,6 +207,14 @@ impl<'a> core::iter::Sum<&'a Weight> for Weight { crate::impl_parse_str_from_int_infallible!(Weight, u64, from_wu); +#[cfg(feature = "arbitrary")] +impl<'a> Arbitrary<'a> for Weight { + fn arbitrary(u: &mut Unstructured<'a>) -> arbitrary::Result { + let w = u64::arbitrary(u)?; + Ok(Weight(w)) + } +} + #[cfg(test)] mod tests { use super::*;