From df58d23f3bfd2f0ae8776601c9453dd4a74c2546 Mon Sep 17 00:00:00 2001 From: Victor Sint Nicolaas Date: Thu, 18 May 2023 14:46:11 -0400 Subject: [PATCH] Fix tests --- synthesizer/src/process/stack/inclusion/mod.rs | 13 +------------ synthesizer/src/process/tests.rs | 15 +++++++++++++-- synthesizer/src/vm/execute.rs | 16 ++++++++-------- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/synthesizer/src/process/stack/inclusion/mod.rs b/synthesizer/src/process/stack/inclusion/mod.rs index 6f937ad97e..539eb15778 100644 --- a/synthesizer/src/process/stack/inclusion/mod.rs +++ b/synthesizer/src/process/stack/inclusion/mod.rs @@ -19,18 +19,7 @@ mod fee; #[cfg(debug_assertions)] use crate::Stack; -use crate::{ - BlockStorage, - Execution, - Fee, - Input, - Output, - ProvingKey, - Query, - Transaction, - Transition, - VerifyingKey, -}; +use crate::{BlockStorage, Execution, Fee, Input, Output, Query, Transaction, Transition, VerifyingKey}; use console::{ network::prelude::*, program::{Identifier, InputID, ProgramID, StatePath, TransactionLeaf, TransitionLeaf, TRANSACTION_DEPTH}, diff --git a/synthesizer/src/process/tests.rs b/synthesizer/src/process/tests.rs index 3ab3655c24..20e540cf4b 100644 --- a/synthesizer/src/process/tests.rs +++ b/synthesizer/src/process/tests.rs @@ -1550,12 +1550,23 @@ finalize compute: assert_eq!(authorization.len(), 1); // Execute the request. - let (response, execution, _inclusion, _metrics) = process.execute::(authorization, rng).unwrap(); + let (_response, mut execution, _inclusion, _metrics, mut function_assignments) = + process.prepare_function::(authorization).unwrap(); + assert_eq!(function_assignments.len(), execution.transitions().len()); + let mut transition_assignments = BTreeMap::<_, Vec<_>>::new(); + for transition in execution.transitions() { + let pk_id = ProvingKeyId { program_id: *transition.program_id(), function_name: *transition.function_name() }; + transition_assignments + .entry(pk_id) + .and_modify(|assignments| assignments.push(function_assignments.pop_front().unwrap())) + .or_insert(vec![function_assignments.pop_front().unwrap()]); + } + process.execute::(&mut execution, transition_assignments, None, rng).unwrap(); let candidate = response.outputs(); assert_eq!(0, candidate.len()); // Verify the execution. - process.verify_execution::(&execution).unwrap(); + process.verify_execution(&execution).unwrap(); // Now, finalize the execution. process.finalize_execution(&store, &execution).unwrap(); diff --git a/synthesizer/src/vm/execute.rs b/synthesizer/src/vm/execute.rs index 204f6ed204..e676f50a4f 100644 --- a/synthesizer/src/vm/execute.rs +++ b/synthesizer/src/vm/execute.rs @@ -252,13 +252,13 @@ mod tests { // Assert the size of the transaction. let transaction_size_in_bytes = transaction.to_bytes_le().unwrap().len(); - assert_eq!(1389, transaction_size_in_bytes, "Update me if serialization has changed"); + assert_eq!(1388, transaction_size_in_bytes, "Update me if serialization has changed"); // Assert the size of the execution. assert!(matches!(transaction, Transaction::Execute(_, _, _))); if let Transaction::Execute(_, execution, _) = &transaction { let execution_size_in_bytes = execution.to_bytes_le().unwrap().len(); - assert_eq!(1354, execution_size_in_bytes, "Update me if serialization has changed"); + assert_eq!(1353, execution_size_in_bytes, "Update me if serialization has changed"); } } @@ -292,13 +292,13 @@ mod tests { // Assert the size of the transaction. let transaction_size_in_bytes = transaction.to_bytes_le().unwrap().len(); - assert_eq!(2216, transaction_size_in_bytes, "Update me if serialization has changed"); + assert_eq!(2215, transaction_size_in_bytes, "Update me if serialization has changed"); // Assert the size of the execution. assert!(matches!(transaction, Transaction::Execute(_, _, _))); if let Transaction::Execute(_, execution, _) = &transaction { let execution_size_in_bytes = execution.to_bytes_le().unwrap().len(); - assert_eq!(2181, execution_size_in_bytes, "Update me if serialization has changed"); + assert_eq!(2180, execution_size_in_bytes, "Update me if serialization has changed"); } } @@ -327,13 +327,13 @@ mod tests { // Assert the size of the transaction. let transaction_size_in_bytes = transaction.to_bytes_le().unwrap().len(); - assert_eq!(2101, transaction_size_in_bytes, "Update me if serialization has changed"); + assert_eq!(2100, transaction_size_in_bytes, "Update me if serialization has changed"); // Assert the size of the execution. assert!(matches!(transaction, Transaction::Execute(_, _, _))); if let Transaction::Execute(_, execution, _) = &transaction { let execution_size_in_bytes = execution.to_bytes_le().unwrap().len(); - assert_eq!(2066, execution_size_in_bytes, "Update me if serialization has changed"); + assert_eq!(2065, execution_size_in_bytes, "Update me if serialization has changed"); } } @@ -361,13 +361,13 @@ mod tests { // Assert the size of the transaction. let transaction_size_in_bytes = transaction.to_bytes_le().unwrap().len(); - assert_eq!(2113, transaction_size_in_bytes, "Update me if serialization has changed"); + assert_eq!(2112, transaction_size_in_bytes, "Update me if serialization has changed"); // Assert the size of the execution. assert!(matches!(transaction, Transaction::Execute(_, _, _))); if let Transaction::Execute(_, execution, _) = &transaction { let execution_size_in_bytes = execution.to_bytes_le().unwrap().len(); - assert_eq!(2078, execution_size_in_bytes, "Update me if serialization has changed"); + assert_eq!(2077, execution_size_in_bytes, "Update me if serialization has changed"); } }