From 1b6c078942c5498d2740798e97049f8c8ff2dc27 Mon Sep 17 00:00:00 2001 From: Kris Nuttycombe Date: Sat, 16 Mar 2024 08:38:10 -0600 Subject: [PATCH] Add `impl Distribution for Standard` for testing. --- src/tree.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/tree.rs b/src/tree.rs index 806b057f3..352974672 100644 --- a/src/tree.rs +++ b/src/tree.rs @@ -264,14 +264,23 @@ impl<'de> Deserialize<'de> for MerkleHashOrchard { #[cfg(feature = "test-dependencies")] pub mod testing { use ff::Field; - use rand::RngCore; + use rand::{ + distributions::{Distribution, Standard}, + RngCore, + }; 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)) } } }