Skip to content

Add tests to bitcore-cli#4105

Open
kajoseph wants to merge 28 commits intobitpay:masterfrom
kajoseph:bitcoreCli
Open

Add tests to bitcore-cli#4105
kajoseph wants to merge 28 commits intobitpay:masterfrom
kajoseph:bitcoreCli

Conversation

@kajoseph
Copy link
Copy Markdown
Collaborator

@kajoseph kajoseph commented Feb 12, 2026

Description

Need more tests in bitcore-cli

Changelog

  • Adds tests to bitcore-cli
  • Fixes a few bugs
    • BWC/S: Sending max amount should work for UTXO chains
    • CLI: Gate SOL from multi-party wallets
    • Various other bitcore-cli bugs
  • Removes tsx dependency from BWC

Testing Notes

cd packages/bitcore-cli && npm run test


Checklist

  • I have read CONTRIBUTING.md and verified that this PR follows the guidelines and requirements outlined in it.
  • I have added the appropriate package tag(s) (e.g. BWC if modifying the bitcore-wallet-client package, CLI if modifying the bitcore-cli package, etc.)
  • I have verified that this is not an existing PR (open or closed)

@kajoseph kajoseph added the bitcore-cli This pull request modifies the bitcore-cli package label Feb 12, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-cli test 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.

Comment thread packages/bitcore-cli/src/wallet.ts Outdated
Comment thread packages/bitcore-cli/src/commands/txproposals.ts Outdated
Comment thread packages/bitcore-cli/src/commands/txproposals.ts
Comment thread packages/bitcore-cli/src/commands/txproposals.ts Outdated
Comment thread packages/bitcore-cli/src/commands/join/joinMultiSig.ts Outdated
@kajoseph kajoseph requested a review from Copilot May 5, 2026 20:02
@kajoseph kajoseph added the BWC This pull request modifies the bitcore-wallet-client package label May 5, 2026
@kajoseph kajoseph added BWS This pull request modifies the bitcore-wallet-service package CWC This pull request modifies the crypto-wallet-core package labels May 5, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread packages/crypto-wallet-core/src/utils/index.ts
Comment thread packages/bitcore-wallet-client/src/lib/verifier.ts
Comment thread packages/bitcore-wallet-client/src/lib/api.ts
Comment thread packages/bitcore-cli/src/utils.ts
Comment thread packages/bitcore-cli/src/commands/txproposals.ts
Comment thread packages/bitcore-cli/src/commands/txproposals.ts Outdated
Comment thread packages/bitcore-wallet-client/copyTestData
Comment thread packages/bitcore-cli/test/tssCoordinator.ts Outdated
Comment thread packages/bitcore-cli/test/address.test.ts Outdated
Comment thread packages/bitcore-wallet-client/src/lib/verifier.ts
@kajoseph kajoseph requested a review from Copilot May 6, 2026 16:07
@kajoseph kajoseph marked this pull request as ready for review May 6, 2026 16:39
@kajoseph kajoseph requested review from MichaelAJay and Copilot and removed request for Copilot May 6, 2026 16:39
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread packages/bitcore-cli/src/wallet.ts
Comment thread packages/bitcore-cli/src/utils.ts
Comment thread packages/bitcore-cli/src/utils.ts
Comment thread packages/crypto-wallet-core/src/utils/index.ts
Comment on lines +101 to +123
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]);
}
Comment on lines 37 to 53
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;
}
Comment on lines 56 to 60
"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",
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bitcore-cli This pull request modifies the bitcore-cli package BWC This pull request modifies the bitcore-wallet-client package BWS This pull request modifies the bitcore-wallet-service package CWC This pull request modifies the crypto-wallet-core package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants