Skip to content

Commit

Permalink
adds sample tests
Browse files Browse the repository at this point in the history
  • Loading branch information
supinie committed Apr 16, 2024
1 parent 4cf44b6 commit 218b94d
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ mod tests {
mod indcpa;
// mod matrix;
mod ntt;
mod sample;
mod params;
mod polynomials;
// mod sample;
mod vectors;
}
1 change: 1 addition & 0 deletions src/tests/indcpa.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(warnings)]
#[cfg(test)]
mod indcpa_tests {
use crate::{
Expand Down
35 changes: 35 additions & 0 deletions src/tests/sample.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#![allow(warnings)]
#[cfg(test)]

pub(in crate::tests) mod sample_tests {
use crate::{
polynomials::*,
params::*,
tests::{
polynomials::poly_tests::*,
params::params_tests::sec_level_strategy,
},
};
use proptest::prelude::*;

proptest! {
#[test]
fn derive_noise_test(
seed in prop::array::uniform32(u8::MIN..u8::MAX),
nonce in (u8::MIN..u8::MAX),
sec_level in sec_level_strategy(),
) {
let poly_1 = Poly::derive_noise(&seed, nonce, sec_level.eta_1());
let poly_2 = Poly::derive_noise(&seed, nonce, sec_level.eta_2());
}

#[test]
fn derive_uniform_test(
seed in prop::array::uniform32(u8::MIN..u8::MAX),
x in (u8::MIN..u8::MAX),
y in (u8::MIN..u8::MAX),
) {
let poly = Poly::derive_uniform(&seed, x, y).unwrap();
}
}
}
2 changes: 1 addition & 1 deletion src/vectors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ impl PolyVec<Normalised> {
.into());
}

let _ = buf
buf
.chunks_mut(self.sec_level().poly_compressed_bytes())
.zip(self.polynomials.iter())
.for_each(|(buf_chunk, poly)| { let _ = poly.compress(buf_chunk, &self.sec_level()); } );
Expand Down

0 comments on commit 218b94d

Please sign in to comment.