test: add setupDashClient unit tests and mnemonic validation#60
test: add setupDashClient unit tests and mnemonic validation#60thephez wants to merge 9 commits intodashpay:mainfrom
Conversation
Replace hardcoded DIP-13 path construction in deriveKeysFromMnemonic with the exported dip13KeyPath() helper, ensuring a single source of truth for path derivation. Add test cases for missing setupDashClient() permutations including undefined manager guards, requireIdentity flag, and identityIndex forwarding. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Catch invalid BIP39 mnemonics early with a clear error message instead of letting them propagate to the WASM SDK as opaque WasmSdkError objects. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Verify key-role correctness (keyId per getSigner method), signer depth (keyCount for getMaster/getFullSigner), createClient success branches (testnet/mainnet isConnected), findNextIndex loop logic with stubbed occupied indices, createForNewIdentity nonzero auto-index, and AddressKeyManager getInfo/getInfoAt with stubbed SDK. Fix stale comment and remove weak clientConfig direct-usage tests. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Don't run setup in test:all
📝 WalkthroughWalkthroughAdd runtime mnemonic validation to SDK setup, introduce dotenv and new test scripts/dependencies, and add extensive integration tests plus conditional mnemonic-gated read-only tests. Changes
Sequence Diagram(s)(omitted) Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
test/setupDashClient.test.mjs (1)
744-772: Consider removing or converting the skipped test to a documentation comment.This skipped test documents a potential future improvement (clearer errors when
keyManagerisundefined) but doesn't actively test anything. If the behavior isn't implemented, consider either:
- Removing the test and tracking the improvement as a GitHub issue
- Converting it to a brief code comment explaining the limitation
Skipped tests can accumulate and become stale over time.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@test/setupDashClient.test.mjs` around lines 744 - 772, The skipped test case using it.skip titled 'should not produce a TypeError when write tutorials use keyManager without a mnemonic' is documentation-only and should be removed or converted to a comment; either delete the entire it.skip block (including references to setupDashClient, clientConfig.mnemonic, keyManager and addressKeyManager) and open a GitHub issue to track the improvement, or replace the it.skip block with a short inline comment describing the limitation and the desired future behavior so the test suite contains no skipped tests.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@test/setupDashClient.test.mjs`:
- Around line 744-772: The skipped test case using it.skip titled 'should not
produce a TypeError when write tutorials use keyManager without a mnemonic' is
documentation-only and should be removed or converted to a comment; either
delete the entire it.skip block (including references to setupDashClient,
clientConfig.mnemonic, keyManager and addressKeyManager) and open a GitHub issue
to track the improvement, or replace the it.skip block with a short inline
comment describing the limitation and the desired future behavior so the test
suite contains no skipped tests.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 33812d60-d18c-47bf-9824-ddcc6529ad00
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (3)
package.jsonsetupDashClient.mjstest/setupDashClient.test.mjs
|
Close in favor of #61 which can run tests successfully (not from fork) |
Tutorials depend on dotenv to load .env files, so it should be a regular dependency to ensure it is available after `npm install`. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Fork PRs don't have access to repository secrets, so identity-retrieve fails in CI. Skip tests marked with requiresMnemonic when the env var is absent. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
🧹 Nitpick comments (1)
package.json (1)
12-13: Include setup tests in the aggregate test command.At Line 12,
test:alldoes not run the newtest:setupsuite from Line 13, so “all” tests can still misssetupDashClientcoverage.💡 Proposed update
- "test:all": "node --test --test-timeout=300000 --test-concurrency=1 test/read-only.test.mjs test/read-write.test.mjs", + "test:all": "node --test --test-timeout=300000 --test-concurrency=1 test/read-only.test.mjs test/read-write.test.mjs && npm run test:setup",🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@package.json` around lines 12 - 13, The package.json script "test:all" currently omits the setup suite "test:setup"; update the "test:all" definition so it runs the setup tests too — either append "test/setupDashClient.test.mjs" to the list of files executed by "test:all" or change the command to invoke the "test:setup" script (e.g., run "npm run test:setup" before the other tests using &&); edit the "test:all" entry to reference the "test:setup" script or file so "test:setup" is executed as part of "test:all".
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@package.json`:
- Around line 12-13: The package.json script "test:all" currently omits the
setup suite "test:setup"; update the "test:all" definition so it runs the setup
tests too — either append "test/setupDashClient.test.mjs" to the list of files
executed by "test:all" or change the command to invoke the "test:setup" script
(e.g., run "npm run test:setup" before the other tests using &&); edit the
"test:all" entry to reference the "test:setup" script or file so "test:setup" is
executed as part of "test:all".
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 81c4201b-c419-4fd2-b457-76c0a58fa1ad
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (2)
package.jsontest/read-only.test.mjs
Summary
setupDashClientcovering client creation, key derivation, DIP-13 path logic, identity handling, and error paths (~920 lines, 138 assertions)setupDashClientbefore key derivation, throwing a clear error for invalid BIP39 mnemonicstest:setupscript for running setupDashClient tests via MochaSummary by CodeRabbit
Bug Fixes
New Features
Tests
Chores