Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion vm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ cairo-0-secp-hints = []
cairo-0-data-availability-hints = []

# Note that these features are not retro-compatible with the cairo Python VM.
test_utils = ["dep:arbitrary", "starknet-types-core/arbitrary", "starknet-types-core/std"] # This feature will reference every test-oriented feature
function_runner = []
test_utils = ["function_runner", "dep:arbitrary", "starknet-types-core/arbitrary", "starknet-types-core/std"] # This feature will reference every test-oriented feature
# Allows extending the set of hints for the current vm run from within a hint.
# For a usage example checkout vm/src/tests/run_deprecated_contract_class_simplified.rs
extensive_hints = []
Expand Down
11 changes: 7 additions & 4 deletions vm/src/vm/runners/function_runner.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Function runner extension methods for [`CairoRunner`].
//!
//! Provides a simplified API for executing individual Cairo 0 functions by name or PC.
//! This entire module is compiled only when the `test_utils` feature is enabled.
//! Enabled by the `function_runner` feature flag.

use crate::hint_processor::builtin_hint_processor::builtin_hint_processor_definition::BuiltinHintProcessor;
use crate::hint_processor::hint_processor_definition::HintProcessor;
Expand All @@ -18,8 +18,11 @@ use crate::vm::errors::vm_exception::VmException;
use crate::vm::runners::cairo_runner::{CairoArg, CairoRunner, ORDERED_BUILTIN_LIST};
use crate::vm::security::verify_secure_runner;

/// Type alias for [`CairoRunner`] with testing methods enabled.
/// Mirrors the Python `CairoFunctionRunner` class interface.
pub type CairoFunctionRunner = CairoRunner;

/// Identifies a Cairo function entrypoint either by function name or by program counter.
#[allow(dead_code)]
pub enum EntryPoint<'a> {
Name(&'a str),
Pc(usize),
Expand Down Expand Up @@ -75,7 +78,7 @@ impl CairoRunner {
/// Resolves the entrypoint, builds the call stack, runs until the function's end PC,
/// and optionally verifies security constraints.
#[allow(clippy::result_large_err)]
pub(crate) fn run_from_entrypoint(
pub fn run_from_entrypoint(
&mut self,
entrypoint: EntryPoint<'_>,
args: &[CairoArg],
Expand Down Expand Up @@ -106,7 +109,7 @@ impl CairoRunner {

/// Resolves `__main__.<entrypoint>` to its PC, following alias chains.
#[allow(clippy::result_large_err)]
pub(crate) fn get_function_pc(&self, entrypoint: &str) -> Result<usize, CairoRunError> {
pub fn get_function_pc(&self, entrypoint: &str) -> Result<usize, CairoRunError> {
let full_name = format!("__main__.{entrypoint}");
let identifier = self
.program
Expand Down
4 changes: 2 additions & 2 deletions vm/src/vm/runners/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pub mod builtin_runner;
pub mod cairo_pie;
pub mod cairo_runner;
#[cfg(feature = "test_utils")]
pub(crate) mod function_runner;
#[cfg(feature = "function_runner")]
pub mod function_runner;
Loading