diff --git a/src/tree.rs b/src/tree.rs index 806b057f3..15ca745ce 100644 --- a/src/tree.rs +++ b/src/tree.rs @@ -264,14 +264,20 @@ impl<'de> Deserialize<'de> for MerkleHashOrchard { #[cfg(feature = "test-dependencies")] pub mod testing { use ff::Field; - use rand::RngCore; + use rand::{RngCore, distributions::{Standard, Distribution}}; use super::MerkleHashOrchard; impl MerkleHashOrchard { /// Return a random fake `MerkleHashOrchard`. pub fn random(rng: &mut impl RngCore) -> Self { - Self(pasta_curves::Fp::random(rng)) + Standard.sample(rng) + } + } + + impl Distribution for Standard { + fn sample(&self, rng: &mut R) -> MerkleHashOrchard { + MerkleHashOrchard(pasta_curves::Fp::random(rng)) } } }