Skip to content

Commit 49e60b1

Browse files
committed
Update operator tests
1 parent be1f6b9 commit 49e60b1

1 file changed

Lines changed: 29 additions & 6 deletions

File tree

operator/mina/lib/src/lib.rs

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,11 @@ mod test {
182182
include_bytes!("../../../../batcher/aligned/test_files/mina/protocol_state.proof");
183183
const PROTOCOL_STATE_PUB_BYTES: &[u8] =
184184
include_bytes!("../../../../batcher/aligned/test_files/mina/protocol_state.pub");
185-
const BAD_PROTOCOL_STATE_PUB_BYTES: &[u8] =
186-
include_bytes!("../../../../batcher/aligned/test_files/mina/bad_protocol_state.pub");
187-
// BAD_PROTOCOL_STATE_PUB_BYTES has an invalid hash.
185+
const PROTOCOL_STATE_BAD_HASH_PUB_BYTES: &[u8] =
186+
include_bytes!("../../../../batcher/aligned/test_files/mina/protocol_state_bad_hash.pub");
187+
const PROTOCOL_STATE_BAD_CONSENSUS_PUB_BYTES: &[u8] = include_bytes!(
188+
"../../../../batcher/aligned/test_files/mina/protocol_state_bad_consensus.pub"
189+
);
188190

189191
#[test]
190192
fn parse_protocol_state_proof_does_not_fail() {
@@ -218,16 +220,37 @@ mod test {
218220
}
219221

220222
#[test]
221-
fn bad_protocol_state_proof_does_not_verify() {
223+
fn proof_of_protocol_state_with_bad_hash_does_not_verify() {
222224
let mut proof_buffer = [0u8; super::MAX_PROOF_SIZE];
223225
let proof_size = PROTOCOL_STATE_PROOF_BYTES.len();
224226
assert!(proof_size <= proof_buffer.len());
225227
proof_buffer[..proof_size].clone_from_slice(PROTOCOL_STATE_PROOF_BYTES);
226228

227229
let mut pub_input_buffer = [0u8; super::MAX_PUB_INPUT_SIZE];
228-
let pub_input_size = BAD_PROTOCOL_STATE_PUB_BYTES.len();
230+
let pub_input_size = PROTOCOL_STATE_BAD_HASH_PUB_BYTES.len();
229231
assert!(pub_input_size <= pub_input_buffer.len());
230-
pub_input_buffer[..pub_input_size].clone_from_slice(BAD_PROTOCOL_STATE_PUB_BYTES);
232+
pub_input_buffer[..pub_input_size].clone_from_slice(PROTOCOL_STATE_BAD_HASH_PUB_BYTES);
233+
234+
let result = verify_protocol_state_proof_ffi(
235+
&proof_buffer,
236+
proof_size,
237+
&pub_input_buffer,
238+
pub_input_size,
239+
);
240+
assert!(!result);
241+
}
242+
243+
#[test]
244+
fn proof_of_protocol_state_with_bad_consensus_does_not_verify() {
245+
let mut proof_buffer = [0u8; super::MAX_PROOF_SIZE];
246+
let proof_size = PROTOCOL_STATE_PROOF_BYTES.len();
247+
assert!(proof_size <= proof_buffer.len());
248+
proof_buffer[..proof_size].clone_from_slice(PROTOCOL_STATE_PROOF_BYTES);
249+
250+
let mut pub_input_buffer = [0u8; super::MAX_PUB_INPUT_SIZE];
251+
let pub_input_size = PROTOCOL_STATE_BAD_CONSENSUS_PUB_BYTES.len();
252+
assert!(pub_input_size <= pub_input_buffer.len());
253+
pub_input_buffer[..pub_input_size].clone_from_slice(PROTOCOL_STATE_BAD_CONSENSUS_PUB_BYTES);
231254

232255
let result = verify_protocol_state_proof_ffi(
233256
&proof_buffer,

0 commit comments

Comments
 (0)