Skip to content

[Chore] Add mnemonic codec regression tests and a real npm test CI gate - #7

Draft
roomote-conceal-network[bot] wants to merge 1 commit into
mainfrom
feature/mnemonic-codec-regression-tests-2p4zx8akm9d0c
Draft

[Chore] Add mnemonic codec regression tests and a real npm test CI gate#7
roomote-conceal-network[bot] wants to merge 1 commit into
mainfrom
feature/mnemonic-codec-regression-tests-2p4zx8akm9d0c

Conversation

@roomote-conceal-network

Copy link
Copy Markdown

​Created by Roomote. Follow up by mentioning @roomote, in the web UI, or in Discord.

What changed

Added a standalone C++ test harness for the mnemonic codec in cpp/Mnemonics — the first test coverage in this repository. tests/mnemonics_test.cpp compiles directly against Mnemonics.cpp, CRC32.cpp, and the word list with a plain host compiler (no React Native host app needed) via scripts/run-cpp-tests.sh, wired up as npm test.

The eight tests cover:

  • Known-vector encode/decode round trip against a fixed key/phrase pair, plus round trips over multiple generated keys
  • Mixed-case, fully upper-cased, and capitalized phrases decoding to the same private key as the lowercase phrase — the exact wallet-import bug fixed in [Fix] Wallet import fails or decodes the wrong key when mnemonic words are capitalized #4
  • Checksum rejection when the checksum word or a data word is tampered with
  • Wrong word count (24 and 26 words) rejection
  • Unknown word rejection, including an unknown checksum word
  • Checksum-word derivation and empty-phrase rejection

CI now runs npm test after the existing lint/format/check/cpp steps, so the tests gate merges. The npm run cpp / cpp:fix format scope was extended from cpp to cpp tests so the new test source is format-checked too.

Why this change was made

The critical mixed-case mnemonic decode fix from #4 (and polish in #5) merged with zero test coverage: no test script, no test files, and no CI test job, even though CLAUDE.md documented npm test as part of the quality gate. That doc/gate drift is closed by making the gate real and reconciling CLAUDE.md with what actually runs.

Impact

No runtime behavior changes — the codec itself is untouched. Refactors of the mnemonic codec are now guarded by regression tests; as a sensitivity check, the mixed-case test was verified to fail against a copy of Mnemonics.cpp with the #4 normalization fix reverted. The full local gate (npm run lint && npm run format && npm run check && npm run cpp && npm test) passes.

@roomote-conceal-network

roomote-conceal-network Bot commented Aug 28, 2026

Copy link
Copy Markdown
Author

No code issues found. Reviewed the standalone mnemonic codec test harness, the npm test CI gate wiring, and the CLAUDE.md/package.json updates against the codec sources; ran the full local gate (npm run lint / format / check clean, and npm test — all 8 tests pass). See task

Reviewed c3b1a53

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant