Skip to content

test: WALLET-1364 — close the test-coverage gaps - #1465

Open
ost-ptk wants to merge 13 commits into
developfrom
WALLET-1364-test-coverage-gaps
Open

test: WALLET-1364 — close the test-coverage gaps#1465
ost-ptk wants to merge 13 commits into
developfrom
WALLET-1364-test-coverage-gaps

Conversation

@ost-ptk

@ost-ptk ost-ptk commented Aug 13, 2026

Copy link
Copy Markdown
Member

Closes the nine test-coverage gaps recorded in WALLET-1364. Tests only, apart from two small
behaviour-preserving extractions explained below.

Jira: https://make-software.atlassian.net/browse/WALLET-1364

Why these nine

Each gap is paired with the regression it would let through today. They were picked because the
code they cover is either a security boundary or a silent-failure path — the kind that ships green
and surfaces as a user-visible loss.

Area Regression now caught
src/content/index.ts — no test file existed Relaxing SDK_REQUEST_TYPES to the shape check alone lets a forged *:Response / *:Error envelope or a redux action reach the background. Also pins that the activePort == null drop path logs type + requestId and never the payload — those envelopes carry signatureHex / encryptedMessage.
error envelope round trip A drift in the hand-built `${type}:Error` envelope makes the SDK's requestId filter discard it, so the dapp's promise never settles and the user waits out a timeout of up to 30 minutes. Both real modules run against one fake channel; a shape assertion would not catch this.
fetchFromBackground routing A broken requestId filter hands the wrong signature to a dapp with two concurrent sign() calls; an inverted error check resolves an error envelope as success.
manageKeepAlive Inverting the lock-state condition kills the MV3 service worker at its ~30s idle deadline while the wallet is unlocked — the silent session loss 01343e0e fixed.
createAccountSaga A broken derivation-collision loop either reuses an index or never terminates, wedging the service worker. The tests assert the exact derivationIndex; "a put happened" passes with a reused index.
vault saga error channel Four catch blocks whose source is the wiring to the error banner. Nothing previously forced encryptVault to throw.
src/libs/crypto/encryption/ Had zero direct tests. Round trip per key algorithm, plus pinned fixed-vector ciphertexts so a wire-format change fails here instead of in the field.
download-account-keys A zip failure must route to Failure and never Success (WALLET-1345), and only error.name may be logged — the thrown value is built from key material.
use-private-state push listener A renamed action type leaves every UI replica holding a stale passwordHash after a password change.
create-open-window SwitchAccount joins its params with &; a ? there silently drops every param after the first, i.e. an approval window opening without its requestId. Plus the clearWindowId path and the fullscreen geometry branch.

The two production changes

Both exist only because jest runs testEnvironment: 'node' with no jsdom, so logic living inside a
React component is unreachable from a test. Neither changes behaviour.

  • runKeysDownload moves out of download-account-keys/index.tsx into its own module; the page now
    calls it. A verbatim move.
  • createPrivateStateUpdatedListener lifts the inner listener out of usePrivateState's effect. The
    hook still registers and removes the same function reference, which the cleanup depends on.

Coverage

740 → 867 tests, 83 → 90 suites. vault-sagas.ts goes from 78.19% to 94.68% lines.

The ./src/background/redux/sagas/ floor rises 45/35/45/45 → 74/63/79/79, following this repo's
existing convention of setting the floor to what is achieved.

One thing worth a deliberate decision: that directory's denominators are small (38 functions,
364 statements), so at floor-set-to-achieved a single new uncovered function or statement anywhere
under redux/sagas/ — including in the still-untested onboarding-sagas.ts (33%),
check-casper2-network-saga.ts (52%) or trusted-wasm-saga.ts (63%) — will fail CI on an unrelated
PR. A branch review recommended leaving a few points of slack (70/58/75/75) instead. I kept the
existing convention rather than deviate in one group only, but if this bites, lowering it is a
deliberate call the team should make, not a silent one.

Notes for review

  • The tests were mutation-checked: production code was temporarily broken to confirm each new test
    fails, then restored. Where a check proved less than it appeared, that is recorded — e.g.
    SagaErrorSource is a union type, so a renamed source literal already fails tsc before any
    test runs.
  • src/content/__fixtures.ts is a shared test harness, not production code. It follows the existing
    src/libs/crypto/__fixtures.ts precedent; jest's testRegex does not collect it.
  • Rebased onto develop after perf: cut the code each page parses on open (WALLET-1380, WALLET-1381) #1456 merged. File overlap with that PR is empty, and the full
    ci-check was re-run against casper-js-sdk 5.1.0 / casper-wallet-core 1.4.0 — the pinned ECIES
    ciphertexts still decrypt, so the wire format is unchanged.

PR2 under the same ticket will cover the six remaining P3 code items.

@ost-ptk ost-ptk changed the title WALLET 1364 test coverage gaps test: WALLET-1364 — close the test-coverage gaps Aug 13, 2026
@ost-ptk
ost-ptk requested a review from Comp0te August 13, 2026 14:31
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