From c2b7230af2fdd3cee76bb0d72b0943d6782c322e Mon Sep 17 00:00:00 2001 From: Tom French <15848336+TomAFrench@users.noreply.github.com> Date: Wed, 15 Feb 2023 16:12:42 +0000 Subject: [PATCH] fix: avoid testing equality between unit values in acir_gen test (#849) * 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 --------- Co-authored-by: Blaine Bublitz --- .../src/ssa/acir_gen/operations/sort.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/crates/noirc_evaluator/src/ssa/acir_gen/operations/sort.rs b/crates/noirc_evaluator/src/ssa/acir_gen/operations/sort.rs index 430d1180b6e..ff42c1307e8 100644 --- a/crates/noirc_evaluator/src/ssa/acir_gen/operations/sort.rs +++ b/crates/noirc_evaluator/src/ssa/acir_gen/operations/sort.rs @@ -20,7 +20,7 @@ pub fn evaluate_permutation( evaluator: &mut Evaluator, ) -> Vec { 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))); } @@ -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(); @@ -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); @@ -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)); } @@ -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); } } }