Skip to content

Add behavior tests for key commands and reveal-password storage - #48

Open
paulgnz wants to merge 1 commit into
XPRNetwork:masterfrom
paulgnz:test/key-command-behavior
Open

paulgnz wants to merge 1 commit into
XPRNetwork:masterfrom
paulgnz:test/key-command-behavior

Conversation

@paulgnz

@paulgnz paulgnz commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds tests for the key-security features from #39 (key:list, key:get, key:reveal-setup, key:reveal-disable, the encryptor, and reveal-password hashing), which had no coverage. Tests only, no source changes.

This is the first of a few smaller PRs replacing #41.

  • test/commands/key.test.ts: spawns bin/dev with a temp HOME, so tests run from src (no build needed) and never read or write the real wallet config. Asserts that private keys are never printed, that empty wallets are handled, that the flags are documented in help, that reveal-setup refuses to run without a TTY, and that reveal-disable is a no-op on a fresh wallet.
  • test/encryptor.test.ts, test/reveal-password.test.ts: unit tests in the same node:assert style as msig-utils.test.ts.
  • test/helpers/cli.ts: a small spawn runner plus the isolated-HOME helper.

Testing

  • Node 20: nyc mocha "test/**/*.test.ts" gives 98 passing: the existing 82 plus 16 new.
  • Node 22: the new files pass on their own (16). The existing suites don't load on Node 22 because @oclif/test@1 relies on module.parent. That's a separate issue, and a follow-up PR handles it.
  • ESLint: 0 errors on the new files. posttest lint already fails repo-wide on master (~3,000 pre-existing errors), so npm test exits non-zero both before and after this PR.

Covers the security features from XPRNetwork#39, which had no tests:
- key:list / key:get never print private keys, report empty wallets,
  and document --reveal-private / --force / the reveal password
- key:reveal-setup refuses to run without an interactive terminal;
  key:reveal-disable is a no-op on a fresh wallet
- encryptor round-trips with a random IV and rejects the wrong key
- reveal-password hashing uses a fresh salt, power-of-two scrypt N,
  and verifies only the exact password
- the "I UNDERSTAND" confirmation phrase stays stable

Command tests spawn bin/dev with a temp HOME, so they run from source
and never touch the user's real wallet config.

Claude-Session: https://claude.ai/code/session_01PsSVdfBGzbRD6i9BwVosdN
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant