-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into fix/transaction-simulation-bug
- Loading branch information
Showing
22 changed files
with
1,182 additions
and
43 deletions.
There are no files selected for viewing
This file contains 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
54 changes: 54 additions & 0 deletions
54
app/core/Engine/controllers/AccountsController/logger.test.ts
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import Logger from '../../../../util/Logger'; | ||
import { logAccountsControllerCreation } from './logger'; | ||
import { defaultAccountsControllerState } from './utils'; | ||
import { MOCK_ACCOUNTS_CONTROLLER_STATE } from '../../../../util/test/accountsControllerTestUtils'; | ||
|
||
jest.mock('../../../../util/Logger'); | ||
|
||
describe('logAccountsControllerCreation', () => { | ||
beforeEach(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
it('logs creation with default state when no initial state provided', () => { | ||
logAccountsControllerCreation(); | ||
|
||
expect(Logger.log).toHaveBeenCalledWith( | ||
'Creating AccountsController with default state', | ||
{ | ||
defaultState: defaultAccountsControllerState, | ||
}, | ||
); | ||
}); | ||
|
||
it('logs creation with empty initial state', () => { | ||
const initialState = { | ||
internalAccounts: { | ||
accounts: {}, | ||
selectedAccount: '', | ||
}, | ||
}; | ||
|
||
logAccountsControllerCreation(initialState); | ||
|
||
expect(Logger.log).toHaveBeenCalledWith( | ||
'Creating AccountsController with provided initial state', | ||
{ | ||
hasSelectedAccount: false, | ||
accountsCount: 0, | ||
}, | ||
); | ||
}); | ||
|
||
it('logs creation with populated initial state', () => { | ||
logAccountsControllerCreation(MOCK_ACCOUNTS_CONTROLLER_STATE); | ||
|
||
expect(Logger.log).toHaveBeenCalledWith( | ||
'Creating AccountsController with provided initial state', | ||
{ | ||
hasSelectedAccount: true, | ||
accountsCount: 2, | ||
}, | ||
); | ||
}); | ||
}); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { AccountsControllerState } from '@metamask/accounts-controller'; | ||
import Logger from '../../../../util/Logger'; | ||
import { defaultAccountsControllerState } from './utils'; | ||
|
||
export function logAccountsControllerCreation( | ||
initialState?: AccountsControllerState, | ||
) { | ||
if (!initialState) { | ||
Logger.log('Creating AccountsController with default state', { | ||
defaultState: defaultAccountsControllerState, | ||
}); | ||
} else { | ||
Logger.log('Creating AccountsController with provided initial state', { | ||
hasSelectedAccount: !!initialState.internalAccounts?.selectedAccount, | ||
accountsCount: Object.keys(initialState.internalAccounts?.accounts || {}) | ||
.length, | ||
}); | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { KeyringControllerState } from '@metamask/keyring-controller'; | ||
import { EngineState } from '../types'; | ||
import Logger from '../../../util/Logger'; | ||
|
||
export function logEngineCreation( | ||
initialState: Partial<EngineState> = {}, | ||
initialKeyringState?: KeyringControllerState | null, | ||
) { | ||
if (Object.keys(initialState).length === 0) { | ||
Logger.log('Engine initialized with empty state', { | ||
keyringStateFromBackup: !!initialKeyringState, | ||
}); | ||
} else { | ||
Logger.log('Engine initialized with non-empty state', { | ||
hasAccountsState: !!initialState.AccountsController, | ||
hasKeyringState: !!initialState.KeyringController, | ||
keyringStateFromBackup: !!initialKeyringState, | ||
}); | ||
} | ||
} |
Oops, something went wrong.