Skip to content

chore(bitcoin): type the Bitcoin handler test fixtures - #640

Open
ulissesferreira wants to merge 3 commits into
mainfrom
chore/bitcoin-lint-suppressions-handler-tests
Open

ulissesferreira wants to merge 3 commits into
mainfrom
chore/bitcoin-lint-suppressions-handler-tests

Conversation

@ulissesferreira

Copy link
Copy Markdown
Contributor

Description

Types the Bitcoin snap handler test fixtures instead of leaving them any, clearing all 83 oxlint violations recorded for these seven handler test files (21 file -> rule entries): typescript/no-explicit-any (29), no-unsafe-return (15), no-unnecessary-type-assertion (14), no-unsafe-member-access (11), explicit-function-return-type (8), vitest/no-conditional-in-test (3), no-unsafe-argument (2) and id-length (1). The change is behaviour-neutral: mock Address values are cast to the real Address type instead of any, partially-stubbed Balance fixtures are cast to Balance, the four params literals that deliberately omit a field drop an unnecessary as any (they already satisfy JsonRpcRequest), and the two assertions that had to be reworded (toMatchObject for canBeMalleable, slice over it.each data in place of a ternary) assert exactly the same values as before. No production code, lint configuration or test expectation changed.

Changes

  • packages/bitcoin-wallet-snap/src/handlers/mappings.test.ts — helper return types (Transaction, TxOut, MockProxy<BitcoinAccount>), as any -> as unknown as Address for the Address.from_script mocks, and asset property reads narrowed to the Asset union member shape (no-explicit-any, no-unsafe-return, no-unsafe-member-access, explicit-function-return-type)
  • packages/bitcoin-wallet-snap/src/handlers/RpcHandler.test.ts — same Address/Balance typing, mock<BitcoinAccount>({...}) account fixtures, explicit to_sat mock return types, four redundant as any on params and four redundant as never casts dropped, canBeMalleable asserted with toMatchObject (no-explicit-any, no-unnecessary-type-assertion, no-unsafe-argument, no-unsafe-return, no-unsafe-member-access, explicit-function-return-type)
  • packages/bitcoin-wallet-snap/src/handlers/KeyringHandler.test.ts — generic renamed to satisfy id-length, expect.objectContaining callbacks return unknown, 'p2tr' as AddressType dropped, it.each carries the expected persisted-account count instead of a ternary, caught rejection typed Error, to_btc mock typed (id-length, no-unsafe-return, no-unnecessary-type-assertion, vitest/no-conditional-in-test, explicit-function-return-type)
  • packages/bitcoin-wallet-snap/src/handlers/CronHandler.test.ts — the snap_getState/snap_setState mock is a handler map instead of an if, with the JSON round-trip in a module-scoped, Json-typed helper (vitest/no-conditional-in-test, no-unsafe-return)
  • packages/bitcoin-wallet-snap/src/handlers/UserInputHandler.test.ts — two redundant as UserInputEvent assertions dropped along with the now-unused type import (no-unnecessary-type-assertion)
  • packages/bitcoin-wallet-snap/src/handlers/HandlerMiddleware.test.ts — redundant as unknown as Mock dropped (no-unnecessary-type-assertion)
  • packages/bitcoin-wallet-snap/src/handlers/validation.test.ts — return types on the feeRate and account helpers (explicit-function-return-type)
  • oxlint-suppressions.json — regenerated with --prune-suppressions (Bitcoin package 185 -> 102 violations; the remaining 102 entries are in sibling files owned by parallel cleanups)

Quality gates

  • yarn lint:oxlint packages/bitcoin-wallet-snap — clean, 83 violations / 21 suppressions entries removed (my files: 83 -> 0)
  • tsc --noEmit — clean
  • vitest run — 28 files / 761 tests pass (matches the origin/main baseline)
  • oxfmt --check — clean

@sonarqubecloud

Copy link
Copy Markdown

This branch was previously deployed

1 inactive (outdated) deployment
default-branch — a4b8cc3d Deployed Nov 17, 2026 by ulissesferreira via Determine whether this PR is a release PR #2420
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