Skip to content

Commit

Permalink
Merge pull request #422 from nuttycom/test_only_random_merklehashorchard
Browse files Browse the repository at this point in the history
Add a `MerkleHashOrchard::random` function under the `test-dependencies` feature.
  • Loading branch information
nuttycom authored Mar 12, 2024
2 parents 1db9741 + 7ef1fea commit a6b3407
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 a6b3407

Please sign in to comment.