Skip to content

Latest commit

 

History

History
68 lines (46 loc) · 3.85 KB

File metadata and controls

68 lines (46 loc) · 3.85 KB

Testing

How to get bytecode fixtures, run regression tests, and update fixtures.

Bytecode fixtures

Regression tests use Sui Move .mv files under tests/bytecode/. These are not committed (they are large and gitignored). To obtain them:

  1. Clone and build Sui
    See tests/bytecode/README.md for exact commands: clone MystenLabs/sui, run sui move build in crates/sui-framework, then copy .mv files from the build output into:

    • tests/bytecode/move_stdlib/
    • tests/bytecode/sui_framework/
  2. If you skip this
    If no .mv files are present, integration tests that depend on bytecode are skipped and still pass. So cargo test and CI succeed without any fixtures.

Running regression tests

From the repo root:

cargo test

This runs all workspace tests, including the decompiler integration tests in crates/sui-decompiler/tests/decompiler_regression.rs:

  • decompile_bytecode_fixtures: for each .mv under tests/bytecode/, loads the module, decompiles, and checks that the output is non-empty and contains "module" or "address". Skipped if no .mv files.
  • decompile_then_sui_move_build: decompiles all .mv fixtures to Move 2024, writes a temporary package with Move.toml (edition = "2024") and all modules under [addresses] std = "0x1", sui = "0x2", then runs sui move build. Skipped if there are no .mv files or if sui is not in PATH; otherwise the test asserts that the build succeeds.

To run only the regression tests:

cargo test -p sui-decompiler decompile_bytecode_fixtures
cargo test -p sui-decompiler decompile_then_sui_move_build

Using real bytecode for regression (SUI_PATH)

To run the full “decompile → sui move build” regression locally or in CI:

  1. Prepare bytecode
    From a local Sui repo, build the framework and copy .mv files as described in tests/bytecode/README.md. Use your Sui clone path (e.g. /Users/mac/work/sui/sui) in the cp or rsync commands.

  2. Install Sui CLI
    The build step requires sui on your PATH (e.g. cargo install --path /path/to/sui sui or install from docs.sui.io).

  3. Run tests
    From the desui repo root:

    cargo test -p sui-decompiler decompile_then_sui_move_build

    If no .mv files exist under tests/bytecode/ or sui is not in PATH, the test is skipped and passes.

  4. CI (optional)
    In GitHub Actions you can enable the bytecode regression by setting the SUI_PATH environment variable (e.g. as a repository variable) to the path of a Sui checkout. The workflow will then copy bytecode from SUI_PATH into tests/bytecode/ before running tests. The existing job does not require SUI_PATH; without it, only unit tests and the decompile-only integration test run (or the build test is skipped). To have the build regression actually run in CI, sui must also be available on PATH in that job (e.g. build Sui and add it to PATH in a prior step when SUI_PATH is set).

No absolute paths are hardcoded in the test code; the bytecode root is derived from CARGO_MANIFEST_DIR relative to the crate.

Updating fixtures

  • Bytecode (.mv)
    Re-run the steps in tests/bytecode/README.md to refresh from a newer Sui revision. Replace or add files in tests/bytecode/move_stdlib/ and tests/bytecode/sui_framework/.

  • Move package for sui move build
    The minimal package under tests/fixtures/ is used to verify decompiled output. To update:

    • Edit tests/fixtures/Move.toml (e.g. bump Sui dependency rev).
    • Add or replace .move files in tests/fixtures/sources/ with decompiled or stub code.
    • Run sui move build from tests/fixtures/ to confirm it still builds. See tests/fixtures/README.md.