Skip to content

VM Tooling & Test Harness

Source: crates/vm-tooling, crates/vm-test-harness

Ashen ships two developer utilities for contract work:

  • vm-tooling: CLI for validation, disassembly, tracing, gas profiling, and tier predecode.
  • vm-test-harness: in-memory host for running Zig/Rust contracts without a full node.

Binary: vm-tooling (crate: crates/vm-tooling).

vm-tooling deploy-manifest --out deploy.json
vm-tooling elf-validate --elf contract.elf --manifest deploy.json
vm-tooling disasm --file contract.elf --start 0x0 --len 256
vm-tooling trace --file contract.elf --entry 0x0 --gas 1000000 --calldata-hex 0x...
vm-tooling gas --json
vm-tooling cache-stats --max-entries 1024 --max-bytes 268435456
vm-tooling predecode --elf contract.elf --tier jit --out contract.jit
vm-tooling predecode --elf contract.elf --tier aot --out contract.aot
vm-tooling gas-profile --file contract.elf --gas 1000000 --trace-out gas.json
vm-tooling gas-budget-check --config .gas-budgets.toml --contracts-dir contracts/
vm-tooling corpus-freeze --out corpus/ --cases 1000
vm-tooling corpus-run --dir corpus/ --tier interpreter

Crate: crates/vm-test-harness.

It provides a lightweight host for executing contracts with deterministic storage, events, and result parsing.

use vm_test_harness::{ContractHarness, TestHost, TestAccounts};
use vm_test_harness::{assert_call_ok, build_calldata};
let accounts = TestAccounts::default();
let mut host = TestHost::new();
host.seed_default_balances(&accounts);
let harness = ContractHarness::from_zig_artifact(
"contracts/my_token/zig-out/bin/my_token",
)
.expect("artifact exists")
.expect("load contract");
let calldata = build_calldata(*b"MINT", &accounts.alice);
let result = harness.call(&mut host, &accounts.alice, b"my_token", &calldata, 1_000_000);
assert_call_ok(&result, "mint should succeed");

The harness includes helpers for:

  • Event emission checks
  • Storage assertions
  • Host state fixtures
  • ABI-compatible calldata builders
  • docs/design/gas-profiler-flame-graphs.md
  • docs/design/simulation-mode.md
  • docs/design/cross-contract-call-tracing.md