Impl Arbitrary for Bctv14Proof
use std::{fmt, io};
+#[cfg(test)]
+use proptest::{arbitrary::Arbitrary, collection::vec, prelude::*};
+
use crate::serialization::{SerializationError, ZcashDeserialize, ZcashSerialize};
/// An encoding of a BCTV14 proof, as used in Zcash.
@@ -47,3 +50,20 @@ impl ZcashDeserialize for Bctv14Proof {
Ok(Self(bytes))
}
}
+
+#[cfg(test)]
+impl Arbitrary for Bctv14Proof {
+ type Parameters = ();
+
+ fn arbitrary_with(_args: Self::Parameters) -> Self::Strategy {
+ (vec(any::<u8>(), 296))
+ .prop_map(|v| {
+ let mut bytes = [0; 296];
+ bytes.copy_from_slice(v.as_slice());
+ return Self(bytes);
+ })
+ .boxed()
+ }
+
+ type Strategy = BoxedStrategy<Self>;
+}
