Add tests to bitcore-cli#4105
Conversation
Co-authored-by: Copilot <copilot@github.com>
There was a problem hiding this comment.
Pull request overview
Adds a substantial automated test suite for bitcore-cli (unit tests + end-to-end CLI flows against a local BWS + MongoDB), and adjusts CLI behavior/types to support those tests (wallet creation/join flows, tx proposal pagination/actions, and build/test tooling).
Changes:
- Added extensive
bitcore-clitest coverage (utils/prompts/filestorage + CLI interaction tests for create/join, proposals, addresses). - Updated CLI wallet + txproposals logic to support new scenarios (join secret plumbing, pagination refactor, chain-specific behavior, token lookup scoping).
- Updated build/test tooling (prod tsconfig, test scripts, test wallet fixtures, and new dev deps for running an embedded BWS + MongoDB).
Reviewed changes
Copilot reviewed 29 out of 31 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/bitcore-wallet-client/src/index.ts | Re-exports Constants from BWC for downstream usage. |
| packages/bitcore-cli/types/wallet.d.ts | Updates wallet create() type signature for join-secret flow + new return fields. |
| packages/bitcore-cli/tsconfig.prod.json | Adds prod TS config excluding tests. |
| packages/bitcore-cli/test/wallets/btc-singlesig.json | Adds wallet fixture used by CLI tests. |
| packages/bitcore-cli/test/wallets/btc-multisig-copayer1.json | Adds multisig copayer fixture. |
| packages/bitcore-cli/test/wallets/btc-multisig-copayer2.json | Adds multisig copayer fixture. |
| packages/bitcore-cli/test/utils.test.ts | Adds unit tests for Utils. |
| packages/bitcore-cli/test/tssCoordinator.ts | Adds helper to coordinate multiple CLI processes for TSS tests. |
| packages/bitcore-cli/test/proposals.test.ts | Adds end-to-end tests for viewing/accepting/rejecting/deleting proposals. |
| packages/bitcore-cli/test/prompts.test.ts | Adds tests for prompt helpers (env defaults, validation, cancel flow). |
| packages/bitcore-cli/test/helpers.ts | Adds BWS/Mongo-backed test harness and blockchainExplorer mock utilities. |
| packages/bitcore-cli/test/filestorage.test.ts | Adds tests for FileStorage behavior. |
| packages/bitcore-cli/test/data/walletsData.ts | Adds BWS wallet seed data for tests. |
| packages/bitcore-cli/test/data/test-config.ts | Adds test config for Mongo/BWS ports. |
| packages/bitcore-cli/test/data/proposalsData.ts | Adds BWS proposal seed data. |
| packages/bitcore-cli/test/data/addressesData.ts | Adds BWS address seed data. |
| packages/bitcore-cli/test/create.test.ts | Adds end-to-end tests for single-sig, multisig, and TSS wallet creation/join flows. |
| packages/bitcore-cli/test/commands.test.ts | Fixes type import paths for command tests. |
| packages/bitcore-cli/test/address.test.ts | Adds end-to-end tests for address generation + pagination. |
| packages/bitcore-cli/src/wallet.ts | Adds join-secret support to create(), adjusts completion/save logic, adds regtest currency URL requirement. |
| packages/bitcore-cli/src/utils.ts | Adjusts goodbye messages, parseAmount() error behavior, and documents paginate() types. |
| packages/bitcore-cli/src/commands/txproposals.ts | Refactors proposal viewing/actions onto shared paginator, adds --page option. |
| packages/bitcore-cli/src/commands/token.ts | Restricts token lookup to the wallet’s chain. |
| packages/bitcore-cli/src/commands/join/joinMultiSig.ts | Routes multisig join through wallet.create({ joinSecret }). |
| packages/bitcore-cli/src/commands/join/index.ts | Blocks Solana for multi-party join flows. |
| packages/bitcore-cli/src/commands/create/index.ts | Disables multi-party prompt for Solana creation. |
| packages/bitcore-cli/src/commands/create/createThresholdSig.ts | Adds explicit Solana guard for TSS creation. |
| packages/bitcore-cli/src/commands/create/createMultiSig.ts | Adds explicit chain support guard for multisig creation. |
| packages/bitcore-cli/package.json | Updates test/coverage scripts (copy fixtures, --exit), adds prod build, adds test deps. |
| packages/bitcore-cli/package-lock.json | Locks new dev dependencies (BWS, mongodb, supertest, etc.). |
| packages/bitcore-cli/copyTestWallets | Adds helper script to copy wallet fixtures into build output for tests. |
Files not reviewed (1)
- packages/bitcore-cli/package-lock.json: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 39 out of 42 changed files in this pull request and generated 10 comments.
Files not reviewed (2)
- packages/bitcore-cli/package-lock.json: Language not supported
- packages/bitcore-wallet-client/package-lock.json: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <copilot@github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 40 out of 43 changed files in this pull request and generated 7 comments.
Files not reviewed (2)
- packages/bitcore-cli/package-lock.json: Language not supported
- packages/bitcore-wallet-client/package-lock.json: Language not supported
| export function isEqual(obj1: object, obj2: object): boolean { | ||
| if (obj1 === obj2) return true; | ||
| if (obj1 == null || obj2 == null) return false; | ||
| if (typeof obj1 !== 'object' || typeof obj2 !== 'object') return false; | ||
| const stack = [obj1, obj2]; | ||
| while (stack.length) { | ||
| const a = stack.pop(); | ||
| const b = stack.pop(); | ||
| if (a === b) continue; | ||
| if (a == null || b == null) return false; | ||
| if (typeof a !== 'object' || typeof b !== 'object') return false; | ||
| if (Object.getPrototypeOf(a) !== Object.getPrototypeOf(b)) return false; | ||
| if (a instanceof Date) { | ||
| if (!(b instanceof Date) || a.getTime() !== b.getTime()) return false; | ||
| continue; | ||
| } | ||
| if (a instanceof RegExp) { | ||
| if (!(b instanceof RegExp) || a.source !== b.source || a.flags !== b.flags) return false; | ||
| continue; | ||
| } | ||
| for (const key in a) { | ||
| stack.push(a[key], b[key]); | ||
| } |
| if (!!opts.action !== !!opts.proposalId) { | ||
| throw new Error('Both --action and --proposalId options must be provided together.'); | ||
| } | ||
| if (opts.proposalId && opts.page) { | ||
| throw new Error('--page option does not make sense with --proposalId.'); | ||
| } | ||
| if (opts.action) { | ||
| if (ViewAction[opts.action.toUpperCase()]) { | ||
| opts.action = ViewAction[opts.action.toUpperCase()] as ViewAction; | ||
| } else if (Object.values(ViewAction).includes(opts.action.toLowerCase())) { | ||
| opts.action = opts.action.toLowerCase() as ViewAction; | ||
| } else { | ||
| throw new Error(`Invalid action: ${opts.action}`); | ||
| } | ||
| } | ||
| return opts; | ||
| } |
| "scripts": { | ||
| "coverage": "npm run compile && nyc mocha 'ts_build/test/**/*.test.js'", | ||
| "test": "tsc --noEmit && mocha -r tsx 'test/**/*.test.ts'", | ||
| "test": "npm run compile && ./copyTestData && mocha --exit 'ts_build/test/**/*.test.js'", | ||
| "test:ci": "npm run test", | ||
| "docs": "TODO ./node_modules/.bin/tsdoc src/lib/* src/lib/common src/lib/errors -o docs && cat README.header.md docs/*.md LICENSE > README.md", |
Description
Need more tests in bitcore-cli
Changelog
tsxdependency from BWCTesting Notes
cd packages/bitcore-cli && npm run testChecklist
BWCif modifying the bitcore-wallet-client package,CLIif modifying the bitcore-cli package, etc.)