Skip to content

Commit

Permalink
chore: Perform formatting changes to integration tests (#2448)
Browse files Browse the repository at this point in the history
  • Loading branch information
TomAFrench authored Aug 25, 2023
1 parent fd69cd2 commit 168e0db
Show file tree
Hide file tree
Showing 53 changed files with 42 additions and 99 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ fn main(x: Field) {
unconstrained fn conditional(x : bool) -> Field {
assert(x);
1
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ unconstrained fn main() {
assert(be_bit == le_bit);
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,4 @@ fn main() {
let y: u32 = 30;
let z: u64 = 40;
assert(accepts_closure3(|| y as u64 + z) == 70);
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

fn main() {
let unsorted: [u8; 3] = [3,1,2];
let sorted = unsorted.sort();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use dep::std;

fn g(x: &mut Field) -> () {
*x *= 2;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use dep::std;

fn f(x: Field) -> Field {
x + 1
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use dep::std;

fn main() {
let field = 1000;
Expand All @@ -21,4 +20,4 @@ fn main() {
assert(be_bit == le_bit);
}

}
}
8 changes: 4 additions & 4 deletions crates/nargo_cli/tests/execution_success/6_array/src/main.nr
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ fn main(x: [u32; 5], y: [u32; 5], mut z: u32, t: u32) {
c = z*z*y[i];
z -= c;
}
assert(z==0); //y[4]=0, so c and z are always 0
assert(z == 0); //y[4]=0, so c and z are always 0

//Test 2:
c = 2301 as u32;
Expand All @@ -16,7 +16,7 @@ fn main(x: [u32; 5], y: [u32; 5], mut z: u32, t: u32) {
c = z*z*x[i];
z += x[i]*y[i] - c;
}
assert(z==3814912846);
assert(z == 3814912846);

//Test 3:
c = 2300001 as u32;
Expand All @@ -28,7 +28,7 @@ fn main(x: [u32; 5], y: [u32; 5], mut z: u32, t: u32) {
z *= c;
}
}
assert(z==41472);
assert(z == 41472);

//Test 4:
z = y[4];
Expand All @@ -38,7 +38,7 @@ fn main(x: [u32; 5], y: [u32; 5], mut z: u32, t: u32) {
z += x[i+j] - y[i+j];
}
}
assert(z ==11539);
assert(z == 11539);

//Test 5:
let cc = if z < 1 { x } else { y };
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
//Tests for function calling
use dep::std;

fn f1(mut x: Field) -> Field {
x = x + 1;
x = f2(x);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,5 +279,5 @@ fn main(a: [u32; 100], b: [u32; 100], c: [u32; 4], mut d: [u32; 4], m: [u8; 32])
sha_hash = iterate3(sha_hash);

let h6 = test6(m);
assert(h6[0]== 523008072); //31.. 3800709683
assert(h6[0] == 523008072); //31.. 3800709683
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ fn main(a: u32, mut c: [u32; 4], x: [u8; 5], result: pub [u8; 32]){
}
}
}
assert(c1==1);
assert(c1 == 1);

//Regression for Issue #579
let result1_true = test(true);
Expand Down Expand Up @@ -143,7 +143,7 @@ fn main(a: u32, mut c: [u32; 4], x: [u8; 5], result: pub [u8; 32]){
}
assert(y == result[0]);
c = sort(c);
assert(c[0]==0);
assert(c[0] == 0);

//test 1
let mut x: u32 = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ fn dyn_array(mut x: [u32; 5], y: Field, z: Field) {
x[y] = 0;
}
assert(x[4] == 109);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use dep::std;

fn len_plus_1<T, N>(array: [T; N]) -> Field {
array.len() + 1
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
// The features being tested is assertion
fn main(x : Field, y : Field) {
assert(x == y);
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use dep::std;
fn main(x: u1) {
assert(!x == 0);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use dep::std;
fn main(x: u1, y: u1) {
assert(x | y == 1);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ fn main(x: Field) {
unconstrained fn conditional(x : bool) -> Field {
assert(x);
1
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ unconstrained fn another_entry_point(x: [u32; 3]) {
assert(x[0] == 1);
assert(x[1] == 2);
assert(x[2] == 3);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ unconstrained fn conditional(x : bool) -> Field {
}else {
5
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ fn main(hashed_message : [u8;32], pub_key_x : [u8;32], pub_key_y : [u8;32], sign

unconstrained fn ecdsa(hashed_message : [u8;32], pub_key_x : [u8;32], pub_key_y : [u8;32], signature : [u8;64]) -> bool {
std::ecdsa_secp256k1::verify_signature(pub_key_x, pub_key_y, signature, hashed_message)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ unconstrained fn wrapper_with_struct(my_struct: MyStruct, param: u32) -> u32 {
func(param)
}



fn increment_acir(x: u32) -> u32 {
x + 1
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use dep::std;

struct myStruct {
foo: Field,
foo_arr: [Field; 2],
Expand Down Expand Up @@ -32,4 +30,4 @@ unconstrained fn identity_array(arr : [Field; 2]) -> [Field; 2] {

unconstrained fn identity_struct(s : myStruct) -> myStruct {
s
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ fn main(x: Field, result: [u8; 32]) {

unconstrained fn keccak256<N>(data: [u8; N], msg_len: u32) -> [u8; 32] {
std::hash::keccak256(data, msg_len)
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
use dep::std::slice;
use dep::std;

// Tests nested slice passing to/from functions
unconstrained fn push_back_to_slice<T>(slice: [T], item: T) -> [T] {
slice.push_back(item)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ fn main(x: Field, y : Field) {

unconstrained fn not_operator(x : bool) -> bool {
!x
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
use dep::std::slice;
use dep::std;

unconstrained fn main(x: Field, y: Field) {
let mut slice: [Field] = [y, x];
assert(slice.len() == 2);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use dep::std;

unconstrained fn main(x : Field) -> pub [u8; 31] {
// The result of this byte array will be big-endian
let byte_array = x.to_be_bytes(31);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ unconstrained fn main(x : Field, _y: Field) {
assert(p_bits[100] == z_bits[100]);

_y.to_le_bits(std::field::modulus_num_bits() as u32);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use dep::std;

unconstrained fn main(x : Field) -> pub [u8; 31] {
// The result of this byte array will be little-endian
let byte_array = x.to_le_bytes(31);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use dep::std;

fn main(mut x: Field) {
let one = 1;
let add1 = |z| {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
use dep::std;


fn main(message : [u8;38],hashed_message : [u8;32], pub_key_x : [u8;32], pub_key_y : [u8;32], signature : [u8;64]) {
// Hash the message, since secp256k1 expects a hashed_message
let expected= std::hash::sha256(message);
assert(hashed_message == expected);

let valid_signature = std::ecdsa_secp256k1::verify_signature(pub_key_x, pub_key_y, signature, hashed_message);
assert(valid_signature);
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use dep::std;


fn main(hashed_message : [u8;32], pub_key_x : [u8;32], pub_key_y : [u8;32], signature : [u8;64]) {
let valid_signature = std::ecdsa_secp256r1::verify_signature(pub_key_x, pub_key_y, signature, hashed_message);
assert(valid_signature);
}
}
4 changes: 1 addition & 3 deletions crates/nargo_cli/tests/execution_success/eddsa/src/main.nr
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ use dep::std::compat;
use dep::std::ec::consts::te::baby_jubjub;
use dep::std::hash;
use dep::std::eddsa::eddsa_poseidon_verify;
use dep::std;

fn main(msg: pub Field, _priv_key_a: Field, _priv_key_b: Field) {
// Skip this test for non-bn254 backends
if compat::is_bn254() {
Expand Down Expand Up @@ -52,4 +50,4 @@ fn main(msg: pub Field, _priv_key_a: Field, _priv_key_b: Field) {
// User A's signature over the message can't be used with another message
assert(!eddsa_poseidon_verify(pub_key_a.x, pub_key_a.y, s_a, r8_a.x, r8_a.y, msg + 1));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ fn from_baz(x : [Field; crate::foo::MAGIC_NUMBER]) {
for i in 0..crate::foo::MAGIC_NUMBER {
assert(x[i] == crate::foo::MAGIC_NUMBER);
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ fn from_foo(x : [Field; bar::N]) {
for i in 0..bar::N {
assert(x[i] == bar::N);
};
}
}
22 changes: 10 additions & 12 deletions crates/nargo_cli/tests/execution_success/global_consts/src/main.nr
Original file line number Diff line number Diff line change
Expand Up @@ -78,18 +78,16 @@ fn arrays_neq(a: [Field; M], b: [Field; M]) {
}

mod mysubmodule {
use dep::std;
global N: Field = 10;
global L: Field = 50;

global N: Field = 10;
global L: Field = 50;

fn my_bool_or(x: u1, y: u1) {
assert(x | y == 1);
}
fn my_bool_or(x: u1, y: u1) {
assert(x | y == 1);
}

fn my_helper() -> Field {
let N: Field = 15; // Like in Rust, local variables override globals
let x = N;
x
}
fn my_helper() -> Field {
let N: Field = 15; // Like in Rust, local variables override globals
let x = N;
x
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use dep::std;

fn main() -> pub Field {
let f = if 3 * 7 > 200 as u32 { foo } else { bar };
assert(f()[1] == 2);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

fn main(a: u32, mut c: [u32; 4]){
if a == c[0] {
assert(c[0] == 0);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use dep::std;

global ARRAY_LEN: u32 = 3;

fn main(arr: [Field; ARRAY_LEN], x: u32) -> pub Field {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ fn main(bn254_modulus_be_bytes : [u8; 32], bn254_modulus_be_bits : [u1; 254]) ->
}

modulus_size
}
}
2 changes: 0 additions & 2 deletions crates/nargo_cli/tests/execution_success/pred_eq/src/main.nr
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use dep::std;

fn main(x: Field, y: Field) {
let p = x == y;
assert(p == true);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use dep::std;

// Testing signed integer division:
// 7/3 = 2
// -7/3 = -2
Expand All @@ -13,8 +11,8 @@ fn main(mut x: i32, mut y: i32, mut z: i32) {
let minus_x = 0-x;
let minus_z = 0-z;
let minus_y = 0-y;
assert(x+minus_x==0);
assert(z+minus_z==0);
assert(x+minus_x == 0);
assert(z+minus_z == 0);
assert(minus_x / y == minus_z);

// -7/-3 = 2
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// Simple program to test to_radix

use dep::std;

fn main(x : Field) {
let bits = x.to_le_bits(3);
assert(bits[0] == 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ fn main(x : u32) {
let z = x >> 4;
let t = x << 4;
assert(z == t >> 8);
}
}
Loading

0 comments on commit 168e0db

Please sign in to comment.