CKB Pulse

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.

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)

More about Rust scripts and ckb-std

All 35 in this topic

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.

Drawn from public commits and checked against the commit each one came from and the project's code today. Read the source before you rely on one. Text under CC BY 4.0: credit LusoCryptoLabs, CKB lessons, with a link to the lesson. Want a lesson changed or removed? Open an issue.