Skip to content

Commit

Permalink
Test empty inputs in Mina FFI
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielbosio committed Sep 19, 2024
1 parent caf7e32 commit 664a813
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions operator/mina/lib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,4 +234,34 @@ mod test {
verify_mina_state_ffi(&proof_buffer, proof_size, &pub_input_buffer, pub_input_size);
assert!(!result);
}

#[test]
fn empty_mina_state_proof_does_not_verify() {
let mut proof_buffer = [0u8; super::MAX_PROOF_SIZE];
let proof_size = PROOF_BYTES.len();

let mut pub_input_buffer = [0u8; super::MAX_PUB_INPUT_SIZE];
let pub_input_size = PUB_INPUT_BYTES.len();
assert!(pub_input_size <= pub_input_buffer.len());
pub_input_buffer[..pub_input_size].clone_from_slice(PUB_INPUT_BYTES);

let result =
verify_mina_state_ffi(&proof_buffer, proof_size, &pub_input_buffer, pub_input_size);
assert!(!result);
}

#[test]
fn valid_mina_state_proof_with_empty_pub_input_does_not_verify() {
let mut proof_buffer = [0u8; super::MAX_PROOF_SIZE];
let proof_size = PROOF_BYTES.len();
assert!(proof_size <= proof_buffer.len());
proof_buffer[..proof_size].clone_from_slice(PROOF_BYTES);

let mut pub_input_buffer = [0u8; super::MAX_PUB_INPUT_SIZE];
let pub_input_size = PUB_INPUT_BYTES.len();

let result =
verify_mina_state_ffi(&proof_buffer, proof_size, &pub_input_buffer, pub_input_size);
assert!(!result);
}
}

0 comments on commit 664a813

Please sign in to comment.