Skip to content

Commit

Permalink
modify tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kevaundray committed Oct 29, 2023
1 parent 1152384 commit 051dd01
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 22 deletions.
7 changes: 3 additions & 4 deletions acvm-repo/acir/src/circuit/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,9 +263,8 @@ mod tests {
};

fn read_write(circuit: Circuit) -> (Circuit, Circuit) {
let mut bytes = Vec::new();
circuit.write(&mut bytes).unwrap();
let got_circuit = Circuit::read(&*bytes).unwrap();
let bytes = Circuit::serialize_circuit(&circuit);
let got_circuit = Circuit::deserialize_circuit(&bytes).unwrap();
(circuit, got_circuit)
}

Expand Down Expand Up @@ -311,7 +310,7 @@ mod tests {
encoder.write_all(bad_circuit).unwrap();
encoder.finish().unwrap();

let deserialization_result = Circuit::read(&*zipped_bad_circuit);
let deserialization_result = Circuit::deserialize_circuit(&zipped_bad_circuit);
assert!(deserialization_result.is_err());
}
}
21 changes: 7 additions & 14 deletions acvm-repo/acir/tests/test_program_serialization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ fn addition_circuit() {
..Circuit::default()
};

let mut bytes = Vec::new();
circuit.write(&mut bytes).unwrap();
let bytes = Circuit::serialize_circuit(&circuit);

let expected_serialization: Vec<u8> = vec![
31, 139, 8, 0, 0, 0, 0, 0, 0, 255, 173, 144, 187, 13, 192, 32, 12, 68, 249, 100, 32, 27,
Expand Down Expand Up @@ -73,8 +72,7 @@ fn fixed_base_scalar_mul_circuit() {
..Circuit::default()
};

let mut bytes = Vec::new();
circuit.write(&mut bytes).unwrap();
let bytes = Circuit::serialize_circuit(&circuit);

let expected_serialization: Vec<u8> = vec![
31, 139, 8, 0, 0, 0, 0, 0, 0, 255, 77, 138, 91, 10, 0, 48, 12, 194, 178, 215, 215, 46, 189,
Expand All @@ -101,8 +99,7 @@ fn pedersen_circuit() {
..Circuit::default()
};

let mut bytes = Vec::new();
circuit.write(&mut bytes).unwrap();
let bytes = Circuit::serialize_circuit(&circuit);

let expected_serialization: Vec<u8> = vec![
31, 139, 8, 0, 0, 0, 0, 0, 0, 255, 93, 138, 9, 10, 0, 64, 8, 2, 103, 15, 250, 255, 139,
Expand Down Expand Up @@ -143,8 +140,7 @@ fn schnorr_verify_circuit() {
..Circuit::default()
};

let mut bytes = Vec::new();
circuit.write(&mut bytes).unwrap();
let bytes = Circuit::serialize_circuit(&circuit);

let expected_serialization: Vec<u8> = vec![
31, 139, 8, 0, 0, 0, 0, 0, 0, 255, 77, 210, 87, 78, 2, 1, 20, 134, 209, 177, 247, 222, 123,
Expand Down Expand Up @@ -197,8 +193,7 @@ fn simple_brillig_foreign_call() {
..Circuit::default()
};

let mut bytes = Vec::new();
circuit.write(&mut bytes).unwrap();
let bytes = Circuit::serialize_circuit(&circuit);

let expected_serialization: Vec<u8> = vec![
31, 139, 8, 0, 0, 0, 0, 0, 0, 255, 173, 143, 49, 10, 64, 33, 12, 67, 99, 63, 124, 60, 142,
Expand Down Expand Up @@ -271,8 +266,7 @@ fn complex_brillig_foreign_call() {
..Circuit::default()
};

let mut bytes = Vec::new();
circuit.write(&mut bytes).unwrap();
let bytes = Circuit::serialize_circuit(&circuit);

let expected_serialization: Vec<u8> = vec![
31, 139, 8, 0, 0, 0, 0, 0, 0, 255, 213, 83, 219, 10, 128, 48, 8, 117, 174, 139, 159, 179,
Expand Down Expand Up @@ -310,8 +304,7 @@ fn memory_op_circuit() {
return_values: PublicInputs([Witness(4)].into()),
..Circuit::default()
};
let mut bytes = Vec::new();
circuit.write(&mut bytes).unwrap();
let bytes = Circuit::serialize_circuit(&circuit);

let expected_serialization: Vec<u8> = vec![
31, 139, 8, 0, 0, 0, 0, 0, 0, 255, 213, 146, 49, 14, 0, 32, 8, 3, 139, 192, 127, 240, 7,
Expand Down
3 changes: 2 additions & 1 deletion acvm-repo/acvm_js/src/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ pub async fn execute_circuit_with_black_box_solver(
foreign_call_handler: ForeignCallHandler,
) -> Result<JsWitnessMap, Error> {
console_error_panic_hook::set_once();
let circuit: Circuit = Circuit::read(&*circuit).expect("Failed to deserialize circuit");
let circuit: Circuit =
Circuit::deserialize_circuit(&circuit).expect("Failed to deserialize circuit");

let mut acvm = ACVM::new(&solver.0, &circuit.opcodes, initial_witness.into());

Expand Down
9 changes: 6 additions & 3 deletions acvm-repo/acvm_js/src/public_witness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ pub fn get_return_witness(
witness_map: JsWitnessMap,
) -> Result<JsWitnessMap, JsString> {
console_error_panic_hook::set_once();
let circuit: Circuit = Circuit::read(&*circuit).expect("Failed to deserialize circuit");
let circuit: Circuit =
Circuit::deserialize_circuit(&circuit).expect("Failed to deserialize circuit");
let witness_map = WitnessMap::from(witness_map);

let return_witness =
Expand All @@ -50,7 +51,8 @@ pub fn get_public_parameters_witness(
solved_witness: JsWitnessMap,
) -> Result<JsWitnessMap, JsString> {
console_error_panic_hook::set_once();
let circuit: Circuit = Circuit::read(&*circuit).expect("Failed to deserialize circuit");
let circuit: Circuit =
Circuit::deserialize_circuit(&circuit).expect("Failed to deserialize circuit");
let witness_map = WitnessMap::from(solved_witness);

let public_params_witness =
Expand All @@ -70,7 +72,8 @@ pub fn get_public_witness(
solved_witness: JsWitnessMap,
) -> Result<JsWitnessMap, JsString> {
console_error_panic_hook::set_once();
let circuit: Circuit = Circuit::read(&*circuit).expect("Failed to deserialize circuit");
let circuit: Circuit =
Circuit::deserialize_circuit(&circuit).expect("Failed to deserialize circuit");
let witness_map = WitnessMap::from(solved_witness);

let public_witness =
Expand Down

0 comments on commit 051dd01

Please sign in to comment.