From a2ed567ad42b237088c110ce12ce8212d5099da2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Bene=C5=A1?= Date: Tue, 22 Oct 2024 23:19:31 +0100 Subject: [PATCH] refactor: minor test cleanup (#9339) --- .../aztec-nr/aztec/src/encrypted_logs/payload.nr | 5 +---- noir-projects/aztec-nr/aztec/src/utils/point.nr | 11 ++--------- .../crates/types/src/utils/field.nr | 8 ++------ 3 files changed, 5 insertions(+), 19 deletions(-) diff --git a/noir-projects/aztec-nr/aztec/src/encrypted_logs/payload.nr b/noir-projects/aztec-nr/aztec/src/encrypted_logs/payload.nr index a34e62a1e8c..8b8577f980d 100644 --- a/noir-projects/aztec-nr/aztec/src/encrypted_logs/payload.nr +++ b/noir-projects/aztec-nr/aztec/src/encrypted_logs/payload.nr @@ -254,9 +254,6 @@ mod test { 127, 182, 227, 75, 192, 197, 54, 47, 168, 134, 233, 148, 251, 46, 86, 12, 73, 50, 238, 50, 31, 174, 27, 202, 110, 77, 161, 197, 244, 124, 17, 100, 143, 150, 232, 14, 156, 248, 43, 177, 16, 82, 244, 103, 88, 74, 84, 200, 15, 65, 187, 14, 163, 60, 91, 22, 104, 31, 211, 190, 124, 121, 79, 92, 239, 65, 185, 106, 51, 178, 168, 137, 84, 43, 79, 158, 151, 152, 83, 42, 170, 13, 106, 209, 254, 74, 39, 145, 73, 215, 17, 234, 196, 89, 30, 58, 120, 127, 88, 69, 121, 61, 18, 206, 89, 118, 243, 238, 177, 71, 73, 47, 147, 4, 155, 25, 173, 248, 206, 52, 17, 180, 122, 186, 106, 191, 252, 102, 197, 91, 16, 39, 94, 91, 224, 30, 168, 177, 26, 144, 5, 124, 128, 6 ]; - for i in 0..outgoing_body_ciphertext_from_typescript.len() { - assert_eq(ciphertext[i], outgoing_body_ciphertext_from_typescript[i]); - } - assert_eq(outgoing_body_ciphertext_from_typescript.len(), ciphertext.len()); + assert_eq(outgoing_body_ciphertext_from_typescript, ciphertext); } } diff --git a/noir-projects/aztec-nr/aztec/src/utils/point.nr b/noir-projects/aztec-nr/aztec/src/utils/point.nr index 40b555c5655..22fb675663c 100644 --- a/noir-projects/aztec-nr/aztec/src/utils/point.nr +++ b/noir-projects/aztec-nr/aztec/src/utils/point.nr @@ -47,11 +47,7 @@ mod test { let expected_compressed_point_positive_sign = [ 154, 244, 31, 93, 233, 100, 70, 220, 55, 118, 161, 235, 45, 152, 187, 149, 107, 122, 205, 153, 121, 166, 120, 84, 190, 198, 250, 124, 41, 115, 189, 115 ]; - - assert_eq(expected_compressed_point_positive_sign.len(), compressed_point.len()); - for i in 0..expected_compressed_point_positive_sign.len() { - assert_eq(compressed_point[i], expected_compressed_point_positive_sign[i]); - } + assert_eq(expected_compressed_point_positive_sign, compressed_point); } #[test] @@ -68,9 +64,6 @@ mod test { 36, 115, 113, 101, 46, 85, 221, 116, 201, 175, 141, 190, 159, 180, 73, 49, 186, 41, 169, 34, 153, 148, 56, 75, 215, 7, 119, 150, 193, 78, 226, 181 ]; - assert_eq(expected_compressed_point_negative_sign.len(), compressed_point.len()); - for i in 0..expected_compressed_point_negative_sign.len() { - assert_eq(compressed_point[i], expected_compressed_point_negative_sign[i]); - } + assert_eq(expected_compressed_point_negative_sign, compressed_point); } } diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/utils/field.nr b/noir-projects/noir-protocol-circuits/crates/types/src/utils/field.nr index 954ef602f82..d4115e5743d 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/utils/field.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/utils/field.nr @@ -52,9 +52,7 @@ unconstrained fn bytes_field_test() { ]; let field = field_from_bytes(inputs, true); let return_bytes: [u8; 31] = field.to_be_bytes(); - for i in 0..31 { - assert_eq(inputs[i], return_bytes[i]); - } + assert_eq(inputs, return_bytes); // 32 bytes - we remove the final byte, and check it matches the field let inputs2 = [ 84, 62, 10, 102, 66, 255, 235, 128, 57, 41, 104, 97, 118, 90, 83, 64, 123, 186, 98, 189, 28, 151, 202, 67, 55, 77, 233, 80, 187, 224, 167, 158 @@ -62,9 +60,7 @@ unconstrained fn bytes_field_test() { let field2 = field_from_bytes_32_trunc(inputs2); let return_bytes2: [u8; 31] = field.to_be_bytes(); - for i in 0..31 { - assert_eq(return_bytes2[i], return_bytes[i]); - } + assert_eq(return_bytes2, return_bytes); assert_eq(field2, field); }