Skip to content

Commit 01652f5

Browse files
seaonagambinish
authored andcommitted
test: fix state fixtures race condition (#28421)
<!-- Please submit this PR as a draft initially. Do not mark it as "Ready for review" until the template has been completely filled out, and PR status checks have passed at least once. --> ## **Description** There is a race condition in our testing setup, which causes that the expected fixtures state, not being there when we start the test. This has been surfaced in [this branch](#28277), where the account tracker multi polling is being added. The problem is that if we don't have the AccountTracker in state when the `resetState` function is called (at the beginning of wallet loading) the balance will remain loading until we refresh the wallet. Edit: performing the load state early in the test setup fixes the issue. [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/28421?quickstart=1) ## **Related issues** Fixes: MetaMask/MetaMask-planning#3627 ## **Manual testing steps** 1. Check all tests continue to pass 2. Check this changes fix this branch ENS test https://github.com/MetaMask/metamask-extension/pull/28402/files#diff-1acb7898d60977530c97169551d22dbe477a4e3aeb74f1f14bf2eea0b4d75d35 . Alternatively, see videos below with before and after behaviours ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** https://github.com/user-attachments/assets/8f50ec04-cf96-478e-9c3c-dce54254a628 ### **After** https://github.com/user-attachments/assets/0f109b1a-9289-48d9-b337-d51890c9d448 ## **Pre-merge author checklist** - [x] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [x] I’ve included tests if applicable - [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.
1 parent 57f8af1 commit 01652f5

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

test/e2e/helpers.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,9 @@ async function withFixtures(options, testSuite) {
119119
contractRegistry = ganacheSeeder.getContractRegistry();
120120
}
121121

122+
await fixtureServer.start();
123+
fixtureServer.loadJsonState(fixtures, contractRegistry);
124+
122125
if (ganacheOptions?.concurrent) {
123126
ganacheOptions.concurrent.forEach(async (ganacheSettings) => {
124127
const { port, chainId, ganacheOptions2 } = ganacheSettings;
@@ -138,8 +141,6 @@ async function withFixtures(options, testSuite) {
138141
await initBundler(bundlerServer, ganacheServer, usePaymaster);
139142
}
140143

141-
await fixtureServer.start();
142-
fixtureServer.loadJsonState(fixtures, contractRegistry);
143144
await phishingPageServer.start();
144145
if (dapp) {
145146
if (dappOptions?.numberOfDapps) {

0 commit comments

Comments
 (0)