This repository was archived by the owner on Oct 7, 2024. It is now read-only.
  
  
  
  
    
    
    
      
    
  
  
    
File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -247,7 +247,7 @@ class KeyringController extends EventEmitter {
247247
248248    if  ( ( ! opts  ||  ! opts . mnemonic )  &&  type  ===  KEYRINGS_TYPE_MAP . HD_KEYRING )  { 
249249      keyring . generateRandomMnemonic ( ) ; 
250-       keyring . addAccounts ( ) ; 
250+       await   keyring . addAccounts ( ) ; 
251251    } 
252252
253253    const  accounts  =  await  keyring . getAccounts ( ) ; 
Original file line number Diff line number Diff line change @@ -280,6 +280,22 @@ describe('KeyringController', function () {
280280
281281      sinon . assert . calledOnce ( initSpy ) ; 
282282    } ) ; 
283+ 
284+     it ( 'should add HD Key Tree when addAccounts is asynchronous' ,  async  function  ( )  { 
285+       const  originalAccAccounts  =  HdKeyring . prototype . addAccounts ; 
286+       sinon . stub ( HdKeyring . prototype ,  'addAccounts' ) . callsFake ( function  ( )  { 
287+         return  new  Promise ( ( resolve )  =>  { 
288+           setImmediate ( ( )  =>  { 
289+             resolve ( originalAccAccounts . bind ( this ) ( ) ) ; 
290+           } ) ; 
291+         } ) ; 
292+       } ) ; 
293+ 
294+       const  keyring  =  await  keyringController . addNewKeyring ( 'HD Key Tree' ) ; 
295+ 
296+       const  keyringAccounts  =  await  keyring . getAccounts ( ) ; 
297+       expect ( keyringAccounts ) . toHaveLength ( 1 ) ; 
298+     } ) ; 
283299  } ) ; 
284300
285301  describe ( 'restoreKeyring' ,  function  ( )  { 
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments