Skip to content

Commit

Permalink
Add a MerkleHashOrchard::random function under the `test-dependenci…
Browse files Browse the repository at this point in the history
…es` feature.
  • Loading branch information
nuttycom committed Mar 12, 2024
1 parent 1db9741 commit 7ef1fea
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,22 @@ impl<'de> Deserialize<'de> for MerkleHashOrchard {
}
}

/// Test utilities available under the `test-dependencies` feature flag.
#[cfg(feature = "test-dependencies")]
pub mod testing {
use ff::Field;
use rand::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))
}
}
}

#[cfg(test)]
mod tests {
use {
Expand Down

0 comments on commit 7ef1fea

Please sign in to comment.