Skip to content

Commit

Permalink
test: update fpi memory tests, add main test
Browse files Browse the repository at this point in the history
  • Loading branch information
Fumuran committed Nov 21, 2024
1 parent 7098c66 commit 2f35f36
Show file tree
Hide file tree
Showing 4 changed files with 263 additions and 181 deletions.
7 changes: 4 additions & 3 deletions miden-tx/src/testing/mock_host.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use alloc::{rc::Rc, string::ToString, sync::Arc};
use alloc::{rc::Rc, string::ToString, sync::Arc, vec::Vec};

use miden_lib::transaction::TransactionEvent;
use miden_objects::{
Expand Down Expand Up @@ -32,10 +32,11 @@ impl MockHost {
account: AccountHeader,
advice_inputs: AdviceInputs,
mast_store: Rc<TransactionMastStore>,
mut foreign_code_commitments: Vec<Digest>,
) -> Self {
foreign_code_commitments.push(account.code_commitment());
let adv_provider: MemAdviceProvider = advice_inputs.into();
let proc_index_map =
AccountProcedureIndexMap::new([account.code_commitment()], &adv_provider);
let proc_index_map = AccountProcedureIndexMap::new(foreign_code_commitments, &adv_provider);
Self {
adv_provider,
acct_procedure_index_map: proc_index_map.unwrap(),
Expand Down
3 changes: 2 additions & 1 deletion miden-tx/src/testing/tx_context/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,8 @@ impl TransactionContextBuilder {
};

let mut tx_args =
TransactionArgs::new(self.tx_script, Some(self.note_args), AdviceMap::default());
TransactionArgs::new(self.tx_script, Some(self.note_args), AdviceMap::default())
.with_advice_inputs(self.advice_inputs.clone());

tx_args.extend_expected_output_notes(self.expected_output_notes.clone());

Expand Down
11 changes: 8 additions & 3 deletions miden-tx/src/testing/tx_context/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,14 @@ impl TransactionContext {

mast_store.load_transaction_code(&self.tx_inputs, &self.tx_args);

CodeExecutor::new(MockHost::new(self.tx_inputs.account().into(), advice_inputs, mast_store))
.stack_inputs(stack_inputs)
.execute_program(program)
CodeExecutor::new(MockHost::new(
self.tx_inputs.account().into(),
advice_inputs,
mast_store,
self.foreign_codes.iter().map(|code| code.commitment()).collect(),
))
.stack_inputs(stack_inputs)
.execute_program(program)
}

/// Executes the transaction through a [TransactionExecutor]
Expand Down
Loading

0 comments on commit 2f35f36

Please sign in to comment.