A Nix flake provides a reproducible development environment with the Rust toolchain, LLVM/Clang, NEAR CLI, and all system dependencies pre-configured. Run nix develop to enter the shell; see nix-dev-environment.md for setup details (direnv integration, VS Code config, verification).
Outside Nix, the Rust toolchain version is pinned in rust-toolchain.toml; rustup handles installation automatically.
Build the MPC node:
cargo build -p mpc-node --releaseBuild the smart contract:
cargo near build non-reproducible-wasm --features abi --profile=release-contract \
--manifest-path crates/contract/Cargo.toml --lockedBoth the node and launcher Docker images also support reproducible builds, producing identical binaries from the same source.
- unit test -> a rust test in
/srcfolder (per crate) - integration test -> a rust test in
/testsfolder (per crate) - e2e test -> a rust test in the
crates/e2e-testscrate
- Unit and integration tests: Run with
cargo nextest run --cargo-profile=test-release - E2E tests: See the README in
crates/e2e-tests.
We use cargo insta for snapshot testing to guard against
unintended changes to ABIs, serialization formats, and deterministic outputs.
If a snapshot test fails, it means the output has changed relative to the
accepted .snap file. To resolve this:
-
Review the diff. Run the failing test to see what changed:
cargo nextest run --cargo-profile=test-release <test_name>
This creates a
.snap.newfile next to the existing.snapfile. -
Accept or reject. Use
cargo instato interactively review pending snapshots:cargo insta review
This walks you through each changed snapshot and lets you accept or reject it.
Alternatively, to accept all pending snapshots at once:
cargo insta accept
-
Commit the updated
.snapfiles. The updated snapshots should be committed alongside your code changes.
Important: Snapshot tests exist to catch accidental breaking changes. Before accepting a new snapshot, make sure the change is intentional and won't break compatibility (e.g. with existing on-chain data or client integrations).
If you don't have cargo insta installed:
cargo install cargo-instaWe run several checks in CI that require tools beyond the default Rust toolchain. The nix environment installs all of them automatically.
cargo-makecargo-nextestcargo-sortcargo-shearcargo-denyzizmorlycheeeditorconfig-checkerast-grep
This set does not include all checks, but only the most common reasons for CI
failures. Therefore, we suggest running these checks locally before opening a
PR. Running these checks with the correct parameters can be done easily with
cargo-make.
Running fast checks:
cargo make check-all-fastRunning all cargo-make supported checks:
cargo make check-all