test: cover security-critical gaps from post-merge coverage analysis#848
Open
test: cover security-critical gaps from post-merge coverage analysis#848
Conversation
Contributor
faa2a66 to
c68b657
Compare
Contributor
Contributor
E2E Tests Resultse2e_tests_reports: Run #3556
🎉 All tests passed!Suites119 passed, 0 failed, and 4 other
Github Test Reporter by CTRF 💚 🔄 This comment has been updated |
Adds focused tests for two gaps surfaced in the post-merge coverage analysis of the last two months: - packages/contracts (#745): per-recipient encryption key resolver — burn-constant structural validation, precedence of the fixed wallet and burn keys over additional DApp mappings, resolver invocation per non-contract recipient in zswapStateToOffer (the security property motivating the original fix). - packages/dapp-connector-proof-provider (#732): sync throws, non-Error rejections, ZKConfigProvider failure, and transient-failure retry semantics at both the proving-provider and proof-provider layers. Coverage: zswap-utils.ts 93.81% stmt / 94.59% branch; dapp-connector source files 100% across all metrics. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Covers the Protocol ACL package (#832), which had zero test coverage. Structural tests (protocol-acl.test.ts): - Barrel namespaces (ledger, compactRuntime, compactJs, onchainRuntime, platform) each resolve, are non-empty, and the top-level surface is exactly those 5 keys. - Each subpath has identical member keys to its barrel namespace, detecting broken subpath wiring or divergence between import styles. - Representative symbols (sampleSigningKey, StateValue, entryPointHash, asBytes) exist on each subpath, detecting empty/stub modules. - Effect submodule subpaths (compact-js/effect, compact-js/effect/Contract, platform-js/effect/Configuration, platform-js/effect/ContractAddress) resolve and expose their expected contents. ESLint rule tests (eslint-restriction.test.ts): - Runs the real root eslint.config.mjs via ESLint.lintText. - Flags direct imports of ledger-v8, compact-runtime, compact-js, onchain-runtime-v3, platform-js (and submodules) from consumer packages, with the error message pointing at the correct ACL replacement. - Wildcard patterns guard future ledger / onchain-runtime major bumps. - All ACL subpath imports are allowed from consumer packages. - The override for packages/protocol/src/ permits direct imports inside the ACL implementation, while still forbidding dist imports. Adds vitest config and test script to the package. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Whitespace/layout normalisation only — no test behaviour changes. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Adds a spy-based test asserting that StorageEncryption.create is invoked again after `invalidateEncryptionCache()`, catching regressions where invalidate silently becomes a no-op. Part of the post-merge coverage review of PRs #538/#798 (encryption caching + web crypto migration). Also includes a pre-existing prettier pass against the test file that was already present in the working tree. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Adds static-source regression tests for #711 (replace shell string interpolation with safe argument arrays in compact CLI tools). The tests grep the source of fetch-compact.mts and run-compactc.cjs to guarantee that exec/execSync with interpolated template literals — the exact pattern the PR removed — cannot be re-introduced without a test failure. Also adds vitest config and test script to the compact package, which previously had no test infrastructure. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ctor suites Removes 12 tests across two files after an honest re-evaluation of the branch's additions: - zswap-utils.test.ts (7 removed): two tautological burn-constant shape assertions; tests that exercise Map.get with multiple entries; edge cases that work by construction (empty Map); a bidirectional normalisation test already covered in the opposite direction by enc-pub-key-resolver.test.ts; two thin-delegation wrapper tests. - dapp-connector-proving-provider.test.ts (2 removed): "sync throw is rejected" and "non-Error rejection value is preserved" both test language semantics (async/await behaviour) rather than code. Net effect: every remaining test now encodes a specific regression it would catch — resolver precedence against DApp mapping overrides (the security property of #745), the spy test that proves per-recipient encryption key selection, and error-path propagation with call-ordering guarantees. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Adds lockfile entries for vitest, @vitest/coverage-v8, and eslint declared as devDependencies in the protocol and compact packages. CI runs `yarn install --immutable` which rejects unlocked deps. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
0ba0597 to
507a3d3
Compare
Contributor
Code reviewFound 2 issues:
midnight-js/packages/contracts/src/test/utils/zswap-utils.test.ts Lines 295 to 298 in 0ba0597
🤖 Generated with Claude Code - If this code review was useful, please react with 👍. Otherwise, react with 👎. |
- Remove tautological burn-constant assertion: BURN_ENCRYPTION_PUBLIC_KEY is a hardcoded hex literal that can never be all zeros — the test asserted a property that holds by definition. - Replace toBeGreaterThan with exact .toBe(callsBeforeInvalidate + 1) in the cache-invalidation test, catching double-derivation bugs that the looser assertion would have missed. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Remove tautological burn-constant assertion: the hardcoded hex literal can never be all zeros. - Replace toBeGreaterThan with exact .toBe(callsBeforeInvalidate + 1) in the cache-invalidation test. - Remove redundant .not.toBe() in spy test (already proved by the two .toBe() assertions above it). - Revert formatter noise from level-private-state-provider test file to keep the diff focused on the new test block only. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
Summary
protocol,compact)Packages touched
contractsdapp-connector-proof-providerprotocolESLint.lintText)level-private-state-providerinvalidateEncryptionCacheactually forcesStorageEncryption.createre-derivationcompactexec/execSyncwith template literals cannot be re-introduced (#711)Key findings during investigation
set/getfrom a single provider instance — the "web crypto concurrency" gap was overstated; the real interleaving surface is limited to in-memory cache operationsTest plan
vitest runpasses in all 5 touched packages (contracts: 40, dapp-connector: 12, protocol: 45, level-private-state: 153, compact: 4)tsc --noEmitclean in all packageseslintclean in all packagesmain)🤖 Generated with Claude Code