Todas as lições · Developer tooling · Começa aqui · Glossário
Mirror on-chain rules off-chain with mutation testsPráticoDe uma correção
De uma correção · Verificação: certa · Verificada em 2026-11-19
A CKB script that refuses a transaction returns only an error code that names no rule, so port the contract's witness decoders to JS with the same refusals (bad version, truncation, trailing bytes, count or size limits). Check that they round-trip bytes produced by the Rust code. Before signing, run a checker that re-derives the contract's rules from the finished transaction, and pin each rule with a mutation test that breaks one field of a valid transaction and expects that rule's named reason.
Porque importa: Without an off-chain mirror, a malformed witness or broken rule only shows up as an opaque script error code at submission, with no indication of which rule failed.
Padrão
decode(bytes) throws on cut-short / trailing bytes / bad version like the Rust decoder; tests do `breakIt(clone(tx)); assert reasons.some(r => /expected/.test(r))`Um teste mudou no mesmo commit
Está ao lado da correcção. Nós não o corremos.
- toastmanAu/daowow:
apps/web/test/entitlements.test.js,apps/web/test/payout-tx.test.js,apps/web/test/settlement-rules.test.js,tests/devnet/js_settlement.mjs,tests/devnet/js_settlement.py
- Conceitos
- Testing and devnet, Data encoding (molecule, hex, bigints), Since and time locks
- Evidência
- De uma correção: de um projeto, verificada contra o commit
- Vista pela primeira vez
- 2026-11-13
- Última mudança
- 2026-11-13
- Última verificação
- 2026-11-19
- Verificação contra o commit
- certa: a lição sai do commit e continua a valer no código de hoje
Fontes (1)
- 2026-11-13 · toastmanAu/daowow · mais deste projeto
Mais sobre Developer tooling
- ckb-vm-js 0.2.0 (npm) checks header hash instead of rejecting the field
- Emit shannon u64 values as strings in cross-language test vectors
- Mock transactions must expand dep_group members
Manténs um projeto de onde esta lição veio? Confirma ou corrige
Citar esta lição
LusoCryptoLabs, "Mirror on-chain rules off-chain with mutation tests", CKB lessons, https://pulse.lusocryptolabs.com/learned/tooling/mirror-on-chain-rules-off-chain-with-mutation-tests, CC BY 4.0, last changed 2026-11-13.