This is the authoritative validation guide for the contracts/ workspace. Use it instead of piecing commands together from checklists or older quick references.
- Rust
1.88.0to match .github/workflows/contracts.yml - Target:
wasm32-unknown-unknown - Components:
clippy,rustfmt - Optional for deployment and manual invocation:
soroban-cli
Setup:
rustup toolchain install 1.88.0
rustup default 1.88.0
rustup target add wasm32-unknown-unknown
rustup component add clippy rustfmtRun these when you are working in one contract and want the fastest feedback.
From contracts/:
cargo test -p tip-time-lock
cargo build -p tip-time-lock --target wasm32-unknown-unknown --releaseFrom a contract directory such as contracts/tip-time-lock:
cargo test --verbose
cargo build --target wasm32-unknown-unknown --release
cargo clippy -- -D warnings
cargo fmt -- --checkUse the package-scoped path first after a local code change. It is the cheapest way to catch logic, type, and ledger-behavior regressions.
The current contracts CI does not run a single cargo test --workspace command. It iterates over each contract directory, skips ./lottery, and runs validation inside each package directory.
Use this when a change affects shared crates, workspace configuration, or multiple contracts:
cd contracts
for dir in */; do
if [ "$dir" = "lottery/" ]; then
continue
fi
if [ -f "$dir/Cargo.toml" ]; then
(cd "$dir" && cargo test --verbose)
(cd "$dir" && cargo build --target wasm32-unknown-unknown --release)
(cd "$dir" && cargo clippy -- -D warnings)
(cd "$dir" && cargo fmt -- --check)
fi
doneIf you are on Windows without a POSIX shell, run the same four commands manually in each changed contract directory.
cargo test -p <package>: default choice for a single contract change.cargo test --verbose: same validation from inside a package directory and matches CI output more closely.cargo build --target wasm32-unknown-unknown --release: required whenever contract WASM output might change.cargo clippy -- -D warnings: required before review to keep CI green.cargo fmt -- --check: required before review to avoid format-only CI failures.
Prefer explicit assertions for balances, events, ledger timestamps, storage transitions, and auth failures.
Use snapshots only when:
- the output is large enough that field-by-field assertions would hide intent,
- the serialized shape is expected to stay stable across normal refactors,
- and the review clearly benefits from a before/after diff.
Avoid snapshots for rapidly changing payloads, random addresses, or values derived from current ledger timestamps unless you first make the test deterministic.
- Run the narrowest package test command that covers your change.
- Build the changed contract for
wasm32-unknown-unknown --release. - Run
clippyandfmtin the changed contract directory. - Run the CI-parity sweep if you touched shared code, workspace config, or multiple contracts.
For the time-lock storage TTL hardening work:
cd contracts
cargo test -p tip-time-lock
cargo build -p tip-time-lock --target wasm32-unknown-unknown --release