@@ -94,6 +94,19 @@ describe('KeyringController', function () {
9494 } ) ;
9595 } ) ;
9696
97+ describe ( 'persistAllKeyrings' , function ( ) {
98+ it ( 'should persist keyrings in _unsupportedKeyrings array' , async function ( ) {
99+ const unsupportedKeyring = 'DUMMY_KEYRING' ;
100+ keyringController . _unsupportedKeyrings = [ unsupportedKeyring ] ;
101+ await keyringController . persistAllKeyrings ( ) ;
102+
103+ const { vault } = keyringController . store . getState ( ) ;
104+ const keyrings = await mockEncryptor . decrypt ( password , vault ) ;
105+ expect ( keyrings . indexOf ( unsupportedKeyring ) > - 1 ) . toBe ( true ) ;
106+ expect ( keyrings ) . toHaveLength ( 2 ) ;
107+ } ) ;
108+ } ) ;
109+
97110 describe ( 'createNewVaultAndKeychain' , function ( ) {
98111 it ( 'should create a new vault' , async function ( ) {
99112 keyringController . store . updateState ( { vault : null } ) ;
@@ -245,6 +258,13 @@ describe('KeyringController', function () {
245258 const accounts = await keyring . getAccounts ( ) ;
246259 expect ( accounts [ 0 ] ) . toBe ( walletOneAddresses [ 0 ] ) ;
247260 } ) ;
261+ it ( 'should return undefined if keyring type is not supported.' , async function ( ) {
262+ const unsupportedKeyring = { type : 'Ledger Keyring' , data : 'DUMMY' } ;
263+ const keyring = await keyringController . restoreKeyring (
264+ unsupportedKeyring ,
265+ ) ;
266+ expect ( keyring ) . toBeUndefined ( ) ;
267+ } ) ;
248268 } ) ;
249269
250270 describe ( 'getAccounts' , function ( ) {
@@ -330,6 +350,16 @@ describe('KeyringController', function () {
330350 expect ( keyring . wallets ) . toHaveLength ( 1 ) ;
331351 } ) ;
332352 } ) ;
353+ it ( 'add serialized keyring to _unsupportedKeyrings array if keyring type is not known' , async function ( ) {
354+ const _unsupportedKeyrings = [ { type : 'Ledger Keyring' , data : 'DUMMY' } ] ;
355+ mockEncryptor . encrypt ( password , _unsupportedKeyrings ) ;
356+ await keyringController . setLocked ( ) ;
357+ const keyrings = await keyringController . unlockKeyrings ( password ) ;
358+ expect ( keyrings ) . toHaveLength ( 0 ) ;
359+ expect ( keyringController . _unsupportedKeyrings ) . toStrictEqual (
360+ _unsupportedKeyrings ,
361+ ) ;
362+ } ) ;
333363 } ) ;
334364
335365 describe ( 'verifyPassword' , function ( ) {
0 commit comments