Skip to content

Commit

Permalink
chore: run nargo fmt on integration tests (#3059)
Browse files Browse the repository at this point in the history
Co-authored-by: Koby Hall <[email protected]>
Co-authored-by: kevaundray <[email protected]>
Co-authored-by: github-merge-queue[bot] <github-merge-queue[bot]@users.noreply.github.com>
Co-authored-by: jfecher <[email protected]>
Co-authored-by: Alex Gherghisan <[email protected]>
Co-authored-by: Koby <[email protected]>
Co-authored-by: guipublic <[email protected]>
Co-authored-by: Jonathan Bursztyn <[email protected]>
Co-authored-by: José Pedro Sousa <[email protected]>
Co-authored-by: Álvaro Rodríguez <[email protected]>
Co-authored-by: Tom French <[email protected]>
Co-authored-by: Gustavo Giráldez <[email protected]>
  • Loading branch information
13 people authored Oct 12, 2023
1 parent 004f8dd commit b65201f
Show file tree
Hide file tree
Showing 88 changed files with 167 additions and 211 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
// a test before ACIR gen optimizes this test.
fn main(_x : Field) -> pub Field {
5
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
// ---

fn new_concrete_c_over_d() -> C<D> {
let d_method_interface = get_d_method_interface();
C::new(d_method_interface)
}
fn new_concrete_c_over_d() -> C<D> {
let d_method_interface = get_d_method_interface();
C::new(d_method_interface)
}

// ---

Expand Down Expand Up @@ -54,25 +53,24 @@
d: Field,
}

fn d_method(input: D) -> Field {
input.d * input.d
}
fn d_method(input: D) -> Field {
input.d * input.d
}

fn get_d_method_interface() -> MethodInterface<D> {
MethodInterface {
fn get_d_method_interface() -> MethodInterface<D> {
MethodInterface {
some_method_on_t_d: d_method,
}
}

// ---
}

fn main(input: Field) -> pub Field {
let b: B<C<D>> = B::new(new_concrete_c_over_d);
let c: C<D> = b.get_t_c(); // Singleton<Note>
let d: D = D { d: input }; // Note
let output = c.call_method_of_t_d(d);

output
}
// ---
fn main(input: Field) -> pub Field {
let b: B<C<D>> = B::new(new_concrete_c_over_d);
let c: C<D> = b.get_t_c(); // Singleton<Note>
let d: D = D { d: input }; // Note
let output = c.call_method_of_t_d(d);

output
}

// ---
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ fn main(mut x: u32, y: u32) {
x = std::wrapping_mul(x,x);
assert(y == x);

let c:u3 = 2;
let c: u3 = 2;
assert(c > x as u3);
}
4 changes: 2 additions & 2 deletions tooling/nargo_cli/tests/execution_success/6_array/src/main.nr
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use dep::std;
//Basic tests for arrays
fn main(x: [u32; 5], y: [u32; 5], mut z: u32, t: u32) {
//Basic tests for arrays
fn main(x: [u32; 5], y: [u32; 5], mut z: u32, t: u32) {
let mut c = 2301;
z = y[4];
//Test 1:
Expand Down
15 changes: 6 additions & 9 deletions tooling/nargo_cli/tests/execution_success/7_function/src/main.nr
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
//Tests for function calling
//Tests for function calling
fn f1(mut x: Field) -> Field {
x = x + 1;
x = f2(x);
x
}

fn f2(mut x: Field) -> Field{
fn f2(mut x: Field) -> Field {
x += 2;
x
}
Expand All @@ -22,7 +22,7 @@ fn test1(mut a: Field) {
assert(a == 4);
}

fn test2(z: Field, t: u32 ) {
fn test2(z: Field, t: u32 ) {
let a = z + t as Field;
assert(a == 64);
let e = pow(z, t as Field);
Expand Down Expand Up @@ -78,15 +78,12 @@ fn test_multiple5(a: (u32, u32)) {
assert(a.0 == a.1+2);
}


fn test_multiple6(a: my2, b: my_struct, c: (my2, my_struct)) {
test_multiple4(a.aa);
test_multiple5((b.a, b.b));
assert(c.0.aa.a == c.1.a);
}



fn foo<N>(a: [Field; N]) -> [Field; N] {
a
}
Expand All @@ -95,7 +92,7 @@ fn bar() -> [Field; 1] {
foo([0])
}

fn main(x: u32 , y: u32 , a: Field, arr1: [u32; 9], arr2: [u32; 9]) {
fn main(x: u32 , y: u32 , a: Field, arr1: [u32; 9], arr2: [u32; 9]) {
let mut ss: my_struct = my_struct { b: x, a: x+2, };
test_multiple4(ss);
test_multiple5((ss.a,ss.b));
Expand All @@ -106,13 +103,13 @@ fn main(x: u32 , y: u32 , a: Field, arr1: [u32; 9], arr2: [u32; 9]) {
ss.a = 61;
test_multiple6(my, ss, (my,ss));

let my_block = {
let my_block = {
let mut ab = f2(a);
ab = ab + a;
(x,ab)
};
assert(my_block.1 == 4);

test0(a);
test1(a);
test2(x as Field, y);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ fn main(x : Field, y : Field, z : Field) -> pub Field {
let c = b * z; // 2 * 5 = 10
let d = c / a; // 10 / 6 (This uses field inversion, so we test it by multiplying by `a`)
d * a
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

fn main(x: [u32; 5], mut z: u32, t: u32, index: [Field;5], index2: [Field;5], offset: Field, sublen: Field) {
let idx = (z - 5*t - 5) as Field;
//dynamic array test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Tests a very simple program.
//
// The features being tested is assertion
fn main(x : Field, y : pub Field) {
fn main(x : Field, y : pub Field) {
assert(x == y, "x and y are not equal");
assert_eq(x, y, "x and y are not equal");
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ fn main(x : Field, y : Field) {
let y_as_u11 = y as u11;
assert((x_as_u11 & y_as_u11) == x_as_u11);
}

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
fn main(x: u64) {
let two: u64 = 2;
let three: u64 = 3;
let two: u64 = 2;
let three: u64 = 3;

// shifts on constant values
assert(two << 2 == 8);
Expand All @@ -11,13 +11,13 @@ fn main(x: u64) {
assert(x << 1 == 128);
assert(x >> 2 == 16);

regression_2250();
regression_2250();
}

fn regression_2250() {
let a: u1 = 1 >> 1;
let a: u1 = 1 >> 1;
assert(a == 0);
let b: u32 = 1 >> 32;

let b: u32 = 1 >> 32;
assert(b == 0);
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
fn main(x: u1) {
assert(!x == 0);
}

Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ fn main(x: u1, y: u1) {

assert(x | y | x == 1);
}

Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@

fn main(x: u32) {
fn main(x: u32) {
assert(entry_point(x) == 2);
swap_entry_point(x, x + 1);
assert(deep_entry_point(x) == 4);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// Tests a very simple program.
//
// The features being tested are array reads and writes

fn main(x: [Field; 3]) {
fn main(x: [Field; 3]) {
read_array(x);
read_write_array(x);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Tests a very simple program.
//
// The features being tested is using assert on brillig
fn main(x: Field) {
fn main(x: Field) {
assert(1 == conditional(x as bool));
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Tests a very simple program.
//
// The features being tested is brillig calls
fn main(x: u32) {
fn main(x: u32) {
assert(entry_point(x) == 2);
swap_entry_point(x, x + 1);
assert(deep_entry_point(x) == 4);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Tests a very simple program.
//
// The features being tested is brillig calls passing arrays around
fn main(x: [u32; 3]) {
fn main(x: [u32; 3]) {
assert(entry_point(x) == 9);
another_entry_point(x);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Tests a very simple program.
//
// The features being tested is brillig calls with conditionals
fn main(x: [u32; 3]) {
fn main(x: [u32; 3]) {
assert(entry_point(x[0]) == 7);
assert(entry_point(x[1]) == 8);
assert(entry_point(x[2]) == 9);
Expand Down Expand Up @@ -29,7 +29,7 @@ unconstrained fn entry_point(x: u32) -> u32 {
result = inner_2();
} else if x == 3 {
result = inner_3();
}
}

result
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Tests a very simple program.
//
// The features being tested is basic conditonal on brillig
fn main(x: Field) {
fn main(x: Field) {
assert(4 == conditional(x == 1));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ struct MyStruct {
operation: fn (u32) -> u32,
}

fn main(x: u32) {
fn main(x: u32) {
assert(wrapper(increment, x) == x + 1);
assert(wrapper(increment_acir, x) == x + 1);
assert(wrapper(decrement, x) == x - 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ struct myStruct {
// Tests a very simple program.
//
// The features being tested is the identity function in Brillig
fn main(x : Field) {
fn main(x : Field) {
assert(x == identity(x));
// TODO: add support for array comparison
let arr = identity_array([x, x]);
Expand All @@ -21,13 +21,13 @@ fn main(x : Field) {
}

unconstrained fn identity(x : Field) -> Field {
x
x
}

unconstrained fn identity_array(arr : [Field; 2]) -> [Field; 2] {
arr
arr
}

unconstrained fn identity_struct(s : myStruct) -> myStruct {
s
s
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ fn main(x: Field, result: [u8; 32]) {
let digest = keccak256([x as u8], 1);
assert(digest == result);

//#1399: variable meesage size
//#1399: variable meesage size
let message_size = 4;
let hash_a = keccak256([1,2,3,4], message_size);
let hash_b = keccak256([1,2,3,4,0,0,0,0], message_size);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Tests a very simple program.
//
// The features being tested is basic looping on brillig
fn main(sum: u32){
fn main(sum: u32) {
assert(loop(4) == sum);
assert(plain_loop() == sum);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Tests a very simple Brillig function.
//
// The features being tested is not instruction on brillig
fn main(x: Field, y : Field) {
fn main(x: Field, y : Field) {
assert(false == not_operator(x as bool));
assert(true == not_operator(y as bool));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use dep::std::slice;

// Tests oracle usage in brillig/unconstrained functions
fn main(x: Field) {
fn main(x: Field) {
get_number_sequence_wrapper(20);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ unconstrained fn main(x: Field, y: Field, salt: Field, out_x: Field, out_y: Fiel
let hash = std::hash::pedersen_with_separator([state], 0);
assert(std::hash::pedersen_with_separator([43], 0)[0] == hash[0]);
}

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Tests a very simple program.
//
// The feature being tested is brillig recursion
fn main(x: u32) {
fn main(x: u32) {
assert(fibonacci(x) == 55);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ unconstrained fn main(
b_pub_x: pub Field,
b_pub_y: pub Field
) {
let mut priv_key = a;
let mut pub_x: Field = a_pub_x;
let mut pub_y: Field = a_pub_y;
if a != 1 { // Change `a` in Prover.toml to test input `b`
let mut priv_key = a;
let mut pub_x: Field = a_pub_x;
let mut pub_y: Field = a_pub_y;
if a != 1 { // Change `a` in Prover.toml to test input `b`
priv_key = b;
pub_x = b_pub_x;
pub_y = b_pub_y;
}
let res = std::scalar_mul::fixed_base_embedded_curve(priv_key, 0);
let res = std::scalar_mul::fixed_base_embedded_curve(priv_key, 0);
assert(res[0] == pub_x);
assert(res[1] == pub_y);
}
Loading

0 comments on commit b65201f

Please sign in to comment.