@@ -32,7 +32,7 @@ import {
32
32
} from './AccountTreeController' ;
33
33
import type { BackupAndSyncAnalyticsEventPayload } from './backup-and-sync/analytics' ;
34
34
import { BackupAndSyncService } from './backup-and-sync/service' ;
35
- import { isAccountGroupNameUnique } from './group' ;
35
+ import { AccountGroupMultichainAccountObject , isAccountGroupNameUnique } from './group' ;
36
36
import { getAccountWalletNameFromKeyringType } from './rules/keyring' ;
37
37
import {
38
38
type AccountTreeControllerMessenger ,
@@ -42,6 +42,7 @@ import {
42
42
type AllowedActions ,
43
43
type AllowedEvents ,
44
44
} from './types' ;
45
+ import { AccountWalletKeyringObject , AccountWalletObject } from './wallet' ;
45
46
46
47
// Local mock of EMPTY_ACCOUNT to avoid circular dependency
47
48
const EMPTY_ACCOUNT_MOCK : InternalAccount = {
@@ -1215,6 +1216,26 @@ describe('AccountTreeController', () => {
1215
1216
} ,
1216
1217
} as AccountTreeControllerState ) ;
1217
1218
} ) ;
1219
+
1220
+ it ( 'does not remove account if init has not been called' , ( ) => {
1221
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
1222
+ const { controller, messenger } = setup ( {
1223
+ accounts : [ MOCK_HD_ACCOUNT_1 ] ,
1224
+ } ) ;
1225
+
1226
+ const mockAccountTreeChange = jest . fn ( ) ;
1227
+ messenger . subscribe (
1228
+ 'AccountTreeController:accountTreeChange' ,
1229
+ mockAccountTreeChange ,
1230
+ ) ;
1231
+
1232
+ messenger . publish (
1233
+ 'AccountsController:accountRemoved' ,
1234
+ MOCK_HD_ACCOUNT_1 . id ,
1235
+ ) ;
1236
+
1237
+ expect ( mockAccountTreeChange ) . not . toHaveBeenCalled ( ) ;
1238
+ } ) ;
1218
1239
} ) ;
1219
1240
1220
1241
describe ( 'account ordering by type' , ( ) => {
@@ -1487,6 +1508,14 @@ describe('AccountTreeController', () => {
1487
1508
hasAccountTreeSyncingSyncedAtLeastOnce : false ,
1488
1509
} as AccountTreeControllerState ) ;
1489
1510
} ) ;
1511
+
1512
+ it ( 'does not add any account if init has not been called' , ( ) => {
1513
+ const { controller, messenger } = setup ( ) ;
1514
+
1515
+ expect ( controller . state . accountTree . wallets ) . toStrictEqual ( { } ) ;
1516
+ messenger . publish ( 'AccountsController:accountAdded' , MOCK_HD_ACCOUNT_1 ) ;
1517
+ expect ( controller . state . accountTree . wallets ) . toStrictEqual ( { } ) ;
1518
+ } ) ;
1490
1519
} ) ;
1491
1520
1492
1521
describe ( 'on MultichainAccountService:walletStatusUpdate' , ( ) => {
@@ -4266,6 +4295,8 @@ describe('AccountTreeController', () => {
4266
4295
it ( 'names non-HD keyrings accounts properly' , ( ) => {
4267
4296
const { controller, messenger } = setup ( ) ;
4268
4297
4298
+ controller . init ( ) ;
4299
+
4269
4300
// Add all 3 accounts.
4270
4301
[ mockAccount1 , mockAccount2 , mockAccount3 ] . forEach (
4271
4302
( mockAccount , index ) => {
@@ -4418,6 +4449,8 @@ describe('AccountTreeController', () => {
4418
4449
it ( 'fallbacks to natural indexing if group names are not using our default name pattern' , ( ) => {
4419
4450
const { controller, messenger } = setup ( ) ;
4420
4451
4452
+ controller . init ( ) ;
4453
+
4421
4454
[ mockAccount1 , mockAccount2 , mockAccount3 ] . forEach ( ( mockAccount ) =>
4422
4455
messenger . publish ( 'AccountsController:accountAdded' , mockAccount ) ,
4423
4456
) ;
0 commit comments