gen-test-tools is the crate that powers integration tests against the Grid validators. It provides the test fixture, the validator-mode abstraction, and the deterministic entity generation that contract tests use.
What’s in the crate
TestContext: the main context object exposing an RPC client and an entity factory.fixture::test_context: anrstestfixture for easy test setup.TestSeedandEntityFactory: deterministic seeding for reproducible entity generation.ValidatorSubprocess: manages a local validator subprocess.ValidatorContainer: manages a validator in a Docker container via testcontainers.ValidatorMode: enum representing the available validator execution modes.
Quick start
The easiest way to write a test is with thetest_context fixture:
IDE integration
Run and Debug panel entries
A scaffolded workspace includes.vscode/launch.json with:
gen-framework: build contractgen-framework: run contract tests
cargo test, and the cargo wrapper ensures or reuses the validator before tests begin. It remains useful as a manual Run and Debug panel integration even though the inline Rust Analyzer buttons use the same cargo-wrapper path directly. The build launch entry uses scripts/genie-build.sh, which respects GEN_CLI_PATH with a fallback to gen.
IDE test and debug buttons
The bundled workspace settings hook the Rust Analyzer Run Test and Debug buttons into the shared-validator flow:.vscode/bin/cargodelegates toscripts/cargo-with-local-validator.sh..vscode/settings.jsonputs that wrapper first in the runnablePATH.- In the
.devcontainer, the remotePATHalso prefers the wrapper.
.vscode/ and scripts/ files (for example, via the released devcontainer.tar.gz bundle or by working directly in the framework repository).
Shell workflow
For non-VS Code users, the same shared-validator flow is available via:- Runs
./scripts/ensure-local-validator.sh. - Reuses the validator if it is already reachable.
- Exports the environment for
externalmode. - Executes
cargo testwith your arguments.
Validator modes
Control the validator mode viaGEN_VALIDATOR_MODE.
| Mode | Value | Description |
|---|---|---|
| Subprocess | subprocess (default) | Runs the validator as a local subprocess |
| TestContainer | test-container | Runs the validator in Docker via testcontainers |
| External | external | Connects to an already-running validator |
Subprocess mode
gen service validator local. See Run a local validator (host mode) for the same command run standalone.
TestContainer mode
gen-cli:latest, which the framework installer (install.sh) builds automatically when Docker is installed and reachable.
External mode
.devcontainer and IDE helper flows, where a shared validator process is reused between test executions.
Only works against fresh local or self-hosted validators today. The fixture does not send anAuthorizationheader from~/.gen/client_config.yml, and it hard-fails on a “wait for genesis migrations” call that can never succeed on an already-running chain. As a result, you cannot pointexternalmode at an authenticated, established DevNet. To exercise a contract on DevNet, usegen client pushandgen client deployinstead.
Deterministic entity generation
UseTestSeed and EntityFactory for reproducible entity IDs:
Environment variables
| Variable | Description | Default |
|---|---|---|
GEN_VALIDATOR_MODE | Validator mode: subprocess, test-container, external | subprocess |
VALIDATOR_RPC_URL | RPC endpoint URL for external mode | http://127.0.0.1:30001 |
GEN_CLI_PATH | Path to gen CLI binary | gen |
GEN_VALIDATOR_CONFIG | Custom validator config file | CLI default |
GEN_CONTAINER_IMAGE | Docker image name for test-container mode | gen-cli |
GEN_CONTAINER_TAG | Docker image tag for test-container mode | latest |
TEST_SEED | Fixed seed for deterministic entity generation | Random |
Troubleshooting
- Devcontainer + plain
cargo testfails immediately.- The bundled devcontainer should route
cargo testthrough the validator-aware cargo wrapper. - If your shell bypasses the bundled
PATHordering, start the validator first with./scripts/ensure-local-validator.sh.
- The bundled devcontainer should route
- Docker is installed but test-container mode is not selected.
- Ensure the Docker daemon is reachable.
- Ensure
gen-cli:latestexists locally. The framework installer (install.sh) builds it automatically when Docker is available.
- Need deterministic behavior. Set
GEN_VALIDATOR_MODEexplicitly.
See also
- Build and test a contract: the build/test loop that exercises this crate.
- Run a local validator (host mode): the standalone validator used by
externalmode. - Genie SDK reference: the contract-side SDK these tests target.

