Add tests

This commit is contained in:
Remco Bloemen 2022-03-18 15:15:54 -07:00
parent a21ae33661
commit b33c2f1b4b
2 changed files with 16 additions and 6 deletions

View File

@ -1,6 +1,6 @@
use crate::util::{bytes_from_hex, bytes_to_hex, deserialize_bytes, serialize_bytes};
use core::{
fmt::{Debug, Display, Formatter, Result as FmtResult},
fmt::{Debug, Display},
str,
str::FromStr,
};

View File

@ -113,7 +113,7 @@ pub fn generate_proof(
values.iter().copied().map(Into::into).collect::<Vec<_>>(),
)
});
let now = Instant::now();
let full_assignment = WITNESS_CALCULATOR
@ -178,8 +178,7 @@ mod test {
use super::*;
use crate::{hash_to_field, poseidon_tree::PoseidonTree};
#[test]
fn test_proof_serialize() {
fn arb_proof() -> Proof {
// generate identity
let id = Identity::from_seed(b"secret");
@ -194,9 +193,20 @@ mod test {
let signal_hash = hash_to_field(b"xxx");
let external_nullifier_hash = hash_to_field(b"appId");
let proof =
generate_proof(&id, &merkle_proof, external_nullifier_hash, signal_hash).unwrap();
generate_proof(&id, &merkle_proof, external_nullifier_hash, signal_hash).unwrap()
}
#[test]
fn test_proof_cast_roundtrip() {
let proof = arb_proof();
let ark_proof: ArkProof<Bn<Parameters>> = proof.into();
let result: Proof = ark_proof.into();
assert_eq!(proof, result);
}
#[test]
fn test_proof_serialize() {
let proof = arb_proof();
let _json = serde_json::to_value(&proof).unwrap();
// TODO: Ideally we would check the output against an expected value,