CKB Pulse

All lessons · Developer tooling · Start here · Glossary

Emit shannon u64 values as strings in cross-language test vectorsWorkingFrom one fix

From one fix · Check: true, but the check found it more general than CKB · Checked 2026-11-19

When generating JSON test vectors in Rust for JavaScript decoders of CKB cell data, emit u64 fields (such as shannon amounts) as strings, because JSON numbers are IEEE-754 doubles and values above 2^53 would be silently rounded. Use distinct, non-zero field values so a decoder reading the wrong offset gives a visibly wrong result.

Why it matters: Without string encoding, u64 amounts above 2^53 are silently rounded in the JSON oracle, so the JavaScript decoder gets pinned to a wrong value and its tests still pass.

Pattern

Prefer
"principal_total": oracle_shard.principal_total.to_string(),

Taken from the commit, shortened.

A test changed in the same commit

It sits next to the fix. We did not run it.

Concepts
Testing and devnet, Data encoding (molecule, hex, bigints)
Evidence
From one fix: from one project, checked against its commit
First seen
2026-09-18
Last changed
2026-09-18
Last checked
2026-11-19
Check against the commit
true, but the check found it more general than CKB

Sources (1)

More about Developer tooling

All 35 in this topic

Do you maintain a project this lesson came from? Confirm or correct it

Cite this lesson
LusoCryptoLabs, "Emit shannon u64 values as strings in cross-language test vectors", CKB lessons, https://pulse.lusocryptolabs.com/learned/tooling/emit-shannon-u64-values-as-strings-in-cross-language-test-ve, CC BY 4.0, last changed 2026-09-18.

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.