Todas as lições · Rust scripts and ckb-std · Começa aqui · Glossário
Separate builds for test-only contract constantsPráticoDe uma correção
De uma correção · Verificação: em parte certa · Verificada em 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.
Porque importa: 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.
Padrão
#[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))Um teste mudou no mesmo commit
Está ao lado da correcção. Nós não o corremos.
- psawyerberlin/ckb-revocable-timelock:
client/test/chain.test.ts,client/test/tx.test.ts
- Conceitos
- Testing and devnet, Cell deps and script lookup, Type ID and upgrades
- Evidência
- De uma correção: de um projeto, verificada contra o commit
- Vista pela primeira vez
- 2026-11-16
- Última mudança
- 2026-11-16
- Última verificação
- 2026-11-19
- Verificação contra o commit
- em parte certa: um núcleo verdadeiro, com uma parte solta ou demasiado larga
Fontes (1)
- 2026-11-16 · psawyerberlin/ckb-revocable-timelock · mais deste projeto
Mais sobre 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
Manténs um projeto de onde esta lição veio? Confirma ou corrige
Citar esta lição
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.