@@ -1953,8 +1953,7 @@ describe('AccountTreeController', () => {
1953
1953
1954
1954
describe ( 'Fallback Naming' , ( ) => {
1955
1955
it ( 'uses consistent default naming regardless of account import time' , ( ) => {
1956
- const serviceStartTime = Date . now ( ) ;
1957
- const mockAccountWithNewImportTime : Bip44Account < InternalAccount > = {
1956
+ const mockAccount1 : Bip44Account < InternalAccount > = {
1958
1957
...MOCK_HD_ACCOUNT_1 ,
1959
1958
options : {
1960
1959
...MOCK_HD_ACCOUNT_1 . options ,
@@ -1966,11 +1965,11 @@ describe('AccountTreeController', () => {
1966
1965
} ,
1967
1966
metadata : {
1968
1967
...MOCK_HD_ACCOUNT_1 . metadata ,
1969
- importTime : serviceStartTime + 1000 , // Imported after service start
1968
+ importTime : Date . now ( ) + 1000 , // Import time no longer affects naming
1970
1969
} ,
1971
1970
} ;
1972
1971
1973
- const mockAccountWithOldImportTime : Bip44Account < InternalAccount > = {
1972
+ const mockAccount2 : Bip44Account < InternalAccount > = {
1974
1973
...MOCK_HD_ACCOUNT_2 ,
1975
1974
options : {
1976
1975
...MOCK_HD_ACCOUNT_2 . options ,
@@ -1982,12 +1981,12 @@ describe('AccountTreeController', () => {
1982
1981
} ,
1983
1982
metadata : {
1984
1983
...MOCK_HD_ACCOUNT_2 . metadata ,
1985
- importTime : serviceStartTime - 1000 , // Imported before service start
1984
+ importTime : Date . now ( ) - 1000 , // Import time no longer affects naming
1986
1985
} ,
1987
1986
} ;
1988
1987
1989
1988
const { controller } = setup ( {
1990
- accounts : [ mockAccountWithOldImportTime , mockAccountWithNewImportTime ] ,
1989
+ accounts : [ mockAccount2 , mockAccount1 ] ,
1991
1990
keyrings : [ MOCK_HD_KEYRING_1 ] ,
1992
1991
} ) ;
1993
1992
@@ -1999,20 +1998,20 @@ describe('AccountTreeController', () => {
1999
1998
2000
1999
const expectedGroupId1 = toMultichainAccountGroupId (
2001
2000
expectedWalletId ,
2002
- mockAccountWithNewImportTime . options . entropy . groupIndex ,
2001
+ mockAccount1 . options . entropy . groupIndex ,
2003
2002
) ;
2004
2003
2005
2004
const expectedGroupId2 = toMultichainAccountGroupId (
2006
2005
expectedWalletId ,
2007
- mockAccountWithOldImportTime . options . entropy . groupIndex ,
2006
+ mockAccount2 . options . entropy . groupIndex ,
2008
2007
) ;
2009
2008
2010
2009
const wallet = controller . state . accountTree . wallets [ expectedWalletId ] ;
2011
2010
const group1 = wallet ?. groups [ expectedGroupId1 ] ;
2012
2011
const group2 = wallet ?. groups [ expectedGroupId2 ] ;
2013
2012
2014
2013
// Groups should use consistent default naming regardless of import time
2015
- // This verifies the fix for the serviceStartTime inconsistency bug
2014
+ // This verifies that the serviceStartTime inconsistency bug has been fixed
2016
2015
expect ( group1 ?. metadata . name ) . toBe ( 'Account 1' ) ;
2017
2016
expect ( group2 ?. metadata . name ) . toBe ( 'Account 2' ) ;
2018
2017
} ) ;
@@ -2075,8 +2074,7 @@ describe('AccountTreeController', () => {
2075
2074
} ) ;
2076
2075
2077
2076
it ( 'handles adding new accounts to existing groups correctly' , ( ) => {
2078
- const serviceStartTime = Date . now ( ) ;
2079
- // Create an existing account (imported before service start)
2077
+ // Create an existing account
2080
2078
const existingAccount : Bip44Account < InternalAccount > = {
2081
2079
...MOCK_HD_ACCOUNT_1 ,
2082
2080
id : 'existing-account' ,
@@ -2091,11 +2089,11 @@ describe('AccountTreeController', () => {
2091
2089
metadata : {
2092
2090
...MOCK_HD_ACCOUNT_1 . metadata ,
2093
2091
name : '' , // Empty name to trigger naming logic
2094
- importTime : serviceStartTime - 1000 , // Imported before service start
2092
+ importTime : Date . now ( ) - 1000 ,
2095
2093
} ,
2096
2094
} ;
2097
2095
2098
- // Create a new account (imported after service start) for the same group
2096
+ // Create a new account for the same group
2099
2097
const newAccount : Bip44Account < InternalAccount > = {
2100
2098
...MOCK_HD_ACCOUNT_1 ,
2101
2099
id : 'new-account' ,
@@ -2110,7 +2108,7 @@ describe('AccountTreeController', () => {
2110
2108
metadata : {
2111
2109
...MOCK_HD_ACCOUNT_1 . metadata ,
2112
2110
name : '' , // Empty name to trigger naming logic
2113
- importTime : serviceStartTime + 1000 , // Imported after service start
2111
+ importTime : Date . now ( ) + 1000 , // Import time no longer affects naming
2114
2112
} ,
2115
2113
} ;
2116
2114
@@ -2136,22 +2134,22 @@ describe('AccountTreeController', () => {
2136
2134
const wallet = controller . state . accountTree . wallets [ expectedWalletId ] ;
2137
2135
const group = wallet ?. groups [ expectedGroupId ] ;
2138
2136
2139
- // The group should now be treated as "new" and use fallback naming
2137
+ // The group should use consistent default naming
2140
2138
expect ( group ?. metadata . name ) . toBe ( 'Account 1' ) ;
2141
2139
expect ( group ?. accounts ) . toHaveLength ( 2 ) ;
2142
2140
expect ( group ?. accounts ) . toContain ( existingAccount . id ) ;
2143
2141
expect ( group ?. accounts ) . toContain ( newAccount . id ) ;
2144
2142
} ) ;
2145
2143
2146
- it ( 'handles groups not in WeakMap (fallback to false) ' , ( ) => {
2147
- // Create an account with empty name to trigger naming logic
2144
+ it ( 'uses default naming when rule-based naming returns empty ' , ( ) => {
2145
+ // Create an account with empty name to trigger fallback to default naming
2148
2146
const mockAccountWithEmptyName : Bip44Account < InternalAccount > = {
2149
2147
...MOCK_HD_ACCOUNT_1 ,
2150
2148
id : 'account-with-empty-name' ,
2151
2149
metadata : {
2152
2150
...MOCK_HD_ACCOUNT_1 . metadata ,
2153
- name : '' , // Empty name will cause rule-based naming to fail
2154
- importTime : Date . now ( ) - 1000 , // Old account (not new)
2151
+ name : '' ,
2152
+ importTime : Date . now ( ) - 1000 ,
2155
2153
} ,
2156
2154
} ;
2157
2155
@@ -2170,7 +2168,7 @@ describe('AccountTreeController', () => {
2170
2168
const wallet = controller . state . accountTree . wallets [ expectedWalletId ] ;
2171
2169
const group = wallet ?. groups [ expectedGroupId ] ;
2172
2170
2173
- // Should use computed name first since it's not a new group , then fallback to default
2171
+ // Should use computed name first, then fallback to default
2174
2172
// Since the account has empty name, computed name will be empty, so it falls back to default
2175
2173
expect ( group ?. metadata . name ) . toBe ( 'Account 1' ) ;
2176
2174
} ) ;
0 commit comments