All lessons · Rust scripts and ckb-std · Start here · Glossary
Separate builds for test-only contract constantsWorkingFrom one fix
From one fix · Check: partly right · Checked 2026-11-19
Put test variants that change protocol constants behind a Cargo feature, built as a separate binary with its own code hash and deployment file. Client deployment parsing and deploy scripts should reject that variant on mainnet. Off-chain code should read the constant from the deployment rather than hardcode the default.
Why it matters: If off-chain code assumes the default constant while the deployed script enforces the test value, heartbeat jobs are funded for the wrong term. A test binary could also be wired into a mainnet deployment by mistake.
Pattern
#[cfg(feature="drill")] const GRACE_SECONDS: u64 = 600; build into separate target dir/output path; parseDeployment throws if network_id==0 && (drill || grace_seconds!=86400); heartbeatJob(..., graceSeconds(d))A test changed in the same commit
It sits next to the fix. We did not run it.
- psawyerberlin/ckb-revocable-timelock:
client/test/chain.test.ts,client/test/tx.test.ts
- Concepts
- Testing and devnet, Cell deps and script lookup, Type ID and upgrades
- Evidence
- From one fix: from one project, checked against its commit
- First seen
- 2026-11-16
- Last changed
- 2026-11-16
- Last checked
- 2026-11-19
- Check against the commit
- partly right: a true core, with a part that is loose or too wide
Sources (1)
- 2026-11-16 · psawyerberlin/ckb-revocable-timelock · more from this project
More about Rust scripts and ckb-std
- Delegating script validation via exec to a hash bound cell dep
- Recognising a Nervos DAO deposit cell referenced as a stake cell dep
- ckb-std C shim needs a RISC-V C toolchain (clang) in CI
Do you maintain a project this lesson came from? Confirm or correct it
Cite this lesson
LusoCryptoLabs, "Separate builds for test-only contract constants", CKB lessons, https://pulse.lusocryptolabs.com/learned/scripts/separate-builds-for-test-only-contract-constants, CC BY 4.0, last changed 2026-11-16.