From 0b16290173c7938226595d0cb0e469f558f44933 Mon Sep 17 00:00:00 2001 From: Tomas Fabrizio Orsi Date: Thu, 11 Dec 2025 15:39:43 -0300 Subject: [PATCH 01/20] feat: add `cargo miden test` command Signed-off-by: Tomas Fabrizio Orsi --- tools/cargo-miden/src/cli.rs | 4 +- tools/cargo-miden/src/commands/build.rs | 2 +- tools/cargo-miden/src/commands/mod.rs | 2 + tools/cargo-miden/src/commands/test.rs | 78 +++++++++++++++++++++++++ tools/cargo-miden/src/lib.rs | 4 ++ 5 files changed, 88 insertions(+), 2 deletions(-) create mode 100644 tools/cargo-miden/src/commands/test.rs diff --git a/tools/cargo-miden/src/cli.rs b/tools/cargo-miden/src/cli.rs index 7b36a2126..118b124e1 100644 --- a/tools/cargo-miden/src/cli.rs +++ b/tools/cargo-miden/src/cli.rs @@ -1,6 +1,6 @@ use clap::{Parser, Subcommand}; -use crate::commands::{BuildCommand, ExampleCommand, NewCommand}; +use crate::commands::{BuildCommand, ExampleCommand, NewCommand, TestCommand}; /// Top-level command-line interface for `cargo-miden`. #[derive(Debug, Parser)] @@ -25,4 +25,6 @@ pub enum CargoMidenCommand { Build(BuildCommand), /// Scaffold one of the curated example projects. Example(ExampleCommand), + /// Run the miden-tests in the project. + Test(TestCommand), } diff --git a/tools/cargo-miden/src/commands/build.rs b/tools/cargo-miden/src/commands/build.rs index 51e324a44..b355dc3a8 100644 --- a/tools/cargo-miden/src/commands/build.rs +++ b/tools/cargo-miden/src/commands/build.rs @@ -310,7 +310,7 @@ fn run_cargo(wasi: &str, spawn_args: &[String]) -> Result> { Ok(outputs) } -fn spawn_cargo(mut cmd: Command, cargo: &Path) -> Result> { +pub(crate) fn spawn_cargo(mut cmd: Command, cargo: &Path) -> Result> { log::debug!("spawning command {cmd:?}"); let mut child = cmd diff --git a/tools/cargo-miden/src/commands/mod.rs b/tools/cargo-miden/src/commands/mod.rs index 7f8f4d7ef..ab03fde5e 100644 --- a/tools/cargo-miden/src/commands/mod.rs +++ b/tools/cargo-miden/src/commands/mod.rs @@ -1,8 +1,10 @@ pub mod build; pub mod example_project; pub mod new_project; +pub mod test; pub use build::BuildCommand; pub(crate) use build::CargoOptions; pub use example_project::ExampleCommand; pub use new_project::NewCommand; +pub use test::TestCommand; diff --git a/tools/cargo-miden/src/commands/test.rs b/tools/cargo-miden/src/commands/test.rs new file mode 100644 index 000000000..fb62891d6 --- /dev/null +++ b/tools/cargo-miden/src/commands/test.rs @@ -0,0 +1,78 @@ +use std::{path::PathBuf, process::Command}; + +use anyhow::bail; +use clap::Args; + +use crate::{ + commands::{build, BuildCommand}, + BuildOutput, CommandOutput, OutputType, +}; + +/// Command-line arguments accepted by `cargo miden build`. +/// +/// All arguments following `build` are parsed by the `midenc` compiler's argument parser. +/// Cargo-specific options (`--release`, `--manifest-path`, `--workspace`, `--package`) +/// are recognized and forwarded to the underlying `cargo build` invocation. +/// All other options are passed to `midenc` for compilation. +#[derive(Clone, Debug, Args)] +#[command(disable_version_flag = true, trailing_var_arg = true)] +pub struct TestCommand { + /// Arguments parsed by midenc (includes cargo-compatible options). + #[arg(value_name = "ARG", allow_hyphen_values = true)] + pub args: Vec, +} + +impl TestCommand { + pub fn exec(self) -> anyhow::Result<()> { + let build = BuildCommand { + args: self.args.clone(), + }; + + let Some(CommandOutput::BuildCommandOutput { + output: BuildOutput::Masm { artifact_path }, + }) = build.exec(OutputType::Masm)? + else { + // This should never happend since we are hardcoding the output as MASM. + bail!("cargo miden test requires projects to be compiled to a masm artifact.") + }; + + let spawn_args = test_cargo_args(); + unsafe { + std::env::set_var("CREATED_PACKAGE", artifact_path); + } + + run_cargo_test(&spawn_args)?; + + Ok(()) + } +} + +/// Builds the argument vector for the underlying `cargo test` invocation. +fn test_cargo_args() -> Vec { + let mut args = vec!["test".to_string()]; + + // Add build-std flags required for Miden compilation + args.extend(["-Z", "build-std=std,core,alloc"].into_iter().map(|s| s.to_string())); + + // Flag required to enable tests in test-harness-lib + args.extend( + ["--features", "miden-test-harness-macros/test-flag"] + .into_iter() + .map(|s| s.to_string()), + ); +} + +fn run_cargo_test(spawn_args: &[String]) -> anyhow::Result<()> { + let cargo_path = std::env::var("CARGO") + .map(PathBuf::from) + .ok() + .unwrap_or_else(|| PathBuf::from("cargo")); + + let mut cargo = Command::new(&cargo_path); + + cargo.args(spawn_args); + + let artifacts = build::spawn_cargo(cargo, &cargo_path)?; + + Ok(()) +} diff --git a/tools/cargo-miden/src/lib.rs b/tools/cargo-miden/src/lib.rs index a89ea083f..59f601bd7 100644 --- a/tools/cargo-miden/src/lib.rs +++ b/tools/cargo-miden/src/lib.rs @@ -53,6 +53,10 @@ where Ok(Some(CommandOutput::NewCommandOutput { project_path })) } cli::CargoMidenCommand::Build(cmd) => cmd.exec(build_output_type), + cli::CargoMidenCommand::Test(cmd) => { + cmd.exec()?; + Ok(None) + } } } From ab6a99d5b4fbcbc65fd3d3583dd8158832b151a9 Mon Sep 17 00:00:00 2001 From: Tomas Fabrizio Orsi Date: Thu, 11 Dec 2025 15:29:04 -0300 Subject: [PATCH 02/20] feat: custom test harness initial commit Signed-off-by: Tomas Fabrizio Orsi --- test-harness/test-harness-lib/Cargo.toml | 20 +++ test-harness/test-harness-lib/src/lib.rs | 63 +++++++++ test-harness/test-harness-macros/Cargo.toml | 27 ++++ test-harness/test-harness-macros/src/lib.rs | 149 ++++++++++++++++++++ tools/cargo-miden/src/commands/test.rs | 3 +- 5 files changed, 261 insertions(+), 1 deletion(-) create mode 100644 test-harness/test-harness-lib/Cargo.toml create mode 100644 test-harness/test-harness-lib/src/lib.rs create mode 100644 test-harness/test-harness-macros/Cargo.toml create mode 100644 test-harness/test-harness-macros/src/lib.rs diff --git a/test-harness/test-harness-lib/Cargo.toml b/test-harness/test-harness-lib/Cargo.toml new file mode 100644 index 000000000..1ef3463b9 --- /dev/null +++ b/test-harness/test-harness-lib/Cargo.toml @@ -0,0 +1,20 @@ +[package] +name = "miden-test-harness-lib" +description = "Custom testing harness used in rust code targetting the miden compiler." +version.workspace = true +rust-version.workspace = true +authors.workspace = true +repository.workspace = true +categories.workspace = true +keywords.workspace = true +license.workspace = true +readme.workspace = true +edition.workspace = true + +[dev-dependencies] +libtest-mimic = "0.8.1" + +[dependencies] +libtest-mimic = "0.8.1" +inventory.workspace = true +clap.workspace = true diff --git a/test-harness/test-harness-lib/src/lib.rs b/test-harness/test-harness-lib/src/lib.rs new file mode 100644 index 000000000..cfef22cee --- /dev/null +++ b/test-harness/test-harness-lib/src/lib.rs @@ -0,0 +1,63 @@ +#![no_std] + +extern crate alloc; +use alloc::vec::Vec; + +// Only intended to be used by the macro crate +pub struct MidenTest { + pub name: &'static str, + // pub test_fn: fn() -> Result<(), libtest_mimic::Failed>, + pub test_fn: fn() -> (), +} + +inventory::collect!(MidenTest); + +pub use inventory::submit as miden_test_submit; + +// Wrapper used to make normal rust function. +fn runner(test: fn() -> ()) -> impl FnOnce() -> Result<(), libtest_mimic::Failed> + Send + 'static { + move || { + test(); + Ok(()) + } +} + +impl From for libtest_mimic::Trial { + fn from(value: MidenTest) -> Self { + libtest_mimic::Trial::test(value.name, runner(value.test_fn)) + } +} + +impl From<&MidenTest> for libtest_mimic::Trial { + fn from(value: &MidenTest) -> Self { + libtest_mimic::Trial::test(value.name, runner(value.test_fn)) + } +} + +pub struct MidenTestArguments(libtest_mimic::Arguments); + +impl From for libtest_mimic::Arguments { + fn from(value: MidenTestArguments) -> Self { + value.0 + } +} + +impl MidenTestArguments { + pub fn from_args() -> Self { + let inner_args = libtest_mimic::Arguments::from_args(); + Self(inner_args) + } +} + +pub fn run(args: MidenTestArguments) { + let args = args.into(); + + let tests: Vec = inventory::iter:: + .into_iter() + .map(|test| test.into()) + .collect(); + + let conclusion = libtest_mimic::run(&args, tests); + + conclusion.exit() +} diff --git a/test-harness/test-harness-macros/Cargo.toml b/test-harness/test-harness-macros/Cargo.toml new file mode 100644 index 000000000..7c1a8ff8d --- /dev/null +++ b/test-harness/test-harness-macros/Cargo.toml @@ -0,0 +1,27 @@ +[package] +name = "miden-test-harness-macros" +description = "Macros used to aid in test writing." +version.workspace = true +rust-version.workspace = true +authors.workspace = true +repository.workspace = true +categories.workspace = true +keywords.workspace = true +license.workspace = true +readme.workspace = true +edition.workspace = true + +[lib] +proc-macro = true + +[features] +test-flag = [] + +[dev-dependencies] +# Miden dependencies +miden-test-harness-lib.workspace = true + +[dependencies] +# External dependencies +quote.workspace = true +syn.workspace = true diff --git a/test-harness/test-harness-macros/src/lib.rs b/test-harness/test-harness-macros/src/lib.rs new file mode 100644 index 000000000..ce1b6f2a1 --- /dev/null +++ b/test-harness/test-harness-macros/src/lib.rs @@ -0,0 +1,149 @@ +use proc_macro::TokenStream; +use quote::quote; +use syn::{parse_macro_input, ItemFn}; + +#[cfg(feature = "test-flag")] +fn is_test() -> bool { + true +} + +#[cfg(not(feature = "test-flag"))] +fn is_test() -> bool { + // true // Uncomment to debug. + false +} + +fn load_account(function: &mut syn::ItemFn) { + let mut found_packages_vars = Vec::new(); + + for arg in function.sig.inputs.iter() { + let syn::FnArg::Typed(arg) = arg else { + continue; + }; + let syn::Type::Path(syn::TypePath { path, .. }) = *arg.ty.clone() else { + continue; + }; + // The last token in the segments vector is the actual type, the rest + // are just path specifiers. + let Some(maybe_package) = path.segments.last() else { + continue; + }; + + if maybe_package.ident != "Package" { + continue; + } + + let syn::Pat::Ident(package_var_binding) = arg.pat.as_ref() else { + panic!("Couldn't find binding for package") + }; + found_packages_vars.push(package_var_binding.ident.clone()); + } + + if found_packages_vars.len() > 1 { + let identifiers = found_packages_vars + .iter() + .map(|ident| ident.to_string()) + .collect::>() + .join(", "); + + panic!( + " +Detected that all of the following variables are `Package`s: {identifiers} + +#[miden_test] only supports having a single `Package` in its argument list." + ) + } + + let Some(package_binding_name) = found_packages_vars.first() else { + // If there are no variables with `Package` as its value, simply ignore it. + return; + }; + + // This is env var is set by `cargo miden test`. + let package_path = std::env::var("CREATED_PACKAGE").unwrap(); + + let load_package: Vec = syn::parse_quote! { + let path = #package_path; + let bytes = std::fs::read(path).unwrap(); + let #package_binding_name = miden_mast_package::Package::read_from_bytes(&bytes).unwrap(); + }; + + // We add the the lines required to load the generated Package. + for (i, package) in load_package.iter().enumerate() { + function.block.as_mut().stmts.insert(i, package.clone()); + } +} + +#[proc_macro_attribute] +pub fn miden_test( + _attr: proc_macro::TokenStream, + item: proc_macro::TokenStream, +) -> proc_macro::TokenStream { + let mut input_fn = parse_macro_input!(item as ItemFn); + + let fn_ident = input_fn.sig.ident.clone(); + let fn_name = fn_ident.clone().span().source_text().unwrap(); + + load_account(&mut input_fn); + + input_fn.sig.inputs.clear(); + + let function = quote! { + miden_test_harness_lib::miden_test_submit!( + miden_test_harness_lib::MidenTest { + name: #fn_name, + test_fn: #fn_ident, + } + ); + + #[cfg(test)] + #input_fn + }; + + TokenStream::from(function) +} + +#[proc_macro_attribute] +pub fn miden_test_block( + _attr: proc_macro::TokenStream, + item: proc_macro::TokenStream, +) -> proc_macro::TokenStream { + let mut input_module = parse_macro_input!(item as syn::ItemMod); + + // We add an internal "use" here in order for the tests inside the `mod tests` + // block to use the `miden_test` macro without needing to pass the full path. + let internal_use = syn::parse_quote! { + use miden_test_harness_macros::miden_test; + }; + input_module.content.as_mut().unwrap().1.insert(0, internal_use); + + let module = if is_test() { + quote! { + #input_module + } + } else { + quote! {} + }; + + let main_function = if is_test() { + quote! { + use miden_test_harness_lib; + + fn main() { + let args = miden_test_harness_lib::MidenTestArguments::from_args(); + + miden_test_harness_lib::run(args); + } + } + } else { + quote! {} + }; + + let block = quote! { + #module + + #main_function + }; + + block.into() +} diff --git a/tools/cargo-miden/src/commands/test.rs b/tools/cargo-miden/src/commands/test.rs index fb62891d6..f8ea94244 100644 --- a/tools/cargo-miden/src/commands/test.rs +++ b/tools/cargo-miden/src/commands/test.rs @@ -60,6 +60,7 @@ fn test_cargo_args() -> Vec { .into_iter() .map(|s| s.to_string()), ); + args } fn run_cargo_test(spawn_args: &[String]) -> anyhow::Result<()> { @@ -72,7 +73,7 @@ fn run_cargo_test(spawn_args: &[String]) -> anyhow::Result<()> { cargo.args(spawn_args); - let artifacts = build::spawn_cargo(cargo, &cargo_path)?; + let _artifacts = build::spawn_cargo(cargo, &cargo_path)?; Ok(()) } From 59322706f69deba09b8524e1be9da7d767835590 Mon Sep 17 00:00:00 2001 From: Tomas Fabrizio Orsi Date: Fri, 12 Dec 2025 16:38:18 -0300 Subject: [PATCH 03/20] feat: add test-harness library to Cargo.toml Signed-off-by: Tomas Fabrizio Orsi --- Cargo.lock | 36 ++++++++++++++++++++++++++++++++++++ Cargo.toml | 3 +++ 2 files changed, 39 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 7fa5dd716..299f5e007 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1122,6 +1122,12 @@ dependencies = [ "windows-sys 0.61.2", ] +[[package]] +name = "escape8259" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5692dd7b5a1978a5aeb0ce83b7655c58ca8efdcb79d21036ea249da95afec2c6" + [[package]] name = "fallible-iterator" version = "0.3.0" @@ -1989,6 +1995,18 @@ dependencies = [ "vcpkg", ] +[[package]] +name = "libtest-mimic" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5297962ef19edda4ce33aaa484386e0a5b3d7f2f4e037cbeee00503ef6b29d33" +dependencies = [ + "anstream", + "anstyle", + "clap", + "escape8259", +] + [[package]] name = "linked-hash-map" version = "0.5.6" @@ -2712,6 +2730,24 @@ dependencies = [ name = "miden-stdlib-sys" version = "0.7.1" +[[package]] +name = "miden-test-harness-lib" +version = "0.5.1" +dependencies = [ + "clap", + "inventory", + "libtest-mimic", +] + +[[package]] +name = "miden-test-harness-macros" +version = "0.5.1" +dependencies = [ + "miden-test-harness-lib", + "quote", + "syn", +] + [[package]] name = "miden-thiserror" version = "1.0.59" diff --git a/Cargo.toml b/Cargo.toml index b87cb4de8..4b21a0b57 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,6 +19,7 @@ members = [ "tools/*", "tests/integration", "tests/integration-node", + "test-harness/*", ] exclude = [ "sdk/.cargo", @@ -150,6 +151,8 @@ midenc-session = { version = "0.5.1", path = "midenc-session" } cargo-miden = { version = "0.5.1", path = "tools/cargo-miden" } miden-integration-tests = { path = "tests/integration" } midenc-expect-test = { path = "tools/expect-test" } +miden-test-harness-lib = { path = "test-harness/test-harness-lib" } +miden-test-harness-macros = { path = "test-harness/test-harness-macros" } [patch.crates-io] #miden-assembly = { git = "https://github.com/0xMiden/miden-vm", rev = "614cd7f9b52f45238b0ab59c71ebb49325051e5d" } From 24d1be041d5a96c7f1a61de6f7ce0c0e9a46cc9a Mon Sep 17 00:00:00 2001 From: Tomas Fabrizio Orsi Date: Fri, 12 Dec 2025 11:38:57 -0300 Subject: [PATCH 04/20] feat: update counter-contract example with #[miden-test] Signed-off-by: Tomas Fabrizio Orsi --- examples/counter-contract/Cargo.lock | 9 +++ examples/counter-contract/Cargo.toml | 1 + examples/counter-contract/src/lib.rs | 87 +++++++++++++++++++++------- 3 files changed, 76 insertions(+), 21 deletions(-) diff --git a/examples/counter-contract/Cargo.lock b/examples/counter-contract/Cargo.lock index 94ff57c22..1662f41d7 100644 --- a/examples/counter-contract/Cargo.lock +++ b/examples/counter-contract/Cargo.lock @@ -188,6 +188,7 @@ name = "counter-contract" version = "0.1.0" dependencies = [ "miden", + "miden-test-harness-macros", ] [[package]] @@ -1061,6 +1062,14 @@ version = "0.7.0" name = "miden-stdlib-sys" version = "0.7.1" +[[package]] +name = "miden-test-harness-macros" +version = "0.5.1" +dependencies = [ + "quote", + "syn", +] + [[package]] name = "miden-utils-diagnostics" version = "0.19.1" diff --git a/examples/counter-contract/Cargo.toml b/examples/counter-contract/Cargo.toml index b0fab6cd0..41ce997ab 100644 --- a/examples/counter-contract/Cargo.toml +++ b/examples/counter-contract/Cargo.toml @@ -11,6 +11,7 @@ crate-type = ["cdylib"] [dependencies] miden = { path = "../../sdk/sdk" } +miden-test-harness-macros = { path = "../../test-harness/test-harness-macros"} [package.metadata.component] package = "miden:counter-contract" diff --git a/examples/counter-contract/src/lib.rs b/examples/counter-contract/src/lib.rs index 2b7352478..6665bbf52 100644 --- a/examples/counter-contract/src/lib.rs +++ b/examples/counter-contract/src/lib.rs @@ -1,35 +1,80 @@ // Do not link against libstd (i.e. anything defined in `std::`) -#![no_std] +#![cfg_attr(not(test), no_std)] // However, we could still use some standard library types while // remaining no-std compatible, if we uncommented the following lines: // // extern crate alloc; -use miden::{component, felt, Felt, StorageMap, StorageMapAccess, Word}; +use miden_test_harness_macros::miden_test_block; -/// Main contract structure for the counter example. -#[component] -struct CounterContract { - /// Storage map holding the counter value. - #[storage(slot(0), description = "counter contract storage map")] - count_map: StorageMap, +#[cfg(not(test))] +mod component { + use miden::{component, felt, Felt, StorageMap, StorageMapAccess, Word}; + + /// Main contract structure for the counter example. + #[component] + struct CounterContract { + /// Storage map holding the counter value. + #[storage(slot(0), description = "counter contract storage map")] + count_map: StorageMap, + } + + #[component] + impl CounterContract { + /// Returns the current counter value stored in the contract's storage map. + pub fn get_count(&self) -> Felt { + let key = Word::from([felt!(0), felt!(0), felt!(0), felt!(1)]); + self.count_map.get(&key) + } + + /// Increments the counter value stored in the contract's storage map by one. + pub fn increment_count(&self) -> Felt { + let key = Word::from([felt!(0), felt!(0), felt!(0), felt!(1)]); + let current_value: Felt = self.count_map.get(&key); + let new_value = current_value + felt!(1); + self.count_map.set(key, new_value); + new_value + } + } } -#[component] -impl CounterContract { - /// Returns the current counter value stored in the contract's storage map. - pub fn get_count(&self) -> Felt { - let key = Word::from([felt!(0), felt!(0), felt!(0), felt!(1)]); - self.count_map.get(&key) +#[miden_test_block] +mod tests { + use winter_utils::Deserializable; + + // This tests loads the generated package in the `foo` variable and is then + // printed in line 50. + #[miden_test] + fn bar(bar: Package) { + std::dbg!(&bar); + assert_eq!(1, 1 + 1); + } + + // This test will fail at compile time because it is only legal to have a + // single package as an argument. The following error message is displayed: + // + // error: custom attribute panicked + // --> src/lib.rs:55:5 + // | + // 55 | #[miden_test] + // | ^^^^^^^^^^^^^ + // | + // = help: message: + // Detected that all of the following variables are `Package`s: foo, bar + // + // #[miden_test] only supports having a single `Package` in its argument list. + #[miden_test] + fn bing(foo: Package, bar: Package) { + std::dbg!(&foo); + assert_eq!(1, 1 + 1); } - /// Increments the counter value stored in the contract's storage map by one. - pub fn increment_count(&self) -> Felt { - let key = Word::from([felt!(0), felt!(0), felt!(0), felt!(1)]); - let current_value: Felt = self.count_map.get(&key); - let new_value = current_value + felt!(1); - self.count_map.set(key, new_value); - new_value + // This tests will not load the package since there is no argument declared + + // with the Package type. This test will simply behave as normal cargo test. + #[miden_test] + fn foo() { + assert_eq!(2, 1 + 1) } } From a10c5a90061741516300f19eccdab499853f021b Mon Sep 17 00:00:00 2001 From: Tomas Fabrizio Orsi Date: Fri, 12 Dec 2025 19:11:20 -0300 Subject: [PATCH 05/20] feat: re-export miden-mast-package and miden-objects via test-harness-lib Signed-off-by: Tomas Fabrizio Orsi --- examples/counter-contract/Cargo.toml | 1 + examples/counter-contract/src/lib.rs | 2 -- test-harness/test-harness-lib/Cargo.toml | 2 ++ test-harness/test-harness-lib/src/lib.rs | 8 ++++---- test-harness/test-harness-macros/src/lib.rs | 4 +++- 5 files changed, 10 insertions(+), 7 deletions(-) diff --git a/examples/counter-contract/Cargo.toml b/examples/counter-contract/Cargo.toml index 41ce997ab..2faa611e1 100644 --- a/examples/counter-contract/Cargo.toml +++ b/examples/counter-contract/Cargo.toml @@ -12,6 +12,7 @@ crate-type = ["cdylib"] [dependencies] miden = { path = "../../sdk/sdk" } miden-test-harness-macros = { path = "../../test-harness/test-harness-macros"} +miden-test-harness-lib = { path = "../../test-harness/test-harness-lib"} [package.metadata.component] package = "miden:counter-contract" diff --git a/examples/counter-contract/src/lib.rs b/examples/counter-contract/src/lib.rs index 6665bbf52..cf6684d26 100644 --- a/examples/counter-contract/src/lib.rs +++ b/examples/counter-contract/src/lib.rs @@ -41,8 +41,6 @@ mod component { #[miden_test_block] mod tests { - use winter_utils::Deserializable; - // This tests loads the generated package in the `foo` variable and is then // printed in line 50. #[miden_test] diff --git a/test-harness/test-harness-lib/Cargo.toml b/test-harness/test-harness-lib/Cargo.toml index 1ef3463b9..fd097c0e6 100644 --- a/test-harness/test-harness-lib/Cargo.toml +++ b/test-harness/test-harness-lib/Cargo.toml @@ -16,5 +16,7 @@ libtest-mimic = "0.8.1" [dependencies] libtest-mimic = "0.8.1" +miden-objects.workspace = true +miden-mast-package.workspace = true inventory.workspace = true clap.workspace = true diff --git a/test-harness/test-harness-lib/src/lib.rs b/test-harness/test-harness-lib/src/lib.rs index cfef22cee..32b2c8ca9 100644 --- a/test-harness/test-harness-lib/src/lib.rs +++ b/test-harness/test-harness-lib/src/lib.rs @@ -13,6 +13,8 @@ pub struct MidenTest { inventory::collect!(MidenTest); pub use inventory::submit as miden_test_submit; +pub use miden_mast_package; +pub use miden_objects::utils::Deserializable; // Wrapper used to make normal rust function. fn runner(test: fn() -> ()) -> impl FnOnce() -> Result<(), libtest_mimic::Failed> + Send + 'static { @@ -52,10 +54,8 @@ impl MidenTestArguments { pub fn run(args: MidenTestArguments) { let args = args.into(); - let tests: Vec = inventory::iter:: - .into_iter() - .map(|test| test.into()) - .collect(); + let tests: Vec = + inventory::iter::.into_iter().map(|test| test.into()).collect(); let conclusion = libtest_mimic::run(&args, tests); diff --git a/test-harness/test-harness-macros/src/lib.rs b/test-harness/test-harness-macros/src/lib.rs index ce1b6f2a1..304e6ed09 100644 --- a/test-harness/test-harness-macros/src/lib.rs +++ b/test-harness/test-harness-macros/src/lib.rs @@ -65,7 +65,8 @@ Detected that all of the following variables are `Package`s: {identifiers} let load_package: Vec = syn::parse_quote! { let path = #package_path; let bytes = std::fs::read(path).unwrap(); - let #package_binding_name = miden_mast_package::Package::read_from_bytes(&bytes).unwrap(); + let #package_binding_name = + ::read_from_bytes(&bytes).unwrap(); }; // We add the the lines required to load the generated Package. @@ -128,6 +129,7 @@ pub fn miden_test_block( let main_function = if is_test() { quote! { use miden_test_harness_lib; + use miden_test_harness_lib::Deserializable; fn main() { let args = miden_test_harness_lib::MidenTestArguments::from_args(); From 519ba8fbb2b930814cb22db8281b1066d552e342 Mon Sep 17 00:00:00 2001 From: Tomas Fabrizio Orsi Date: Fri, 12 Dec 2025 19:15:43 -0300 Subject: [PATCH 06/20] feat: use custom test harness Signed-off-by: Tomas Fabrizio Orsi --- examples/counter-contract/Cargo.toml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/examples/counter-contract/Cargo.toml b/examples/counter-contract/Cargo.toml index 2faa611e1..50eeb2cba 100644 --- a/examples/counter-contract/Cargo.toml +++ b/examples/counter-contract/Cargo.toml @@ -20,3 +20,8 @@ package = "miden:counter-contract" [package.metadata.miden] project-kind = "account" supported-types = ["RegularAccountUpdatableCode"] + +[[test]] +name = "lib" +path = "src/lib.rs" +harness = false From 5bdf3dea0402d97cf8cb4d2f5ef09ca3004b0268 Mon Sep 17 00:00:00 2001 From: Tomas Fabrizio Orsi Date: Fri, 12 Dec 2025 17:03:09 -0300 Subject: [PATCH 07/20] feat: add miden-testing to test-harness Signed-off-by: Tomas Fabrizio Orsi --- test-harness/test-harness-lib/Cargo.toml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/test-harness/test-harness-lib/Cargo.toml b/test-harness/test-harness-lib/Cargo.toml index fd097c0e6..437aa2fe9 100644 --- a/test-harness/test-harness-lib/Cargo.toml +++ b/test-harness/test-harness-lib/Cargo.toml @@ -11,12 +11,10 @@ license.workspace = true readme.workspace = true edition.workspace = true -[dev-dependencies] -libtest-mimic = "0.8.1" - [dependencies] libtest-mimic = "0.8.1" -miden-objects.workspace = true +miden-objects = "0.12.4" miden-mast-package.workspace = true inventory.workspace = true clap.workspace = true +miden-testing = "0.12.4" From f7a8b4dfcc421c43916ab08aa8e5b21b6c47003e Mon Sep 17 00:00:00 2001 From: Tomas Fabrizio Orsi Date: Tue, 16 Dec 2025 16:22:59 -0300 Subject: [PATCH 08/20] nit: uncomment test that fails at compile time Signed-off-by: Tomas Fabrizio Orsi --- examples/counter-contract/src/lib.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/counter-contract/src/lib.rs b/examples/counter-contract/src/lib.rs index cf6684d26..b4c6b3df6 100644 --- a/examples/counter-contract/src/lib.rs +++ b/examples/counter-contract/src/lib.rs @@ -62,11 +62,11 @@ mod tests { // Detected that all of the following variables are `Package`s: foo, bar // // #[miden_test] only supports having a single `Package` in its argument list. - #[miden_test] - fn bing(foo: Package, bar: Package) { - std::dbg!(&foo); - assert_eq!(1, 1 + 1); - } + // #[miden_test] + // fn bing(foo: Package, bar: Package) { + // std::dbg!(&foo); + // assert_eq!(1, 1 + 1); + // } // This tests will not load the package since there is no argument declared From df9650a1d39fadd45e2ef6fff095e2e361ca3ba6 Mon Sep 17 00:00:00 2001 From: Tomas Fabrizio Orsi Date: Tue, 16 Dec 2025 16:58:43 -0300 Subject: [PATCH 09/20] refactor: split miden-test-harness-lib into 2 crates Signed-off-by: Tomas Fabrizio Orsi --- test-harness/test-harness-lib/Cargo.toml | 3 ++ .../src/{lib.rs => libtest.rs} | 37 +++++++++++-------- test-harness/test-harness-lib/src/mod.rs | 8 ++++ test-harness/test-harness-lib/src/reexport.rs | 2 + test-harness/test-harness-macros/src/lib.rs | 4 +- 5 files changed, 37 insertions(+), 17 deletions(-) rename test-harness/test-harness-lib/src/{lib.rs => libtest.rs} (66%) create mode 100644 test-harness/test-harness-lib/src/mod.rs create mode 100644 test-harness/test-harness-lib/src/reexport.rs diff --git a/test-harness/test-harness-lib/Cargo.toml b/test-harness/test-harness-lib/Cargo.toml index 437aa2fe9..aea94467b 100644 --- a/test-harness/test-harness-lib/Cargo.toml +++ b/test-harness/test-harness-lib/Cargo.toml @@ -11,6 +11,9 @@ license.workspace = true readme.workspace = true edition.workspace = true +[lib] +path = "src/mod.rs" + [dependencies] libtest-mimic = "0.8.1" miden-objects = "0.12.4" diff --git a/test-harness/test-harness-lib/src/lib.rs b/test-harness/test-harness-lib/src/libtest.rs similarity index 66% rename from test-harness/test-harness-lib/src/lib.rs rename to test-harness/test-harness-lib/src/libtest.rs index 32b2c8ca9..a9c876c86 100644 --- a/test-harness/test-harness-lib/src/lib.rs +++ b/test-harness/test-harness-lib/src/libtest.rs @@ -1,28 +1,23 @@ -#![no_std] - -extern crate alloc; use alloc::vec::Vec; -// Only intended to be used by the macro crate +// ============================= Test function ================================ + +/// Struct that represents a function marked with #[miden-test]. +/// NOTE: This structure is only intended to be used by the +/// miden-test-harness-macros crate. pub struct MidenTest { + /// The name of the test, normally whatever text is followed by the `fn` + /// keyword.. pub name: &'static str, - // pub test_fn: fn() -> Result<(), libtest_mimic::Failed>, + + /// Actual test function. pub test_fn: fn() -> (), } +// Register MidenTest as a pluging in order for it to be collected. inventory::collect!(MidenTest); pub use inventory::submit as miden_test_submit; -pub use miden_mast_package; -pub use miden_objects::utils::Deserializable; - -// Wrapper used to make normal rust function. -fn runner(test: fn() -> ()) -> impl FnOnce() -> Result<(), libtest_mimic::Failed> + Send + 'static { - move || { - test(); - Ok(()) - } -} impl From for libtest_mimic::Trial { fn from(value: MidenTest) -> Self { @@ -44,6 +39,8 @@ impl From for libtest_mimic::Arguments { } } +// ============================= Test arguments ================================ + impl MidenTestArguments { pub fn from_args() -> Self { let inner_args = libtest_mimic::Arguments::from_args(); @@ -51,6 +48,16 @@ impl MidenTestArguments { } } +// Wrapper used to make normal rust function with libtest. +fn runner(test: fn() -> ()) -> impl FnOnce() -> Result<(), libtest_mimic::Failed> + Send + 'static { + move || { + test(); + Ok(()) + } +} + +// ============================ Executing tests =============================== + pub fn run(args: MidenTestArguments) { let args = args.into(); diff --git a/test-harness/test-harness-lib/src/mod.rs b/test-harness/test-harness-lib/src/mod.rs new file mode 100644 index 000000000..4341adb70 --- /dev/null +++ b/test-harness/test-harness-lib/src/mod.rs @@ -0,0 +1,8 @@ +#![no_std] + +extern crate alloc; + +pub mod libtest; +pub mod reexport; + +pub use libtest::*; diff --git a/test-harness/test-harness-lib/src/reexport.rs b/test-harness/test-harness-lib/src/reexport.rs new file mode 100644 index 000000000..b8f3f261f --- /dev/null +++ b/test-harness/test-harness-lib/src/reexport.rs @@ -0,0 +1,2 @@ +pub use miden_mast_package as __miden_test_harness_miden_mast_package; +pub use miden_objects::utils::Deserializable as __miden_test_harness_Deserialzable; diff --git a/test-harness/test-harness-macros/src/lib.rs b/test-harness/test-harness-macros/src/lib.rs index 304e6ed09..c67762c15 100644 --- a/test-harness/test-harness-macros/src/lib.rs +++ b/test-harness/test-harness-macros/src/lib.rs @@ -66,7 +66,8 @@ Detected that all of the following variables are `Package`s: {identifiers} let path = #package_path; let bytes = std::fs::read(path).unwrap(); let #package_binding_name = - ::read_from_bytes(&bytes).unwrap(); + ::read_from_bytes(&bytes).unwrap(); }; // We add the the lines required to load the generated Package. @@ -129,7 +130,6 @@ pub fn miden_test_block( let main_function = if is_test() { quote! { use miden_test_harness_lib; - use miden_test_harness_lib::Deserializable; fn main() { let args = miden_test_harness_lib::MidenTestArguments::from_args(); From 2891eb63955a57535e9a30921bcff25592c012b4 Mon Sep 17 00:00:00 2001 From: Tomas Fabrizio Orsi Date: Tue, 16 Dec 2025 17:31:43 -0300 Subject: [PATCH 10/20] feat: add Context struct Signed-off-by: Tomas Fabrizio Orsi --- test-harness/test-harness-lib/src/mod.rs | 1 + test-harness/test-harness-lib/src/reexport.rs | 2 ++ test-harness/test-harness-lib/src/utils.rs | 14 ++++++++++++++ 3 files changed, 17 insertions(+) create mode 100644 test-harness/test-harness-lib/src/utils.rs diff --git a/test-harness/test-harness-lib/src/mod.rs b/test-harness/test-harness-lib/src/mod.rs index 4341adb70..a7b943679 100644 --- a/test-harness/test-harness-lib/src/mod.rs +++ b/test-harness/test-harness-lib/src/mod.rs @@ -4,5 +4,6 @@ extern crate alloc; pub mod libtest; pub mod reexport; +pub mod utils; pub use libtest::*; diff --git a/test-harness/test-harness-lib/src/reexport.rs b/test-harness/test-harness-lib/src/reexport.rs index b8f3f261f..990427a84 100644 --- a/test-harness/test-harness-lib/src/reexport.rs +++ b/test-harness/test-harness-lib/src/reexport.rs @@ -1,2 +1,4 @@ +// Miden pub use miden_mast_package as __miden_test_harness_miden_mast_package; pub use miden_objects::utils::Deserializable as __miden_test_harness_Deserialzable; +pub use miden_testing::*; diff --git a/test-harness/test-harness-lib/src/utils.rs b/test-harness/test-harness-lib/src/utils.rs new file mode 100644 index 000000000..2018150dc --- /dev/null +++ b/test-harness/test-harness-lib/src/utils.rs @@ -0,0 +1,14 @@ +use crate::reexport::*; + +/// Wrapper struct containing +pub struct Context { + mock_chain: MockChain, +} + +impl Context { + pub fn new(builder: MockChainBuilder) -> Self { + let mock_chain = builder.build().expect("Failed to build MockChain"); + + Context { mock_chain } + } +} From 9c28ba8f06ce451aae7c0dc60dbb9de404421434 Mon Sep 17 00:00:00 2001 From: Tomas Fabrizio Orsi Date: Wed, 17 Dec 2025 14:23:40 -0300 Subject: [PATCH 11/20] feat: get_binding_and_type helper function Signed-off-by: Tomas Fabrizio Orsi --- test-harness/test-harness-macros/src/lib.rs | 40 +++++++++++++-------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/test-harness/test-harness-macros/src/lib.rs b/test-harness/test-harness-macros/src/lib.rs index c67762c15..b1433fd95 100644 --- a/test-harness/test-harness-macros/src/lib.rs +++ b/test-harness/test-harness-macros/src/lib.rs @@ -13,30 +13,40 @@ fn is_test() -> bool { false } +// Returns the identifier for a specific FnArg +fn get_binding_and_type(fn_arg: &syn::FnArg) -> Option<(&syn::PatIdent, &syn::PathSegment)> { + let syn::FnArg::Typed(arg) = fn_arg else { + return None; + }; + + let syn::Type::Path(syn::TypePath { path, .. }) = arg.ty.as_ref() else { + return None; + }; + + // The last token in the segments vector is the actual type, the rest + // are just path specifiers. + let path_segment = path.segments.last()?; + + let syn::Pat::Ident(binding) = arg.pat.as_ref() else { + return None; + }; + + Some((binding, path_segment)) +} + fn load_account(function: &mut syn::ItemFn) { let mut found_packages_vars = Vec::new(); - for arg in function.sig.inputs.iter() { - let syn::FnArg::Typed(arg) = arg else { - continue; - }; - let syn::Type::Path(syn::TypePath { path, .. }) = *arg.ty.clone() else { - continue; - }; - // The last token in the segments vector is the actual type, the rest - // are just path specifiers. - let Some(maybe_package) = path.segments.last() else { + for fn_arg in function.sig.inputs.iter() { + let Some((binding, var_type)) = get_binding_and_type(fn_arg) else { continue; }; - if maybe_package.ident != "Package" { + if var_type.ident != "Package" { continue; } - let syn::Pat::Ident(package_var_binding) = arg.pat.as_ref() else { - panic!("Couldn't find binding for package") - }; - found_packages_vars.push(package_var_binding.ident.clone()); + found_packages_vars.push(binding.ident.clone()); } if found_packages_vars.len() > 1 { From 2d67fc2eb23982cec170424778f1fa732fdd3e5a Mon Sep 17 00:00:00 2001 From: Tomas Fabrizio Orsi Date: Wed, 17 Dec 2025 15:01:49 -0300 Subject: [PATCH 12/20] refactor: load_package now consumes 'Package' related tokens, leaves the rest untouched Additionally, renamed the function from load_account and added documentation. Signed-off-by: Tomas Fabrizio Orsi --- test-harness/test-harness-macros/src/lib.rs | 47 ++++++++++++++------- 1 file changed, 31 insertions(+), 16 deletions(-) diff --git a/test-harness/test-harness-macros/src/lib.rs b/test-harness/test-harness-macros/src/lib.rs index b1433fd95..1893c2e01 100644 --- a/test-harness/test-harness-macros/src/lib.rs +++ b/test-harness/test-harness-macros/src/lib.rs @@ -34,20 +34,35 @@ fn get_binding_and_type(fn_arg: &syn::FnArg) -> Option<(&syn::PatIdent, &syn::Pa Some((binding, path_segment)) } -fn load_account(function: &mut syn::ItemFn) { +/// Parse the arguments of a `#[miden-test]` function and check for `Package`s. +/// +/// If the function has a single `Package` as argument, then it is removed from +/// the argument list and the boilerplate code to load the generated `Package` +/// into a variable will be generated. The name of the variable will match the +/// one used as argument. +/// +/// This will "consume" all the tokens that are of type `Package`. +fn load_package(function: &mut syn::ItemFn) { let mut found_packages_vars = Vec::new(); - for fn_arg in function.sig.inputs.iter() { - let Some((binding, var_type)) = get_binding_and_type(fn_arg) else { - continue; - }; + let fn_args = &mut function.sig.inputs; - if var_type.ident != "Package" { - continue; - } + *fn_args = fn_args + .iter() + .filter(|&fn_arg| { + let Some((binding, var_type)) = get_binding_and_type(fn_arg) else { + return true; + }; - found_packages_vars.push(binding.ident.clone()); - } + if var_type.ident != "Package" { + return true; + } + + found_packages_vars.push(binding.ident.clone()); + false + }) + .cloned() + .collect(); if found_packages_vars.len() > 1 { let identifiers = found_packages_vars @@ -65,11 +80,12 @@ Detected that all of the following variables are `Package`s: {identifiers} } let Some(package_binding_name) = found_packages_vars.first() else { - // If there are no variables with `Package` as its value, simply ignore it. + // If there are no variables with `Package` as its type, then don't load + // the `Package`. return; }; - // This is env var is set by `cargo miden test`. + // This env var is set by `cargo miden test`. let package_path = std::env::var("CREATED_PACKAGE").unwrap(); let load_package: Vec = syn::parse_quote! { @@ -80,7 +96,8 @@ Detected that all of the following variables are `Package`s: {identifiers} as miden_test_harness_lib::reexport::__miden_test_harness_Deserialzable>::read_from_bytes(&bytes).unwrap(); }; - // We add the the lines required to load the generated Package. + // We add the required lines to load the generated Package right at the + // beginning of the function. for (i, package) in load_package.iter().enumerate() { function.block.as_mut().stmts.insert(i, package.clone()); } @@ -96,9 +113,7 @@ pub fn miden_test( let fn_ident = input_fn.sig.ident.clone(); let fn_name = fn_ident.clone().span().source_text().unwrap(); - load_account(&mut input_fn); - - input_fn.sig.inputs.clear(); + load_package(&mut input_fn); let function = quote! { miden_test_harness_lib::miden_test_submit!( From 5a321a2e073c679db8c8dcfca67c61f11a35bc91 Mon Sep 17 00:00:00 2001 From: Tomas Fabrizio Orsi Date: Wed, 17 Dec 2025 16:13:09 -0300 Subject: [PATCH 13/20] feat: add load_mock_chain function Signed-off-by: Tomas Fabrizio Orsi --- test-harness/test-harness-lib/src/reexport.rs | 2 +- test-harness/test-harness-lib/src/utils.rs | 2 +- test-harness/test-harness-macros/src/lib.rs | 55 +++++++++++++++++++ 3 files changed, 57 insertions(+), 2 deletions(-) diff --git a/test-harness/test-harness-lib/src/reexport.rs b/test-harness/test-harness-lib/src/reexport.rs index 990427a84..30bea0d71 100644 --- a/test-harness/test-harness-lib/src/reexport.rs +++ b/test-harness/test-harness-lib/src/reexport.rs @@ -1,4 +1,4 @@ // Miden pub use miden_mast_package as __miden_test_harness_miden_mast_package; pub use miden_objects::utils::Deserializable as __miden_test_harness_Deserialzable; -pub use miden_testing::*; +pub use miden_testing; diff --git a/test-harness/test-harness-lib/src/utils.rs b/test-harness/test-harness-lib/src/utils.rs index 2018150dc..5b50591c7 100644 --- a/test-harness/test-harness-lib/src/utils.rs +++ b/test-harness/test-harness-lib/src/utils.rs @@ -1,4 +1,4 @@ -use crate::reexport::*; +use crate::reexport::miden_testing::*; /// Wrapper struct containing pub struct Context { diff --git a/test-harness/test-harness-macros/src/lib.rs b/test-harness/test-harness-macros/src/lib.rs index 1893c2e01..40f3a14ba 100644 --- a/test-harness/test-harness-macros/src/lib.rs +++ b/test-harness/test-harness-macros/src/lib.rs @@ -103,6 +103,60 @@ Detected that all of the following variables are `Package`s: {identifiers} } } +fn load_mock_chain(function: &mut syn::ItemFn) { + let mut found_packages_vars = Vec::new(); + + let fn_args = &mut function.sig.inputs; + + *fn_args = fn_args + .iter() + .filter(|&fn_arg| { + let Some((binding, var_type)) = get_binding_and_type(fn_arg) else { + return true; + }; + + if var_type.ident != "MockChainBuilder" { + return true; + } + + found_packages_vars.push(binding.ident.clone()); + false + }) + .cloned() + .collect(); + + if found_packages_vars.len() > 1 { + let identifiers = found_packages_vars + .iter() + .map(|ident| ident.to_string()) + .collect::>() + .join(", "); + + panic!( + " +Detected that all of the following variables are `MockChainBuilder`s: {identifiers} + +#[miden_test] only supports having a single `MockChainBuilder` in its argument list." + ) + } + + let Some(mock_chain_builder_name) = found_packages_vars.first() else { + // If there are no variables with `MockChainBuilder` as its type, then don't load + // the `MockChainBuilder`. + return; + }; + + let load_mock_chain_builder: Vec = syn::parse_quote! { + let #mock_chain_builder_name = miden_test_harness_lib::reexport::miden_testing::MockChainBuilder::new(); + }; + + // We add the required lines to load the generated MockChainBuilder right at the + // beginning of the function. + for (i, package) in load_mock_chain_builder.iter().enumerate() { + function.block.as_mut().stmts.insert(i, package.clone()); + } +} + #[proc_macro_attribute] pub fn miden_test( _attr: proc_macro::TokenStream, @@ -114,6 +168,7 @@ pub fn miden_test( let fn_name = fn_ident.clone().span().source_text().unwrap(); load_package(&mut input_fn); + load_mock_chain(&mut input_fn); let function = quote! { miden_test_harness_lib::miden_test_submit!( From 3cd46767eb3ffc9738f9607f5a37b708d5712a47 Mon Sep 17 00:00:00 2001 From: Tomas Fabrizio Orsi Date: Wed, 17 Dec 2025 16:57:13 -0300 Subject: [PATCH 14/20] refactor: process_arguments function to generalize argument parsing Signed-off-by: Tomas Fabrizio Orsi --- test-harness/test-harness-macros/Cargo.toml | 3 +- test-harness/test-harness-macros/src/lib.rs | 95 +++++++++------------ 2 files changed, 42 insertions(+), 56 deletions(-) diff --git a/test-harness/test-harness-macros/Cargo.toml b/test-harness/test-harness-macros/Cargo.toml index 7c1a8ff8d..31f3e3470 100644 --- a/test-harness/test-harness-macros/Cargo.toml +++ b/test-harness/test-harness-macros/Cargo.toml @@ -17,11 +17,10 @@ proc-macro = true [features] test-flag = [] -[dev-dependencies] +[dependencies] # Miden dependencies miden-test-harness-lib.workspace = true -[dependencies] # External dependencies quote.workspace = true syn.workspace = true diff --git a/test-harness/test-harness-macros/src/lib.rs b/test-harness/test-harness-macros/src/lib.rs index 40f3a14ba..3dddd5cbe 100644 --- a/test-harness/test-harness-macros/src/lib.rs +++ b/test-harness/test-harness-macros/src/lib.rs @@ -1,3 +1,6 @@ +use miden_test_harness_lib::reexport::{ + __miden_test_harness_miden_mast_package::Package, miden_testing::*, +}; use proc_macro::TokenStream; use quote::quote; use syn::{parse_macro_input, ItemFn}; @@ -34,16 +37,17 @@ fn get_binding_and_type(fn_arg: &syn::FnArg) -> Option<(&syn::PatIdent, &syn::Pa Some((binding, path_segment)) } -/// Parse the arguments of a `#[miden-test]` function and check for `Package`s. -/// -/// If the function has a single `Package` as argument, then it is removed from -/// the argument list and the boilerplate code to load the generated `Package` -/// into a variable will be generated. The name of the variable will match the -/// one used as argument. -/// -/// This will "consume" all the tokens that are of type `Package`. -fn load_package(function: &mut syn::ItemFn) { - let mut found_packages_vars = Vec::new(); +/// Function that parses and consumes types T from `function`. `max_args` +/// represents the maximum amount of arguments of type T that `function` may +/// have. +fn process_arguments( + function: &mut syn::ItemFn, + max_args: usize, +) -> Result, String> { + // "T"'s name as used in the argument list. We skipt the whole path + let struct_name = std::any::type_name::().split("::").last().unwrap(); + + let mut found_vars = Vec::new(); let fn_args = &mut function.sig.inputs; @@ -54,31 +58,47 @@ fn load_package(function: &mut syn::ItemFn) { return true; }; - if var_type.ident != "Package" { + if var_type.ident != struct_name { return true; } - found_packages_vars.push(binding.ident.clone()); + found_vars.push(binding.ident.clone()); false }) .cloned() .collect(); - if found_packages_vars.len() > 1 { - let identifiers = found_packages_vars + if found_vars.len() > max_args { + let identifiers = found_vars .iter() .map(|ident| ident.to_string()) .collect::>() .join(", "); - panic!( + let err = format!( " -Detected that all of the following variables are `Package`s: {identifiers} +Detected that all of the following variables are `{struct_name}`s: {identifiers} -#[miden_test] only supports having a single `Package` in its argument list." - ) +#[miden_test] only supports having {max_args} `{struct_name}` in its argument list." + ); + return Err(err); } + Ok(found_vars) +} + +/// Parse the arguments of a `#[miden-test]` function and check for `Package`s. +/// +/// If the function has a single `Package` as argument, then it is removed from +/// the argument list and the boilerplate code to load the generated `Package` +/// into a variable will be generated. The name of the variable will match the +/// one used as argument. +/// +/// This will "consume" all the tokens that are of type `Package`. +fn load_package(function: &mut syn::ItemFn) { + let found_packages_vars = + process_arguments::(function, 1).unwrap_or_else(|err| panic!("{err}")); + let Some(package_binding_name) = found_packages_vars.first() else { // If there are no variables with `Package` as its type, then don't load // the `Package`. @@ -104,43 +124,10 @@ Detected that all of the following variables are `Package`s: {identifiers} } fn load_mock_chain(function: &mut syn::ItemFn) { - let mut found_packages_vars = Vec::new(); - - let fn_args = &mut function.sig.inputs; - - *fn_args = fn_args - .iter() - .filter(|&fn_arg| { - let Some((binding, var_type)) = get_binding_and_type(fn_arg) else { - return true; - }; - - if var_type.ident != "MockChainBuilder" { - return true; - } - - found_packages_vars.push(binding.ident.clone()); - false - }) - .cloned() - .collect(); - - if found_packages_vars.len() > 1 { - let identifiers = found_packages_vars - .iter() - .map(|ident| ident.to_string()) - .collect::>() - .join(", "); - - panic!( - " -Detected that all of the following variables are `MockChainBuilder`s: {identifiers} - -#[miden_test] only supports having a single `MockChainBuilder` in its argument list." - ) - } + let found_mock_chain = + process_arguments::(function, 1).unwrap_or_else(|err| panic!("{err}")); - let Some(mock_chain_builder_name) = found_packages_vars.first() else { + let Some(mock_chain_builder_name) = found_mock_chain.first() else { // If there are no variables with `MockChainBuilder` as its type, then don't load // the `MockChainBuilder`. return; From d61075ba0a8cd5bce8ed38b9aaebf90889d39c5b Mon Sep 17 00:00:00 2001 From: Tomas Fabrizio Orsi Date: Wed, 17 Dec 2025 16:58:53 -0300 Subject: [PATCH 15/20] feat: add MockChainBuilder to foo test Signed-off-by: Tomas Fabrizio Orsi --- examples/counter-contract/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/counter-contract/src/lib.rs b/examples/counter-contract/src/lib.rs index b4c6b3df6..2023e1c58 100644 --- a/examples/counter-contract/src/lib.rs +++ b/examples/counter-contract/src/lib.rs @@ -72,7 +72,7 @@ mod tests { // with the Package type. This test will simply behave as normal cargo test. #[miden_test] - fn foo() { + fn foo(chain: MockChainBuilder) { assert_eq!(2, 1 + 1) } } From e1183f21edb6dda3b91a88835dd9946d912c532a Mon Sep 17 00:00:00 2001 From: Tomas Fabrizio Orsi Date: Wed, 17 Dec 2025 18:31:46 -0300 Subject: [PATCH 16/20] fix: add mut to mock chain builder Signed-off-by: Tomas Fabrizio Orsi --- test-harness/test-harness-macros/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test-harness/test-harness-macros/src/lib.rs b/test-harness/test-harness-macros/src/lib.rs index 3dddd5cbe..c9062ec57 100644 --- a/test-harness/test-harness-macros/src/lib.rs +++ b/test-harness/test-harness-macros/src/lib.rs @@ -134,7 +134,7 @@ fn load_mock_chain(function: &mut syn::ItemFn) { }; let load_mock_chain_builder: Vec = syn::parse_quote! { - let #mock_chain_builder_name = miden_test_harness_lib::reexport::miden_testing::MockChainBuilder::new(); + let mut #mock_chain_builder_name = miden_test_harness_lib::reexport::miden_testing::MockChainBuilder::new(); }; // We add the required lines to load the generated MockChainBuilder right at the From c52c16b0674f09168b87f27dc0b234919052de55 Mon Sep 17 00:00:00 2001 From: Tomas Fabrizio Orsi Date: Wed, 17 Dec 2025 18:32:10 -0300 Subject: [PATCH 17/20] feat: add function with MockChain + Package Signed-off-by: Tomas Fabrizio Orsi --- examples/counter-contract/Cargo.toml | 4 +++ examples/counter-contract/src/lib.rs | 43 ++++++++++++++++++++++------ 2 files changed, 39 insertions(+), 8 deletions(-) diff --git a/examples/counter-contract/Cargo.toml b/examples/counter-contract/Cargo.toml index 50eeb2cba..c5a9376a3 100644 --- a/examples/counter-contract/Cargo.toml +++ b/examples/counter-contract/Cargo.toml @@ -14,6 +14,10 @@ miden = { path = "../../sdk/sdk" } miden-test-harness-macros = { path = "../../test-harness/test-harness-macros"} miden-test-harness-lib = { path = "../../test-harness/test-harness-lib"} +[dev-dependencies] +miden-objects = { version = "0.12", default-features = false } +miden-lib = { version = "0.12", default-features = false } + [package.metadata.component] package = "miden:counter-contract" diff --git a/examples/counter-contract/src/lib.rs b/examples/counter-contract/src/lib.rs index 2023e1c58..4673d9bd0 100644 --- a/examples/counter-contract/src/lib.rs +++ b/examples/counter-contract/src/lib.rs @@ -41,13 +41,18 @@ mod component { #[miden_test_block] mod tests { + use miden_lib::account::auth::AuthRpoFalcon512; + use miden_objects::account::{ + auth::AuthSecretKey, Account, AccountBuilder, AccountComponent, InitStorageData, + }; + // This tests loads the generated package in the `foo` variable and is then // printed in line 50. - #[miden_test] - fn bar(bar: Package) { - std::dbg!(&bar); - assert_eq!(1, 1 + 1); - } + // #[miden_test] + // fn bar(bar: Package) { + // std::dbg!(&bar); + // assert_eq!(1, 1 + 1); + // } // This test will fail at compile time because it is only legal to have a // single package as an argument. The following error message is displayed: @@ -69,10 +74,32 @@ mod tests { // } // This tests will not load the package since there is no argument declared - // with the Package type. This test will simply behave as normal cargo test. + // #[miden_test] + // fn foo(chain: MockChainBuilder) { + // assert_eq!(2, 1 + 1) + // } + #[miden_test] - fn foo(chain: MockChainBuilder) { - assert_eq!(2, 1 + 1) + fn load_generated_account(account: Package, mock: MockChainBuilder) { + let init_storage_data = InitStorageData::default(); + let account_component = + AccountComponent::from_package_with_init_data(&account, &init_storage_data).unwrap(); + + let (key_pair, auth_component) = { + let key_pair = AuthSecretKey::new_rpo_falcon512(); + let auth_component: AccountComponent = + AuthRpoFalcon512::new(key_pair.public_key().to_commitment()).into(); + (key_pair, auth_component) + }; + + let account = AccountBuilder::new(Default::default()) + .with_component(account_component) + .with_auth_component(auth_component) + .build() + .unwrap(); + + mock.add_account(account).unwrap(); + let chain = mock.build().unwrap(); } } From 40562708abf7415cdd0636ece68e399b72be7b22 Mon Sep 17 00:00:00 2001 From: Tomas Fabrizio Orsi Date: Wed, 17 Dec 2025 18:37:58 -0300 Subject: [PATCH 18/20] feat: update Cargo.lock Signed-off-by: Tomas Fabrizio Orsi --- Cargo.lock | 84 ++- examples/counter-contract/Cargo.lock | 753 ++++++++++++++++++++++++++- examples/counter-contract/src/lib.rs | 2 + 3 files changed, 810 insertions(+), 29 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 299f5e007..1baf84ac4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -150,6 +150,9 @@ name = "anyhow" version = "1.0.100" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a23eb6b1614318a8071c9b2521f36b424b2c83db5eb3a0fead4a6c0809af6e61" +dependencies = [ + "backtrace", +] [[package]] name = "anymap2" @@ -2305,6 +2308,17 @@ dependencies = [ "miden-stdlib-sys", ] +[[package]] +name = "miden-block-prover" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec766587e838664ded55fa926d0611244cac2fe23b7cec202d8db0a85d9e536e" +dependencies = [ + "miden-lib", + "miden-objects", + "thiserror 2.0.17", +] + [[package]] name = "miden-client" version = "0.12.3" @@ -2545,6 +2559,7 @@ dependencies = [ "miden-objects", "miden-processor", "miden-stdlib", + "rand", "regex", "thiserror 2.0.17", "walkdir", @@ -2630,9 +2645,9 @@ dependencies = [ [[package]] name = "miden-objects" -version = "0.12.3" +version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57ea15ca33d7735e08e81afd9c9f4f02fc0259ec019fcb4ec44192c205743553" +checksum = "ace4018bb2d6cdbcff4d86d8af5ade8efca9f0479f7e5775c7f09cfab5f91ebe" dependencies = [ "bech32", "getrandom 0.3.4", @@ -2646,10 +2661,12 @@ dependencies = [ "miden-utils-sync", "miden-verifier", "rand", + "rand_xoshiro", "semver 1.0.27", "serde", "thiserror 2.0.17", "toml 0.9.8", + "winter-rand-utils", ] [[package]] @@ -2737,6 +2754,9 @@ dependencies = [ "clap", "inventory", "libtest-mimic", + "miden-mast-package", + "miden-objects", + "miden-testing", ] [[package]] @@ -2748,6 +2768,26 @@ dependencies = [ "syn", ] +[[package]] +name = "miden-testing" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cda0d572d7415682ed168f616becf006825aa04b89692f9907cbb3e3586bf46a" +dependencies = [ + "anyhow", + "itertools 0.14.0", + "miden-block-prover", + "miden-lib", + "miden-objects", + "miden-processor", + "miden-tx", + "miden-tx-batch-prover", + "rand", + "rand_chacha", + "thiserror 2.0.17", + "winterfell", +] + [[package]] name = "miden-thiserror" version = "1.0.59" @@ -2784,6 +2824,16 @@ dependencies = [ "tokio", ] +[[package]] +name = "miden-tx-batch-prover" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f5029810b106654a1ec5d7d7123945db91b96bc4f4187715d0c2cfe0b0a53af4" +dependencies = [ + "miden-objects", + "miden-tx", +] + [[package]] name = "miden-utils-diagnostics" version = "0.19.1" @@ -4163,6 +4213,15 @@ dependencies = [ "rand_core 0.9.3", ] +[[package]] +name = "rand_xoshiro" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f703f4665700daf5512dcca5f43afa6af89f09db47fb56be587f80636bda2d41" +dependencies = [ + "rand_core 0.9.3", +] + [[package]] name = "ratatui" version = "0.29.0" @@ -6281,6 +6340,16 @@ dependencies = [ "winter-utils", ] +[[package]] +name = "winter-rand-utils" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4ff3b651754a7bd216f959764d0a5ab6f4b551c9a3a08fb9ccecbed594b614a" +dependencies = [ + "rand", + "winter-utils", +] + [[package]] name = "winter-utils" version = "0.13.1" @@ -6303,6 +6372,17 @@ dependencies = [ "winter-utils", ] +[[package]] +name = "winterfell" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43f824ddd5aec8ca6a54307f20c115485a8a919ea94dd26d496d856ca6185f4f" +dependencies = [ + "winter-air", + "winter-prover", + "winter-verifier", +] + [[package]] name = "wit-bindgen" version = "0.46.0" diff --git a/examples/counter-contract/Cargo.lock b/examples/counter-contract/Cargo.lock index 1662f41d7..68e1dc831 100644 --- a/examples/counter-contract/Cargo.lock +++ b/examples/counter-contract/Cargo.lock @@ -2,6 +2,31 @@ # It is not intended for manual editing. version = 4 +[[package]] +name = "Inflector" +version = "0.11.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe438c63458706e03479442743baae6c88256498e6431708f6dfc520a26515d3" +dependencies = [ + "lazy_static", + "regex", +] + +[[package]] +name = "addr2line" +version = "0.25.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b5d307320b3181d6d7954e663bd7c774a838b8220fe0593c86d9fb09f498b4b" +dependencies = [ + "gimli", +] + +[[package]] +name = "adler2" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" + [[package]] name = "aead" version = "0.5.2" @@ -21,11 +46,70 @@ dependencies = [ "memchr", ] +[[package]] +name = "allocator-api2" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" + +[[package]] +name = "anstream" +version = "0.6.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43d5b281e737544384e969a5ccad3f1cdd24b48086a0fc1b2a5262a26b8f4f4a" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is_terminal_polyfill", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5192cca8006f1fd4f7237516f40fa183bb07f8fbdfedaa0036de5ea9b0b45e78" + +[[package]] +name = "anstyle-parse" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e7644824f0aa2c7b9384579234ef10eb7efb6a0deb83f9630a49594dd9c15c2" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40c48f72fd53cd289104fc64099abca73db4166ad86ea0b4341abe65af83dadc" +dependencies = [ + "windows-sys 0.61.2", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "291e6a250ff86cd4a820112fb8898808a366d8f9f58ce16d1f538353ad55747d" +dependencies = [ + "anstyle", + "once_cell_polyfill", + "windows-sys 0.61.2", +] + [[package]] name = "anyhow" version = "1.0.100" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a23eb6b1614318a8071c9b2521f36b424b2c83db5eb3a0fead4a6c0809af6e61" +dependencies = [ + "backtrace", +] [[package]] name = "arrayref" @@ -54,6 +138,30 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" +[[package]] +name = "backtrace" +version = "0.3.76" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb531853791a215d7c62a30daf0dde835f381ab5de4589cfe7c649d2cbe92bd6" +dependencies = [ + "addr2line", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", + "windows-link 0.2.1", +] + +[[package]] +name = "backtrace-ext" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "537beee3be4a18fb023b570f80e3ae28003db9167a751266b259926e25539d50" +dependencies = [ + "backtrace", +] + [[package]] name = "base16ct" version = "0.2.0" @@ -127,6 +235,8 @@ version = "1.2.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "deec109607ca693028562ed836a5f1c4b8bd77755c4e132fc5ce11b0b6211ae7" dependencies = [ + "jobserver", + "libc", "shlex", ] @@ -171,6 +281,52 @@ dependencies = [ "zeroize", ] +[[package]] +name = "clap" +version = "4.5.53" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9e340e012a1bf4935f5282ed1436d1489548e8f72308207ea5df0e23d2d03f8" +dependencies = [ + "clap_builder", + "clap_derive", +] + +[[package]] +name = "clap_builder" +version = "4.5.53" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d76b5d13eaa18c901fd2f7fca939fefe3a0727a953561fefdf3b2922b8569d00" +dependencies = [ + "anstream", + "anstyle", + "clap_lex", + "strsim", +] + +[[package]] +name = "clap_derive" +version = "4.5.49" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a0b5487afeab2deb2ff4e03a807ad1a03ac532ff5a2cee5d86884440c7f7671" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "clap_lex" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1d728cc89cf3aee9ff92b05e62b19ee65a02b5702cff7d5a377e32c6ae29d8d" + +[[package]] +name = "colorchoice" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75" + [[package]] name = "const-oid" version = "0.9.6" @@ -188,6 +344,9 @@ name = "counter-contract" version = "0.1.0" dependencies = [ "miden", + "miden-lib", + "miden-objects", + "miden-test-harness-lib", "miden-test-harness-macros", ] @@ -408,12 +567,51 @@ dependencies = [ "syn", ] +[[package]] +name = "env_filter" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bf3c259d255ca70051b30e2e95b5446cdb8949ac4cd22c0d7fd634d89f568e2" +dependencies = [ + "log", + "regex", +] + +[[package]] +name = "env_logger" +version = "0.11.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13c863f0904021b108aa8b2f55046443e6b1ebde8fd4a15c399893aae4fa069f" +dependencies = [ + "anstream", + "anstyle", + "env_filter", + "jiff", + "log", +] + [[package]] name = "equivalent" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" +[[package]] +name = "errno" +version = "0.3.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" +dependencies = [ + "libc", + "windows-sys 0.59.0", +] + +[[package]] +name = "escape8259" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5692dd7b5a1978a5aeb0ce83b7655c58ca8efdcb79d21036ea249da95afec2c6" + [[package]] name = "ff" version = "0.13.1" @@ -454,6 +652,21 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" +[[package]] +name = "foldhash" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb" + +[[package]] +name = "fs-err" +version = "3.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "824f08d01d0f496b3eca4f001a13cf17690a6ee930043d20817f547455fd98f8" +dependencies = [ + "autocfg", +] + [[package]] name = "futures" version = "0.3.31" @@ -567,6 +780,12 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "gimli" +version = "0.32.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e629b9b98ef3dd8afe6ca2bd0f89306cec16d43d907889945bc5d6687f2f13c7" + [[package]] name = "glob" version = "0.3.2" @@ -590,7 +809,21 @@ version = "0.15.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5971ac85611da7067dbfcabef3c70ebb5606018acd9e2a3903a0da507521e0d5" dependencies = [ - "foldhash", + "foldhash 0.1.5", +] + +[[package]] +name = "hashbrown" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100" +dependencies = [ + "allocator-api2", + "equivalent", + "foldhash 0.2.0", + "rayon", + "serde", + "serde_core", ] [[package]] @@ -636,7 +869,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fe4cd85333e22411419a0bcae1297d25e58c9443848b11dc6a86fefe8c78a661" dependencies = [ "equivalent", - "hashbrown", + "hashbrown 0.15.4", "serde", ] @@ -649,6 +882,27 @@ dependencies = [ "generic-array", ] +[[package]] +name = "inventory" +version = "0.3.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc61209c082fbeb19919bee74b176221b27223e27b65d781eb91af24eb1fb46e" +dependencies = [ + "rustversion", +] + +[[package]] +name = "is_ci" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7655c9839580ee829dfacba1d1278c2b7883e50a277ff7541299489d6bdfdc45" + +[[package]] +name = "is_terminal_polyfill" +version = "1.70.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695" + [[package]] name = "itertools" version = "0.14.0" @@ -664,6 +918,40 @@ version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" +[[package]] +name = "jiff" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49cce2b81f2098e7e3efc35bc2e0a6b7abec9d34128283d7a26fa8f32a6dbb35" +dependencies = [ + "jiff-static", + "log", + "portable-atomic", + "portable-atomic-util", + "serde_core", +] + +[[package]] +name = "jiff-static" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "980af8b43c3ad5d8d349ace167ec8170839f753a42d233ba19e08afe1850fa69" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "jobserver" +version = "0.1.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9afb3de4395d6b3e67a780b6de64b51c978ecf11cb9a462c66be7d4ca9039d33" +dependencies = [ + "getrandom 0.3.3", + "libc", +] + [[package]] name = "js-sys" version = "0.3.77" @@ -751,6 +1039,24 @@ version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f9fbbcab51052fe104eb5e5d351cf728d30a5be1fe14d9be8a3b097481fb97de" +[[package]] +name = "libtest-mimic" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5297962ef19edda4ce33aaa484386e0a5b3d7f2f4e037cbeee00503ef6b29d33" +dependencies = [ + "anstream", + "anstyle", + "clap", + "escape8259", +] + +[[package]] +name = "linux-raw-sys" +version = "0.4.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab" + [[package]] name = "lock_api" version = "0.4.13" @@ -847,6 +1153,7 @@ dependencies = [ "miden-debug-types", "miden-utils-diagnostics", "midenc-hir-type", + "proptest", "regex", "rustc_version 0.4.1", "semver 1.0.26", @@ -883,6 +1190,17 @@ dependencies = [ "miden-stdlib-sys", ] +[[package]] +name = "miden-block-prover" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec766587e838664ded55fa926d0611244cac2fe23b7cec202d8db0a85d9e536e" +dependencies = [ + "miden-lib", + "miden-objects", + "thiserror", +] + [[package]] name = "miden-core" version = "0.19.1" @@ -908,10 +1226,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7eb82051002f9c64878d3b105a7b924de1ee92019231923380cf4ecd7b824f9a" dependencies = [ "blake3", + "cc", "chacha20poly1305", "ed25519-dalek", "flume", "glob", + "hashbrown 0.16.1", "hkdf", "k256", "miden-crypto-derive", @@ -921,6 +1241,7 @@ dependencies = [ "rand_chacha", "rand_core 0.9.3", "rand_hc", + "rayon", "sha3", "subtle", "thiserror", @@ -953,6 +1274,8 @@ dependencies = [ "miden-utils-indexing", "miden-utils-sync", "paste", + "serde", + "serde_spanned 1.0.0", "thiserror", ] @@ -965,6 +1288,25 @@ dependencies = [ "unicode-width 0.1.14", ] +[[package]] +name = "miden-lib" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "598582071e5b0ec835d06288857d4ddc0090a98bd4c17e408fa56b2c43f45d73" +dependencies = [ + "Inflector", + "fs-err", + "miden-assembly", + "miden-core", + "miden-objects", + "miden-processor", + "miden-stdlib", + "rand", + "regex", + "thiserror", + "walkdir", +] + [[package]] name = "miden-mast-package" version = "0.19.1" @@ -983,6 +1325,8 @@ version = "8.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eef536978f24a179d94fa2a41e4f92b28e7d8aab14b8d23df28ad2a3d7098b20" dependencies = [ + "backtrace", + "backtrace-ext", "cfg-if", "futures", "indenter", @@ -995,7 +1339,11 @@ dependencies = [ "serde_json", "spin", "strip-ansi-escapes", + "supports-color", + "supports-hyperlinks", + "supports-unicode", "syn", + "terminal_size", "textwrap", "thiserror", "trybuild", @@ -1015,9 +1363,9 @@ dependencies = [ [[package]] name = "miden-objects" -version = "0.12.1" +version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ef49472012d00be68f68dcbb13b4f28867fb6271c76c014bc555ef6e8e0958a" +checksum = "ace4018bb2d6cdbcff4d86d8af5ade8efca9f0479f7e5775c7f09cfab5f91ebe" dependencies = [ "bech32", "getrandom 0.3.3", @@ -1027,11 +1375,16 @@ dependencies = [ "miden-crypto", "miden-mast-package", "miden-processor", + "miden-stdlib", "miden-utils-sync", "miden-verifier", "rand", + "rand_xoshiro", "semver 1.0.26", + "serde", "thiserror", + "toml 0.9.2", + "winter-rand-utils", ] [[package]] @@ -1054,22 +1407,111 @@ dependencies = [ "winter-prover", ] +[[package]] +name = "miden-prover" +version = "0.19.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84c30a5d10baeec17b9336de8544cb7f9b96b32de757c4cfb8d95ee0521bb5cd" +dependencies = [ + "miden-air", + "miden-debug-types", + "miden-processor", + "tracing", + "winter-maybe-async", + "winter-prover", +] + [[package]] name = "miden-sdk-alloc" version = "0.7.0" +[[package]] +name = "miden-stdlib" +version = "0.19.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e90a5de45a1e6213ff17b66fff8accde0bbc64264e2c22bbcb9a895f8f3b767" +dependencies = [ + "env_logger", + "fs-err", + "miden-assembly", + "miden-core", + "miden-crypto", + "miden-processor", + "miden-utils-sync", + "thiserror", +] + [[package]] name = "miden-stdlib-sys" version = "0.7.1" +[[package]] +name = "miden-test-harness-lib" +version = "0.5.1" +dependencies = [ + "clap", + "inventory", + "libtest-mimic", + "miden-mast-package", + "miden-objects", + "miden-testing", +] + [[package]] name = "miden-test-harness-macros" version = "0.5.1" dependencies = [ + "miden-test-harness-lib", "quote", "syn", ] +[[package]] +name = "miden-testing" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cda0d572d7415682ed168f616becf006825aa04b89692f9907cbb3e3586bf46a" +dependencies = [ + "anyhow", + "itertools", + "miden-block-prover", + "miden-lib", + "miden-objects", + "miden-processor", + "miden-tx", + "miden-tx-batch-prover", + "rand", + "rand_chacha", + "thiserror", + "winterfell", +] + +[[package]] +name = "miden-tx" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d959064f99ce09fc38e9b6b4dc24c3fa80a63072bf5840a1074ca4ed5e9c911" +dependencies = [ + "miden-lib", + "miden-objects", + "miden-processor", + "miden-prover", + "miden-verifier", + "rand", + "thiserror", + "tokio", +] + +[[package]] +name = "miden-tx-batch-prover" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f5029810b106654a1ec5d7d7123945db91b96bc4f4187715d0c2cfe0b0a53af4" +dependencies = [ + "miden-objects", + "miden-tx", +] + [[package]] name = "miden-utils-diagnostics" version = "0.19.1" @@ -1100,6 +1542,7 @@ checksum = "feebe7d896c013ea74dbc98de978836606356a044d4ed3b61ded54d3b319d89f" dependencies = [ "lock_api", "loom", + "parking_lot", ] [[package]] @@ -1126,6 +1569,15 @@ dependencies = [ "thiserror", ] +[[package]] +name = "miniz_oxide" +version = "0.8.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fa76a2c86f704bdb222d66965fb3d63269ce38518b83cb0575fca855ebb6316" +dependencies = [ + "adler2", +] + [[package]] name = "nanorand" version = "0.7.0" @@ -1236,12 +1688,27 @@ dependencies = [ "libm", ] +[[package]] +name = "object" +version = "0.37.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff76201f031d8863c38aa7f905eca4f53abbfa15f609db4277d44cd8938f33fe" +dependencies = [ + "memchr", +] + [[package]] name = "once_cell" version = "1.21.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" +[[package]] +name = "once_cell_polyfill" +version = "1.70.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe" + [[package]] name = "opaque-debug" version = "0.3.1" @@ -1280,7 +1747,7 @@ dependencies = [ "libc", "redox_syscall", "smallvec", - "windows-targets", + "windows-targets 0.52.6", ] [[package]] @@ -1341,6 +1808,21 @@ dependencies = [ "universal-hash", ] +[[package]] +name = "portable-atomic" +version = "1.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f84267b20a16ea918e43c6a88433c2d54fa145c92a811b5b047ccbe153674483" + +[[package]] +name = "portable-atomic-util" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8a2f0d8d040d7848a709caf78912debcc3f33ee4b3cac47d73d1e1069e83507" +dependencies = [ + "portable-atomic", +] + [[package]] name = "ppv-lite86" version = "0.2.21" @@ -1375,6 +1857,21 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "proptest" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bee689443a2bd0a16ab0348b52ee43e3b2d1b1f931c8aa5c9f8de4c86fbe8c40" +dependencies = [ + "bitflags", + "num-traits", + "rand", + "rand_chacha", + "rand_xorshift", + "regex-syntax 0.8.5", + "unarray", +] + [[package]] name = "quote" version = "1.0.40" @@ -1396,6 +1893,7 @@ version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6db2770f06117d490610c7488547d543617b21bfa07796d7a12f6f1bd53850d1" dependencies = [ + "rand_chacha", "rand_core 0.9.3", ] @@ -1423,6 +1921,9 @@ name = "rand_core" version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38" +dependencies = [ + "getrandom 0.3.3", +] [[package]] name = "rand_hc" @@ -1433,6 +1934,24 @@ dependencies = [ "rand_core 0.6.4", ] +[[package]] +name = "rand_xorshift" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "513962919efc330f829edb2535844d1b912b0fbe2ca165d613e4e8788bb05a5a" +dependencies = [ + "rand_core 0.9.3", +] + +[[package]] +name = "rand_xoshiro" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f703f4665700daf5512dcca5f43afa6af89f09db47fb56be587f80636bda2d41" +dependencies = [ + "rand_core 0.9.3", +] + [[package]] name = "rayon" version = "1.11.0" @@ -1516,6 +2035,12 @@ dependencies = [ "subtle", ] +[[package]] +name = "rustc-demangle" +version = "0.1.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56f7d92ca342cea22a06f2121d944b4fd82af56988c270852495420f961d4ace" + [[package]] name = "rustc_version" version = "0.2.3" @@ -1534,6 +2059,19 @@ dependencies = [ "semver 1.0.26", ] +[[package]] +name = "rustix" +version = "0.38.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154" +dependencies = [ + "bitflags", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.59.0", +] + [[package]] name = "rustversion" version = "1.0.21" @@ -1607,18 +2145,28 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] name = "serde" -version = "1.0.219" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" +dependencies = [ + "serde_core", + "serde_derive", +] + +[[package]] +name = "serde_core" +version = "1.0.228" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6" +checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.219" +version = "1.0.228" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" +checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" dependencies = [ "proc-macro2", "quote", @@ -1759,12 +2307,39 @@ dependencies = [ "vte", ] +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + [[package]] name = "subtle" version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" +[[package]] +name = "supports-color" +version = "3.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c64fc7232dd8d2e4ac5ce4ef302b1d81e0b80d055b9d77c7c4f51f6aa4c867d6" +dependencies = [ + "is_ci", +] + +[[package]] +name = "supports-hyperlinks" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e396b6523b11ccb83120b115a0b7366de372751aa6edf19844dfb13a6af97e91" + +[[package]] +name = "supports-unicode" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7401a30af6cb5818bb64852270bb722533397edcfc7344954a38f420819ece2" + [[package]] name = "syn" version = "2.0.106" @@ -1788,7 +2363,7 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2111ef44dae28680ae9752bb89409e7310ca33a8c621ebe7b106cf5c928b3ac0" dependencies = [ - "windows-sys", + "windows-sys 0.59.0", ] [[package]] @@ -1800,6 +2375,16 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "terminal_size" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21bebf2b7c9e0a515f6e0f8c51dc0f8e4696391e6f1ff30379559f8365fb0df7" +dependencies = [ + "rustix", + "windows-sys 0.48.0", +] + [[package]] name = "textwrap" version = "0.16.2" @@ -2013,6 +2598,12 @@ version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1dccffe3ce07af9386bfd29e80c0ab1a8205a2fc34e4bcd40364df902cfa8f3f" +[[package]] +name = "unarray" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eaea85b334db583fe3274d12b4cd1880032beab409c0d774be044d4480ab9a94" + [[package]] name = "unicode-ident" version = "1.0.18" @@ -2053,6 +2644,12 @@ dependencies = [ "subtle", ] +[[package]] +name = "utf8parse" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" + [[package]] name = "valuable" version = "0.1.1" @@ -2185,7 +2782,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8c9d90bb93e764f6beabf1d02028c70a2156a6583e63ac4218dd07ef733368b0" dependencies = [ "bitflags", - "hashbrown", + "hashbrown 0.15.4", "indexmap", "semver 1.0.26", ] @@ -2212,7 +2809,7 @@ version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" dependencies = [ - "windows-sys", + "windows-sys 0.59.0", ] [[package]] @@ -2230,7 +2827,7 @@ dependencies = [ "windows-collections", "windows-core", "windows-future", - "windows-link", + "windows-link 0.1.3", "windows-numerics", ] @@ -2251,7 +2848,7 @@ checksum = "c0fdd3ddb90610c7638aa2b3a3ab2904fb9e5cdbecc643ddb3647212781c4ae3" dependencies = [ "windows-implement", "windows-interface", - "windows-link", + "windows-link 0.1.3", "windows-result", "windows-strings", ] @@ -2263,7 +2860,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fc6a41e98427b19fe4b73c550f060b59fa592d7d686537eebf9385621bfbad8e" dependencies = [ "windows-core", - "windows-link", + "windows-link 0.1.3", "windows-threading", ] @@ -2295,6 +2892,12 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5e6ad25900d524eaabdbbb96d20b4311e1e7ae1699af4fb28c17ae66c80d798a" +[[package]] +name = "windows-link" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" + [[package]] name = "windows-numerics" version = "0.2.0" @@ -2302,7 +2905,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9150af68066c4c5c07ddc0ce30421554771e528bde427614c61038bc2c92c2b1" dependencies = [ "windows-core", - "windows-link", + "windows-link 0.1.3", ] [[package]] @@ -2311,7 +2914,7 @@ version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "56f42bd332cc6c8eac5af113fc0c1fd6a8fd2aa08a0119358686e5160d0586c6" dependencies = [ - "windows-link", + "windows-link 0.1.3", ] [[package]] @@ -2320,7 +2923,16 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "56e6c93f3a0c3b36176cb1327a4958a0353d5d166c2a35cb268ace15e91d3b57" dependencies = [ - "windows-link", + "windows-link 0.1.3", +] + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets 0.48.5", ] [[package]] @@ -2329,7 +2941,31 @@ version = "0.59.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" dependencies = [ - "windows-targets", + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-sys" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" +dependencies = [ + "windows-link 0.2.1", +] + +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", ] [[package]] @@ -2338,14 +2974,14 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", "windows_i686_gnullvm", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", ] [[package]] @@ -2354,21 +2990,39 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b66463ad2e0ea3bbf808b7f1d371311c80e115c0b71d60efc142cafbcfb057a6" dependencies = [ - "windows-link", + "windows-link 0.1.3", ] +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + [[package]] name = "windows_aarch64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + [[package]] name = "windows_aarch64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" +[[package]] +name = "windows_i686_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + [[package]] name = "windows_i686_gnu" version = "0.52.6" @@ -2381,24 +3035,48 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" +[[package]] +name = "windows_i686_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + [[package]] name = "windows_i686_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + [[package]] name = "windows_x86_64_gnu" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + [[package]] name = "windows_x86_64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + [[package]] name = "windows_x86_64_msvc" version = "0.52.6" @@ -2484,6 +3162,16 @@ dependencies = [ "winter-utils", ] +[[package]] +name = "winter-rand-utils" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4ff3b651754a7bd216f959764d0a5ab6f4b551c9a3a08fb9ccecbed594b614a" +dependencies = [ + "rand", + "winter-utils", +] + [[package]] name = "winter-utils" version = "0.13.1" @@ -2503,6 +3191,17 @@ dependencies = [ "winter-utils", ] +[[package]] +name = "winterfell" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43f824ddd5aec8ca6a54307f20c115485a8a919ea94dd26d496d856ca6185f4f" +dependencies = [ + "winter-air", + "winter-prover", + "winter-verifier", +] + [[package]] name = "wit-bindgen" version = "0.46.0" diff --git a/examples/counter-contract/src/lib.rs b/examples/counter-contract/src/lib.rs index 4673d9bd0..17768b043 100644 --- a/examples/counter-contract/src/lib.rs +++ b/examples/counter-contract/src/lib.rs @@ -80,6 +80,8 @@ mod tests { // assert_eq!(2, 1 + 1) // } + // This function instantiates a `MockChain` with an `Account` with the + // `AccountComponent` generated from the rust code from this file.. #[miden_test] fn load_generated_account(account: Package, mock: MockChainBuilder) { let init_storage_data = InitStorageData::default(); From cc5ea76a6407bd415e48234ed958f581dc12acca Mon Sep 17 00:00:00 2001 From: Tomas Fabrizio Orsi Date: Wed, 17 Dec 2025 18:52:44 -0300 Subject: [PATCH 19/20] feat: remove Context struct Signed-off-by: Tomas Fabrizio Orsi --- test-harness/test-harness-lib/src/mod.rs | 1 - test-harness/test-harness-lib/src/utils.rs | 13 ------------- 2 files changed, 14 deletions(-) diff --git a/test-harness/test-harness-lib/src/mod.rs b/test-harness/test-harness-lib/src/mod.rs index a7b943679..4341adb70 100644 --- a/test-harness/test-harness-lib/src/mod.rs +++ b/test-harness/test-harness-lib/src/mod.rs @@ -4,6 +4,5 @@ extern crate alloc; pub mod libtest; pub mod reexport; -pub mod utils; pub use libtest::*; diff --git a/test-harness/test-harness-lib/src/utils.rs b/test-harness/test-harness-lib/src/utils.rs index 5b50591c7..8b1378917 100644 --- a/test-harness/test-harness-lib/src/utils.rs +++ b/test-harness/test-harness-lib/src/utils.rs @@ -1,14 +1 @@ -use crate::reexport::miden_testing::*; -/// Wrapper struct containing -pub struct Context { - mock_chain: MockChain, -} - -impl Context { - pub fn new(builder: MockChainBuilder) -> Self { - let mock_chain = builder.build().expect("Failed to build MockChain"); - - Context { mock_chain } - } -} From b4dd9a08a4753d5f25ee2c3e37e08fd413a10141 Mon Sep 17 00:00:00 2001 From: Tomas Fabrizio Orsi Date: Thu, 18 Dec 2025 14:30:56 -0300 Subject: [PATCH 20/20] feat: document tests Signed-off-by: Tomas Fabrizio Orsi --- examples/counter-contract/src/lib.rs | 34 ++++++++++++++++++---------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/examples/counter-contract/src/lib.rs b/examples/counter-contract/src/lib.rs index 17768b043..9dd5ec798 100644 --- a/examples/counter-contract/src/lib.rs +++ b/examples/counter-contract/src/lib.rs @@ -47,12 +47,12 @@ mod tests { }; // This tests loads the generated package in the `foo` variable and is then - // printed in line 50. - // #[miden_test] - // fn bar(bar: Package) { - // std::dbg!(&bar); - // assert_eq!(1, 1 + 1); - // } + // printed. + #[miden_test] + fn bar(bar: Package) { + std::dbg!(&bar); + assert_eq!(1, 1 + 1); + } // This test will fail at compile time because it is only legal to have a // single package as an argument. The following error message is displayed: @@ -67,18 +67,28 @@ mod tests { // Detected that all of the following variables are `Package`s: foo, bar // // #[miden_test] only supports having a single `Package` in its argument list. + // Uncomment to see the failure! // #[miden_test] // fn bing(foo: Package, bar: Package) { // std::dbg!(&foo); // assert_eq!(1, 1 + 1); // } - // This tests will not load the package since there is no argument declared - // with the Package type. This test will simply behave as normal cargo test. - // #[miden_test] - // fn foo(chain: MockChainBuilder) { - // assert_eq!(2, 1 + 1) - // } + // This tests will work as a traditional test, since neither `Package` nor + // `MockChainBuilder` are declared, the test harness does not produce any + // type of code generation. + #[miden_test] + fn foo() { + assert_eq!(2, 1 + 1) + } + + // This tests will work as a traditional test, since neither `Package` nor + // `MockChainBuilder` are declared, the test harness does not produce any + // type of code generation. + #[miden_test] + fn foo(chain: MockChainBuilder) { + assert_eq!(2, 1 + 1) + } // This function instantiates a `MockChain` with an `Account` with the // `AccountComponent` generated from the rust code from this file..