test(perps): migrate controller unit tests to core#8840
Merged
Conversation
michalconsensys
previously approved these changes
May 19, 2026
Constructor-initiated refreshEligibility chain (RFFC:getState -> GeolocationController:getGeolocation) was leaking into depositMockCall recordings before assertions ran, causing CI failures on Node 18 while local Node 22 passed due to microtask ordering differences.
submitTransaction now spreads isInternal:true into addTransaction options (added via main merge). Update both perpsDeposit and perpsDepositAndOrder assertions to match.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 24ce9a1. Configure here.
jest.fn() is typeof 'function', not 'object', so the provider-mock clearing loop never executed. Cleanup still worked via clearAllMocks in beforeEach, but the selective clear was dead code.
michalconsensys
approved these changes
May 20, 2026
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.

Explanation
This PR migrates the mobile perps controller unit tests into
@metamask/perps-controllerso Core owns the controller test suite. It ports the mobile coverage into Core-nativetests/srcfiles, splits the largest controller/provider/subscription suites into focused shards, adds shared test helpers, and switches package coverage collection from the placeholder test to realsrc/**/*.tscoverage.The package now enforces at least 80% statement/line coverage for the perps controller package. This is test-only and does not change the published runtime API.
Validation performed:
yarn workspace @metamask/perps-controller run test --runInBandyarn eslint 'packages/perps-controller/{src,tests}/**/*.ts'yarn lint:misc --checkyarn workspace @metamask/perps-controller run changelog:validateKnown limitation:
yarn tsc --build packages/perps-controller/tsconfig.build.json --verboseis blocked by existing workspace dependency type errors outside this PR, first inaccounts-controller/snap-account-servicekeyring exports, so the perps package is skipped by project references.References
No related Core GitHub issue found for
perps controller tests core.Checklist
Note
Low Risk
Low risk since changes are test-only, but they significantly expand and restructure the
@metamask/perps-controllerJest suite and relax coverage thresholds, which could affect CI behavior and coverage enforcement.Overview
Migrates the Perps controller unit test suite into
@metamask/perps-controller, adding shared mock helpers (tests/helpers/*) and a large set of new controller tests split across focused shards (PerpsController.*.test.ts).Updates the package Jest config to collect coverage from real
src/**/*.ts(excluding barrelindex.tsfiles) and adjusts enforced global coverage thresholds from 100% to 70% branches / 78% functions / 80% lines+statements.Reviewed by Cursor Bugbot for commit 3ff0529. Bugbot is set up for automated code reviews on this repo. Configure here.