Skip to content

Commit

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

#[test(should_fail)]
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);

}


#[test(should_fail)]
fn test_verify_account_wrong_state_root() {
let _ = OracleMock::mock("get_header").returns((block_header_partial, block_header_rlp));
Expand Down
20 changes: 19 additions & 1 deletion ethereum_history_api/circuits/lib/src/misc/arrays_test.nr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::misc::arrays::{sub_array_equals_up_to_length, sub_array_equals};
use crate::misc::arrays::{sub_array_equals_up_to_length, sub_array_equals, array_equals};

#[test]
fn test_assert_sub_array_equals() {
Expand Down Expand Up @@ -51,3 +51,21 @@ fn test_sub_array_equals_index_out_of_bound() -> bool {
let b: [Field; 5] = [1, 2, 3, 4, 5];
sub_array_equals(a, b, 3)
}

#[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));
}

#[test(should_fail)]
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));
}

0 comments on commit 2acbe44

Please sign in to comment.