This project is a small harness for using Codex to create and run JavaScript regression tests against a local Subtensor mainnet clone.
The goal is to make advanced local blockchain testing repeatable: build or reuse a patched mainnet clone, start a local validator node, optionally upgrade it to the runtime in subtensor-reference/, then run focused JS tests through @polkadot/api.
The normal workflow is:
scripts/clone-mainnet.shverifies or creates a patched mainnet clone chainspec under../../clones.scripts/start-local-clone.shstarts a local node from that chainspec atws://127.0.0.1:9944.js-tests/tests/clone-smoke-test.jsconfirms the websocket endpoint is usable.js-tests/scripts/update-runtime-with-alice.jssubmits a sudo runtime upgrade from Alice using the wasm insubtensor-reference/.- Feature tests under
js-tests/tests/exercise runtime behavior against the upgraded local clone. scripts/stop-local-clone.shstops the node so no background process is left running.
The current focused regression test is js-tests/tests/test-balancer-operation.js. It verifies that balancer storage is initialized, initialized balancer weights stay in the 0.45-0.55 range with at least one subnet not exactly 0.5, balance transfers work, and epoch activity updates subnet reserves within the configured wait window.
This repository expects a Subtensor checkout in ../../subtensor, plus the read-only symlink subtensor-reference/ tree in this workspace for runtime reference and wasm upgrades, for example:
development/
subtensor/
agents/codex-tester/
Build the node binary manually in the subtensor/ checkout:
cd ../../subtensor
cargo build --release --workspace --all-targetsThe runtime upgrade script expects this file:
subtensor-reference/target/release/wbuild/node-subtensor-runtime/node_subtensor_runtime.compact.compressed.wasm
Use prompts like these with Codex:
Write a JS test that verifies balance transfers after a runtime upgrade.
Write a test that verifies balancer initialization, non-default balancer weights, balance transfers, and reserve updates after an epoch.
Inspect the failed JS test output and node logs, explain the likely runtime issue, and make the smallest test change needed to capture it.
subtensor-reference/is read-only reference material for tests.- Local clone data and chainspec files live outside this repo under
../../clones. - Keep new JS tests focused and descriptive; avoid broad refactors during runtime investigations.