Skip to content

Commit

Permalink
Add UT for verify_metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
poszu committed Nov 3, 2023
1 parent aae130a commit 0ec52c1
Showing 1 changed file with 40 additions and 1 deletion.
41 changes: 40 additions & 1 deletion src/verification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ fn expected_indices_bytes(required_bits: usize, k2: u32) -> usize {

#[cfg(test)]
mod tests {
use std::borrow::Cow;
use std::{borrow::Cow};

use crate::{
config::{InitConfig, ProofConfig, ScryptParams},
Expand Down Expand Up @@ -384,4 +384,43 @@ mod tests {
));
}
}

#[test]
fn verify_metadata() {
let valid_meta = ProofMetadata {
node_id: [0; 32],
commitment_atx_id: [0; 32],
challenge: [0; 32],
num_units: 1,
labels_per_unit: 100,
};
let init_cfg = InitConfig {
min_num_units: 1,
max_num_units: 10,
labels_per_unit: 100,
scrypt: ScryptParams::new(2, 1, 1),
};
assert!(super::verify_metadata(&valid_meta, &init_cfg).is_ok());
{
let num_units_small = ProofMetadata {
num_units: 0,
..valid_meta
};
assert!(super::verify_metadata(&num_units_small, &init_cfg).is_err());
}
{
let num_units_large = ProofMetadata {
num_units: 99,
..valid_meta
};
assert!(super::verify_metadata(&num_units_large, &init_cfg).is_err());
}
{
let invalid_labels_per_unit = ProofMetadata {
labels_per_unit: 99,
..valid_meta
};
assert!(super::verify_metadata(&invalid_labels_per_unit, &init_cfg).is_err());
}
}
}

0 comments on commit 0ec52c1

Please sign in to comment.