Uh oh!
There was an error while loading. Please reload this page.
test(perps): migrate controller unit tests to core - #8840
Conversation
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
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.
Uh oh!
There was an error while loading. Please reload this page.
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.
Uh oh!
There was an error while loading. Please reload this page.
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.
Uh oh!
There was an error while loading. Please reload this page.
## Explanation Minor release of `@metamask/perps-controller` (6.2.0 → 6.3.0). **Added** - Per-order slippage controls for market trades - `vip_tier` / `vip_discount` properties on perps trading events for fee analytics - In-app banner during HyperLiquid outages - Subpath `exports` for `./constants`, `./constants/*`, `./types`, `./utils/*` so consumers using legacy `node` resolution can deep-import without losing tree-shaking **Fixed** - Resolve trading account against currently selected EVM account so account switching is honored across providers - Suppress `User or API Wallet does not exist` Sentry noise from unfunded wallets - Auto-approve HyperLiquid builder fee when missing so order submission succeeds after fresh wallet setup See `packages/perps-controller/CHANGELOG.md` for full details. ## References - MetaMask#8871 (perps sync May 21 2026) - MetaMask#8883 (subpath exports) - MetaMask#8840 (test migration — internal, omitted from changelog) ## Checklist - [x] I've updated the test suite for new or updated code as appropriate - [x] I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate - [x] I've communicated my changes to consumers by [updating changelogs for packages I've changed](https://github.com/MetaMask/core/tree/main/docs/processes/updating-changelogs.md) - [ ] I've introduced [breaking changes](https://github.com/MetaMask/core/tree/main/docs/processes/breaking-changes.md) in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

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.