test: WALLET-1364 — close the test-coverage gaps - #1465
Open
ost-ptk wants to merge 13 commits into
Open
Conversation
…rop-path redaction
…and error envelopes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
src/content/index.ts— no test file existedSDK_REQUEST_TYPESto the shape check alone lets a forged*:Response/*:Errorenvelope or a redux action reach the background. Also pins that theactivePort == nulldrop path logs type + requestId and never the payload — those envelopes carrysignatureHex/encryptedMessage.`${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.fetchFromBackgroundroutingsign()calls; an inverted error check resolves an error envelope as success.manageKeepAlive01343e0efixed.createAccountSagaderivationIndex; "a put happened" passes with a reused index.sourceis the wiring to the error banner. Nothing previously forcedencryptVaultto throw.src/libs/crypto/encryption/download-account-keyserror.namemay be logged — the thrown value is built from key material.use-private-statepush listenerpasswordHashafter a password change.create-open-windowSwitchAccountjoins its params with&; a?there silently drops every param after the first, i.e. an approval window opening without itsrequestId. Plus theclearWindowIdpath and the fullscreen geometry branch.The two production changes
Both exist only because jest runs
testEnvironment: 'node'with no jsdom, so logic living inside aReact component is unreachable from a test. Neither changes behaviour.
runKeysDownloadmoves out ofdownload-account-keys/index.tsxinto its own module; the page nowcalls it. A verbatim move.
createPrivateStateUpdatedListenerlifts the inner listener out ofusePrivateState's effect. Thehook still registers and removes the same function reference, which the cleanup depends on.
Coverage
740 → 867 tests, 83 → 90 suites.
vault-sagas.tsgoes 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'sexisting 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-untestedonboarding-sagas.ts(33%),check-casper2-network-saga.ts(52%) ortrusted-wasm-saga.ts(63%) — will fail CI on an unrelatedPR. 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
fails, then restored. Where a check proved less than it appeared, that is recorded — e.g.
SagaErrorSourceis a union type, so a renamedsourceliteral already failstscbefore anytest runs.
src/content/__fixtures.tsis a shared test harness, not production code. It follows the existingsrc/libs/crypto/__fixtures.tsprecedent; jest'stestRegexdoes not collect it.developafter perf: cut the code each page parses on open (WALLET-1380, WALLET-1381) #1456 merged. File overlap with that PR is empty, and the fullci-checkwas re-run againstcasper-js-sdk5.1.0 /casper-wallet-core1.4.0 — the pinned ECIESciphertexts still decrypt, so the wire format is unchanged.
PR2 under the same ticket will cover the six remaining P3 code items.