All lessons · Rust scripts and ckb-std · Start here · Glossary
Assert the specific script error code in ckb-testtool rejection testsWorkingFrom one fix
From one fix · Check: the last check did not agree with this lesson · Checked 2026-11-19
In ckb-testtool tests, checking only that `context.verify_tx(&tx, MAX_CYCLES)` returns an error lets a test keep passing even if the targeted check is deleted from the script, because a badly built transaction usually fails for several reasons. This commit matches the script's exit code in the error string instead (`err.contains("error code {code} ")`), one constant per error discriminant of the script.
A test changed in the same commit
It sits next to the fix. We did not run it.
- CECILIA-MULANDI/zk-Lock:
sdk/ts/test/bound.test.ts,sdk/ts/test/encode.test.ts,tests/src/lib.rs,tests/src/tests.rs,tests/src/tests_bound.rs
- Concepts
- Testing and devnet
- Evidence
- From one fix: from one project, checked against its commit
- First seen
- 2026-11-05
- Last changed
- 2026-11-05
- Last checked
- 2026-11-19
- Check against the commit
- the last check did not agree with this lesson: read the source
Sources (1)
- 2026-11-05 · CECILIA-MULANDI/zk-Lock · more from this project
More about Rust scripts and ckb-std
- ckb-std C shim needs a RISC-V C toolchain (clang) in CI
- Median time vs tip timestamp for deadlines
- Cheque lock receiver path must return the cell's capacity to the sender
Do you maintain a project this lesson came from? Confirm or correct it
Cite this lesson
LusoCryptoLabs, "Assert the specific script error code in ckb-testtool rejection tests", CKB lessons, https://pulse.lusocryptolabs.com/learned/scripts/assert-the-specific-script-error-code-in-ckb-testtool-reject, CC BY 4.0, last changed 2026-11-05.