Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Pasifaee committed Feb 29, 2024
1 parent 2acbe44 commit 2a8a5e4
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 22 deletions.
4 changes: 2 additions & 2 deletions ethereum_history_api/circuits/lib/src/account_int_test.nr
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ fn test_verify_account() {
let _ = verify_account(state_proof.key, account, state_proof, state_root);
}

#[test(should_fail)]
#[test(should_fail_with="Address mismatch")]
fn test_verify_account_wrong_address() {
let _ = OracleMock::mock("get_header").returns((block_header_partial, block_header_rlp));

let _ = verify_account(state_proof_from_different_header.key, account, state_proof, state_root_from_different_header);
let _ = verify_account(state_proof_from_different_header.key, account, state_proof, state_root);

}

Expand Down
41 changes: 21 additions & 20 deletions ethereum_history_api/circuits/lib/src/misc/arrays_test.nr
Original file line number Diff line number Diff line change
Expand Up @@ -37,35 +37,36 @@ fn test_assert_sub_array_equals_array_out_of_bound() {

#[test]
fn test_sub_array_equals() {
let a: [Field; 3] = [2, 3, 4];
let b: [Field; 5] = [1, 2, 3, 4, 5];
assert(sub_array_equals(a, b, 1));
assert(!sub_array_equals(a, b, 0));
assert(!sub_array_equals(a, b, 2));
assert(!sub_array_equals(a, b, 2));
let sub_array: [Field; 3] = [2, 3, 4];
let array: [Field; 5] = [1, 2, 3, 4, 5];
assert(sub_array_equals(sub_array, array, 1));
assert(!sub_array_equals(sub_array, array, 0));
assert(!sub_array_equals(sub_array, array, 2));
assert(!sub_array_equals(sub_array, array, 2));
}

#[test(should_fail_with = "array index out of bound")]
fn test_sub_array_equals_index_out_of_bound() -> bool {
let a: [Field; 3] = [2, 3, 4];
let b: [Field; 5] = [1, 2, 3, 4, 5];
sub_array_equals(a, b, 3)
let sub_array: [Field; 3] = [2, 3, 4];
let array: [Field; 5] = [1, 2, 3, 4, 5];
sub_array_equals(sub_array, array, 3)
}

#[test]
fn test_empty_array_equals() {
let empty_array: [Field; 0] = [];
assert(array_equals(empty_array, empty_array));
}

#[test]
fn test_array_equals() {
let a: [Field; 0] = [];
let b: [Field; 3] = [1, 2, 3];
assert(array_equals(a, a));
assert(array_equals(b, b));
let array: [Field; 3] = [1, 2, 3];
assert(array_equals(array, array));
}

#[test(should_fail)]
#[test(should_fail_with = "Arrays not equal")]
fn test_array_not_equals() {
let a: [Field; 3] = [1, 2, 3];
let b: [Field; 3] = [1, 2, 4];
let c: [Field; 4] = [1, 2, 3, 4];
let d: [Field; 4] = [0, 2, 3, 4];
assert(array_equals(a, b));
assert(array_equals(c, d));
let array: [Field; 3] = [1, 2, 3];
let other_array: [Field; 3] = [1, 2, 4];
assert(array_equals(array, other_array), "Arrays not equal");
}

0 comments on commit 2a8a5e4

Please sign in to comment.