-
-
Notifications
You must be signed in to change notification settings - Fork 276
feat(multichain-account-service): add local perf tracing (debug) + more traces #8244
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
base: main
Are you sure you want to change the base?
Changes from all commits
ecbfa0b
ad1685f
e79f703
ddf487b
4e3c2c0
b2c5d62
ee36b11
67626ce
09fd2c1
fd669ea
57dceb4
f0db0c1
5abaef1
ea21023
850d355
7b2d87a
188ee01
ea870aa
5c6203a
33659d2
498b8fb
8aeb588
3d11ebc
5ffe10e
775199d
a5e4544
a5709d7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,6 +14,7 @@ import { | |
| AccountCreationType, | ||
| } from '@metamask/keyring-api'; | ||
| import type { InternalAccount } from '@metamask/keyring-internal-api'; | ||
| import { createDeferredPromise } from '@metamask/utils'; | ||
|
|
||
| import type { WalletState } from './MultichainAccountWallet'; | ||
| import { MultichainAccountWallet } from './MultichainAccountWallet'; | ||
|
|
@@ -542,19 +543,31 @@ describe('MultichainAccountWallet', () => { | |
| ]; | ||
| evmProvider.createAccounts.mockResolvedValueOnce(evmAccounts); | ||
|
|
||
| jest.spyOn(wallet, 'alignAccounts').mockResolvedValue(undefined); | ||
| // We use a non-resolving mock for SOL provider because we want to verify | ||
| // that it's not called during group creation, but rather during the deferred alignment. | ||
| const { | ||
| promise: mockSolCreateAccountsPromise, | ||
| resolve: mockSolCreateAccountsResolve, | ||
| } = createDeferredPromise(); | ||
| jest | ||
| .spyOn(solProvider, 'createAccounts') | ||
| .mockImplementationOnce(() => mockSolCreateAccountsPromise); | ||
|
Comment on lines
+546
to
+554
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Re-wrote this logic since non-EVM post alignment is scheduled asynchronously, so it's not always reliable to have determinist behavior when you change async calls. This should future-proof it in a more reliable way! |
||
|
|
||
| // With wait=false (default), only EVM accounts are created immediately. | ||
| const groups = await wallet.createMultichainAccountGroups({ to: 2 }); | ||
|
|
||
| // At this point, only EVM provider should have been called to create accounts for groups 1 and 2, but | ||
| // the SOL provider is has been scheduled, so it shouldn't block. | ||
| expect(groups).toHaveLength(3); | ||
| expect(groups[0].groupIndex).toBe(0); // Existing group. | ||
| expect(groups[1].groupIndex).toBe(1); // New group. | ||
| expect(groups[2].groupIndex).toBe(2); // New group. | ||
| expect(wallet.getAccountGroups()).toHaveLength(3); | ||
|
|
||
| // SOL provider is not called during group creation; it's deferred to alignment. | ||
| expect(solProvider.createAccounts).not.toHaveBeenCalled(); | ||
| mockSolCreateAccountsResolve(); | ||
| await mockSolCreateAccountsPromise; | ||
| expect(solProvider.createAccounts).toHaveBeenCalled(); | ||
| }); | ||
|
|
||
| it('returns all existing groups when maxGroupIndex is less than nextGroupIndex', async () => { | ||
|
|
@@ -575,8 +588,6 @@ describe('MultichainAccountWallet', () => { | |
| accounts: [[mockEvmAccount0, mockEvmAccount1, mockEvmAccount2]], | ||
| }); | ||
|
|
||
| jest.spyOn(wallet, 'alignAccounts').mockResolvedValue(undefined); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This actually had no effect! |
||
|
|
||
| // Request groups 0-1 when groups 0-2 exist. | ||
| const groups = await wallet.createMultichainAccountGroups({ to: 1 }); | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.