diff --git a/CHANGELOG.md b/CHANGELOG.md index f72857217c..e3e8395764 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,8 @@ Both branches support Stwo prover opcodes (Blake2s, QM31) since v2.0.0. #### Upcoming Changes +* refactor: add `CairoFunctionRunner` type alias for `CairoRunner` under the `test_utils` feature flag [#2377](https://github.com/starkware-libs/cairo-vm/pull/2377) + * Add Stwo cairo runner API [#2351](https://github.com/lambdaclass/cairo-vm/pull/2351) * Add union merge strategy for CHANGELOG.md [#2345](https://github.com/lambdaclass/cairo-vm/pull/2345) diff --git a/vm/src/vm/runners/function_runner.rs b/vm/src/vm/runners/function_runner.rs index 96f3b2ee67..c584105710 100644 --- a/vm/src/vm/runners/function_runner.rs +++ b/vm/src/vm/runners/function_runner.rs @@ -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; @@ -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), @@ -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], @@ -106,7 +109,7 @@ impl CairoRunner { /// Resolves `__main__.` to its PC, following alias chains. #[allow(clippy::result_large_err)] - pub(crate) fn get_function_pc(&self, entrypoint: &str) -> Result { + pub fn get_function_pc(&self, entrypoint: &str) -> Result { let full_name = format!("__main__.{entrypoint}"); let identifier = self .program diff --git a/vm/src/vm/runners/mod.rs b/vm/src/vm/runners/mod.rs index 1bad5f2627..03f61b9fa1 100644 --- a/vm/src/vm/runners/mod.rs +++ b/vm/src/vm/runners/mod.rs @@ -2,4 +2,4 @@ pub mod builtin_runner; pub mod cairo_pie; pub mod cairo_runner; #[cfg(feature = "test_utils")] -pub(crate) mod function_runner; +pub mod function_runner;