Skip to content

Commit

Permalink
fix: avoid testing equality between unit values in acir_gen test (#849)
Browse files Browse the repository at this point in the history
* fix: avoid testing equality between unit values

`a_val.sort()` returns `()` so this equality will always succeed

* chore: apply spellcheck fixes in sort.rs

* Update crates/noirc_evaluator/src/ssa/acir_gen/operations/sort.rs

Co-authored-by: Blaine Bublitz <blaine.bublitz@gmail.com>

---------

Co-authored-by: Blaine Bublitz <blaine.bublitz@gmail.com>
  • Loading branch information
TomAFrench and phated authored Feb 15, 2023
1 parent e298429 commit c2b7230
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions crates/noirc_evaluator/src/ssa/acir_gen/operations/sort.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub fn evaluate_permutation(
evaluator: &mut Evaluator,
) -> Vec<Witness> {
let (w, b) = permutation_layer(in_expr, evaluator);
// we contrain the network output to out_expr
// we constrain the network output to out_expr
for (b, o) in b.iter().zip(out_expr) {
evaluator.opcodes.push(AcirOpcode::Arithmetic(subtract(b, FieldElement::one(), o)));
}
Expand All @@ -45,7 +45,7 @@ pub fn permutation_layer(
conf.push(evaluator.add_witness_to_cs());
}
// compute expressions after the input switches
// If inputs are a1,a2, and the switch value is c, then we compute expresions b1,b2 where
// If inputs are a1,a2, and the switch value is c, then we compute expressions b1,b2 where
// b1 = a1+q, b2 = a2-q, q = c(a2-a1)
let mut in_sub1 = Vec::new();
let mut in_sub2 = Vec::new();
Expand All @@ -68,7 +68,7 @@ pub fn permutation_layer(
// compute results for the sub networks
let (w1, b1) = permutation_layer(&in_sub1, evaluator);
let (w2, b2) = permutation_layer(&in_sub2, evaluator);
// apply the output swithces
// apply the output switches
for i in 0..(n - 1) / 2 {
let c = evaluator.add_witness_to_cs();
conf.push(c);
Expand Down Expand Up @@ -152,7 +152,7 @@ mod test {
for _i in 0..w.len() {
c.push(rng.next_u32() % 2 != 0);
}
// intialise bits
// initialize bits
for i in 0..w.len() {
solved_witness.insert(w[i], FieldElement::from(c[i] as i128));
}
Expand All @@ -166,7 +166,9 @@ mod test {
b_val.push(solved_witness[&b_wit[i]]);
}
// ensure the outputs are a permutation of the inputs
assert_eq!(a_val.sort(), b_val.sort());
a_val.sort();
b_val.sort();
assert_eq!(a_val, b_val);
}
}
}

0 comments on commit c2b7230

Please sign in to comment.