#[cfg(test)]
mod tests {
use midnight_storage::arena::{ArenaKey, TypedArenaKey};
use midnight_storage::{Storable, db::DB, storable::Loader};
#[cfg(feature = "proptest")]
use proptest::arbitrary::Arbitrary;
#[cfg(feature = "proptest")]
use rand::Rng;
use rand::distributions::Standard;
use rand::prelude::*;
use serialize::{Deserializable, Serializable, Tagged, tagged_deserialize};
#[cfg(feature = "proptest")]
use serialize::{NoStrategy, randomised_serialization_test, simple_arbitrary};
#[cfg(feature = "proptest")]
use std::marker::PhantomData;
#[derive(Debug, Clone, Hash, PartialOrd, PartialEq, Ord, Eq, Serializable, Storable)]
#[tag = "test-vec"]
#[storable(base)]
struct TestVec(std::vec::Vec<bool>);
#[cfg(feature = "proptest")]
simple_arbitrary!(TestVec);
impl Distribution<TestVec> for Standard {
fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> TestVec {
let len = rng.gen_range(0..16);
TestVec(rng.sample_iter(Standard).take(len).collect())
}
}
#[test]
fn arena_key_deserialization_error() {
let bytes: std::vec::Vec<u8> = vec![0u8; 20];
assert!(tagged_deserialize::<TypedArenaKey<TestVec, sha2::Sha256>>(&bytes[..],).is_err());
}
#[cfg(feature = "proptest")]
type SimpleArray = midnight_storage::storage::Array<u8>;
#[cfg(feature = "proptest")]
randomised_serialization_test!(SimpleArray);
#[cfg(feature = "proptest")]
type SimpleMap = midnight_storage::storage::Map<TestVec, u8>;
#[cfg(feature = "proptest")]
randomised_serialization_test!(SimpleMap);
#[cfg(feature = "proptest")]
type SimpleHashMap = midnight_storage::storage::HashMap<TestVec, u8>;
#[cfg(feature = "proptest")]
type SimpleHashSet = midnight_storage::storage::HashSet<u8>;
#[cfg(feature = "proptest")]
randomised_serialization_test!(SimpleHashMap);
#[cfg(feature = "proptest")]
randomised_serialization_test!(SimpleHashSet);
}