-
Notifications
You must be signed in to change notification settings - Fork 0
[Feature] Built-in Testing System (labcoat test) #2
Description
Goal
Enable developers to run contract tests with a single command (labcoat test) without installing Rust or
any extra dependencies. Labcoat should handle compilation, sandboxed runtime execution, and test
reporting automatically.
Scope
• Automatically compile the Rust contract to WASM (wasm32-wasi) using cargo build.
• Load the .wasm inside Node via WebAssembly.instantiate.
• Provide a mock Alkanes environment (sender, UTXOs, println).
• Auto-discover tests in ./tests/*.spec.js.
• Pretty-printed results with colored output.
Implementation Plan
• CLI Integration (src/cli/test.ts): Add new command labcoat test that builds the contract and runs
the test runner.
• Runtime Sandbox (src/runtime/test-runner.js): Implement TestRuntime class with mockSender,
mockUtxos, and call().
• Test Harness: Discover test files, execute exported functions, and report results.
• Assertions (src/runtime/assertions.js): Add minimal built-in assertions (expectEqual,
expectRevert).
• Optional Features: Add --trace, --json, and --watch flags in future iterations.
Example Developer Flow
labcoat init --template launchpad
cd launchpad
labcoat testDeliverables
• labcoat test command
• TestRuntime WASM sandbox
• Mocked Alkanes context (sender, UTXOs, println)
• Built-in assertions
• Test discovery and reporter