Skip to content

Commit

Permalink
Merge branch 'master' into dw/reactivate-completeness-nextest-config
Browse files Browse the repository at this point in the history
  • Loading branch information
dannywillems committed Jun 25, 2024
2 parents 3217f1d + 6be9834 commit 4d722f3
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .config/nextest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,4 @@ test-threads = "num-cpus"
filter = "test(completeness)"
threads-required = 2
# The CI is slower. On a consumer laptop, completeness tests take up to 3m.
slow-timeout = "5m"
slow-timeout = "5m"
5 changes: 1 addition & 4 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,7 @@ jobs:
# FIXME: update to 0.9.68 when we get rid of 1.71 and 1.72.
cargo install cargo-nextest@=0.9.67 --locked
# Completeness tests take a lot of CPU/RAM. It happened in the past that
# the CI was failing only on some of them, even though they were correct
# FIXME: run the completeness tests
- name: Test everything, except tests related to completeness
- name: Test everything
run: |
eval $(opam env)
cargo nextest run --all-features --release --profile ci
Expand Down
52 changes: 51 additions & 1 deletion msm/src/fec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ mod tests {
use ark_ec::AffineCurve;
use ark_ff::UniformRand;
use rand::{CryptoRng, RngCore};
use std::collections::BTreeMap;
use std::collections::{BTreeMap, HashMap};

type FECWitnessBuilderEnv = WitnessBuilderEnv<
Fp,
Expand Down Expand Up @@ -83,6 +83,56 @@ mod tests {
build_fec_addition_circuit(&mut rng, 1 << 4);
}

#[test]
pub fn test_regression_relation_constraints_fec() {
let mut constraint_env = ConstraintBuilderEnv::<Fp, LookupTable<Ff1>>::create();
constrain_ec_addition::<Fp, Ff1, _>(&mut constraint_env);
let constraints = constraint_env.get_relation_constraints();

let mut constraints_degrees = HashMap::new();

assert_eq!(constraints.len(), 24);

{
constraints.iter().for_each(|c| {
let degree = c.degree(1, 0);
*constraints_degrees.entry(degree).or_insert(0) += 1;
});

assert_eq!(constraints_degrees.get(&1), None);
assert_eq!(constraints_degrees.get(&2), Some(&3));
assert_eq!(constraints_degrees.get(&3), Some(&21));

assert!(constraints.iter().map(|c| c.degree(1, 0)).max() <= Some(3));
}
}

#[test]
pub fn test_regression_constraints_fec() {
let mut constraint_env = ConstraintBuilderEnv::<Fp, LookupTable<Ff1>>::create();
constrain_ec_addition::<Fp, Ff1, _>(&mut constraint_env);
let constraints = constraint_env.get_constraints();

let mut constraints_degrees = HashMap::new();

assert_eq!(constraints.len(), 63);

{
constraints.iter().for_each(|c| {
let degree = c.degree(1, 0);
*constraints_degrees.entry(degree).or_insert(0) += 1;
});

assert_eq!(constraints_degrees.get(&1), Some(&1));
assert_eq!(constraints_degrees.get(&2), Some(&5));
assert_eq!(constraints_degrees.get(&3), Some(&21));
assert_eq!(constraints_degrees.get(&4), None);
assert_eq!(constraints_degrees.get(&5), Some(&2));
assert_eq!(constraints_degrees.get(&6), None);
assert_eq!(constraints_degrees.get(&7), Some(&34));
}
}

#[test]
pub fn test_fec_completeness() {
let mut rng = o1_utils::tests::make_test_rng(None);
Expand Down

0 comments on commit 4d722f3

Please sign in to comment.