-
-
Notifications
You must be signed in to change notification settings - Fork 183
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix issue where mutex is acquired after state is read in addToken
resulting in overwritten state with batched addToken/watchAsset calls
#1768
Conversation
…ulting in overwritten state with batched addToken/watchAsset calls
.mockImplementationOnce(() => requestId) | ||
.mockImplementationOnce(() => '67890'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.mockImplementationOnce(() => requestId) | |
.mockImplementationOnce(() => '67890'); | |
.mockReturnValueOnce(requestId) | |
.mockReturnValueOnce('67890'); |
state.allTokens?.[ChainId.mainnet]?.[interactingAddress].length === | ||
2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
state.allTokens?.[ChainId.mainnet]?.[interactingAddress].length === | |
2 | |
state.tokens.length === 2 |
maybe? but definitely keep the allTokens checks below
...anotherAsset, | ||
}, | ||
]); | ||
generateRandomIdStub.mockRestore(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
jest.resetAllMocks()
in a beforeEach()
?
EDIT: ohh... I see. This pattern is used 4 other times in this file already. Up to you if you want to clean it up or not
…esulting in overwritten state with batched addToken/watchAsset calls (#1768) Fixes a subtle bug: when multiple `wallet_watchAsset` calls of ERC20 tokens are batched, only the last of the tokens added was getting added because the calls were not properly single threaded, since the mutex was acquired after reading state in the `addToken` call. ## TokensController ### Fixes - Fixes bug where batched addToken calls overwrite each other because mutex is acquired after reading state
…esulting in overwritten state with batched addToken/watchAsset calls (#1768) Fixes a subtle bug: when multiple `wallet_watchAsset` calls of ERC20 tokens are batched, only the last of the tokens added was getting added because the calls were not properly single threaded, since the mutex was acquired after reading state in the `addToken` call. ## TokensController ### Fixes - Fixes bug where batched addToken calls overwrite each other because mutex is acquired after reading state
…esulting in overwritten state with batched addToken/watchAsset calls (#1768) Fixes a subtle bug: when multiple `wallet_watchAsset` calls of ERC20 tokens are batched, only the last of the tokens added was getting added because the calls were not properly single threaded, since the mutex was acquired after reading state in the `addToken` call. ## TokensController ### Fixes - Fixes bug where batched addToken calls overwrite each other because mutex is acquired after reading state
Fixes a subtle bug: when multiple
wallet_watchAsset
calls of ERC20 tokens are batched, only the last of the tokens added was getting added because the calls were not properly single threaded, since the mutex was acquired after reading state in theaddToken
call.TokensController
Fixes