mirror of https://github.com/zcash/orchard.git
Add `impl Distribution<MerkleHashOrchard> for Standard` for testing.
This commit is contained in:
parent
e74879dd0a
commit
1b6c078942
13
src/tree.rs
13
src/tree.rs
|
@ -264,14 +264,23 @@ impl<'de> Deserialize<'de> for MerkleHashOrchard {
|
||||||
#[cfg(feature = "test-dependencies")]
|
#[cfg(feature = "test-dependencies")]
|
||||||
pub mod testing {
|
pub mod testing {
|
||||||
use ff::Field;
|
use ff::Field;
|
||||||
use rand::RngCore;
|
use rand::{
|
||||||
|
distributions::{Distribution, Standard},
|
||||||
|
RngCore,
|
||||||
|
};
|
||||||
|
|
||||||
use super::MerkleHashOrchard;
|
use super::MerkleHashOrchard;
|
||||||
|
|
||||||
impl MerkleHashOrchard {
|
impl MerkleHashOrchard {
|
||||||
/// Return a random fake `MerkleHashOrchard`.
|
/// Return a random fake `MerkleHashOrchard`.
|
||||||
pub fn random(rng: &mut impl RngCore) -> Self {
|
pub fn random(rng: &mut impl RngCore) -> Self {
|
||||||
Self(pasta_curves::Fp::random(rng))
|
Standard.sample(rng)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Distribution<MerkleHashOrchard> for Standard {
|
||||||
|
fn sample<R: rand::Rng + ?Sized>(&self, rng: &mut R) -> MerkleHashOrchard {
|
||||||
|
MerkleHashOrchard(pasta_curves::Fp::random(rng))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue