Skip to content

Commit 761d383

Browse files
committed
Add tests for Mina account FFI
1 parent 260c051 commit 761d383

File tree

1 file changed

+47
-2
lines changed
  • operator/mina_account/lib/src

1 file changed

+47
-2
lines changed

operator/mina_account/lib/src/lib.rs

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ pub fn verify_account_inclusion(proof_bytes: &[u8], pub_input_bytes: &[u8]) -> b
102102
mod test {
103103

104104
use super::*;
105+
use core::ptr;
105106

106107
const PROOF_BYTES: &[u8] =
107108
include_bytes!("../../../../scripts/test_files/mina_account/mina_account.proof");
@@ -130,7 +131,7 @@ mod test {
130131
}
131132

132133
#[test]
133-
fn empty_account_state_proof_does_not_verify() {
134+
fn zeroized_account_state_proof_does_not_verify() {
134135
const PROOF_SIZE: usize = PROOF_BYTES.len();
135136
let proof_buffer = [0u8; PROOF_SIZE];
136137

@@ -144,7 +145,7 @@ mod test {
144145
}
145146

146147
#[test]
147-
fn valid_account_state_proof_with_empty_pub_input_does_not_verify() {
148+
fn valid_account_state_proof_with_zeroized_pub_input_does_not_verify() {
148149
const PUB_INPUT_SIZE: usize = PUB_INPUT_BYTES.len();
149150
let pub_input_buffer = [0u8; PUB_INPUT_SIZE];
150151

@@ -156,4 +157,48 @@ mod test {
156157
);
157158
assert_eq!(result, 0);
158159
}
160+
161+
#[test]
162+
fn null_account_state_proof_does_not_verify() {
163+
let result = verify_account_inclusion_ffi(
164+
ptr::null(),
165+
PROOF_BYTES.len() as u32,
166+
PUB_INPUT_BYTES.as_ptr(),
167+
PUB_INPUT_BYTES.len() as u32,
168+
);
169+
assert_eq!(result, 0);
170+
}
171+
172+
#[test]
173+
fn valid_account_state_proof_with_null_pub_input_does_not_verify() {
174+
let result = verify_account_inclusion_ffi(
175+
PROOF_BYTES.as_ptr(),
176+
PROOF_BYTES.len() as u32,
177+
ptr::null(),
178+
PUB_INPUT_BYTES.len() as u32,
179+
);
180+
assert_eq!(result, 0);
181+
}
182+
183+
#[test]
184+
fn empty_account_state_proof_does_not_verify() {
185+
let result = verify_account_inclusion_ffi(
186+
PROOF_BYTES.as_ptr(),
187+
0,
188+
PUB_INPUT_BYTES.as_ptr(),
189+
PUB_INPUT_BYTES.len() as u32,
190+
);
191+
assert_eq!(result, 0);
192+
}
193+
194+
#[test]
195+
fn valid_account_state_proof_with_empty_pub_input_does_not_verify() {
196+
let result = verify_account_inclusion_ffi(
197+
PROOF_BYTES.as_ptr(),
198+
PROOF_BYTES.len() as u32,
199+
PUB_INPUT_BYTES.as_ptr(),
200+
0,
201+
);
202+
assert_eq!(result, 0);
203+
}
159204
}

0 commit comments

Comments
 (0)