@@ -83,29 +83,49 @@ describe('createBip39KeyFromSeed', () => {
8383} ) ; 
8484
8585describe ( 'Cip3' ,  ( )  =>  { 
86-   fixtures . cip3 . forEach ( ( fixture )  =>  { 
87-     describe ( 'entropyToCip3MasterNode' ,  ( )  =>  { 
88-       it ( 'derives the correct bip39 key for ed25519Bip32 curve' ,  async  ( )  =>  { 
86+   describe ( 'entropyToCip3MasterNode' ,  ( )  =>  { 
87+     it . each ( fixtures . cip3 ) ( 
88+       'derives the correct bip39 key for ed25519Bip32 curve' , 
89+       async  ( fixture )  =>  { 
8990        const  result  =  await  entropyToCip3MasterNode ( 
9091          hexToBytes ( fixture . entropyHex ) , 
9192          ed25519Bip32 , 
9293        ) ; 
9394        const  {  bip39Node }  =  fixture . nodes ; 
9495        expect ( result . privateKey ) . toBe ( bip39Node . privateKey ) ; 
9596        expect ( result . chainCode ) . toBe ( bip39Node . chainCode ) ; 
96-       } ) ; 
97+       } , 
98+     ) ; 
99+ 
100+     it ( 'throws if the entropy is less than 16 bytes' ,  async  ( )  =>  { 
101+       await  expect ( 
102+         entropyToCip3MasterNode ( new  Uint8Array ( 15 ) ,  ed25519Bip32 ) , 
103+       ) . rejects . toThrow ( 
104+         'Invalid entropy: The entropy must be between 16 and 64 bytes long.' , 
105+       ) ; 
97106    } ) ; 
98107
99-     describe ( 'deriveChildKey' ,  ( )  =>  { 
100-       it ( 'derives the correct child key for ed25519Bip32 curve from mnemonic' ,  async  ( )  =>  { 
108+     it ( 'throws if the entropy is greater than 64 bytes' ,  async  ( )  =>  { 
109+       await  expect ( 
110+         entropyToCip3MasterNode ( new  Uint8Array ( 65 ) ,  ed25519Bip32 ) , 
111+       ) . rejects . toThrow ( 
112+         'Invalid entropy: The entropy must be between 16 and 64 bytes long.' , 
113+       ) ; 
114+     } ) ; 
115+   } ) ; 
116+ 
117+   describe ( 'deriveChildKey' ,  ( )  =>  { 
118+     it . each ( fixtures . cip3 ) ( 
119+       'derives the correct child key for ed25519Bip32 curve from mnemonic' , 
120+       async  ( fixture )  =>  { 
101121        const  result  =  await  deriveChildKey ( { 
102122          path : fixture . mnemonic , 
103123          curve : ed25519Bip32 , 
104124        } ) ; 
105125        const  {  bip39Node }  =  fixture . nodes ; 
106126        expect ( result . privateKey ) . toBe ( bip39Node . privateKey ) ; 
107127        expect ( result . chainCode ) . toBe ( bip39Node . chainCode ) ; 
108-       } ) ; 
109-     } ) ; 
128+       } , 
129+     ) ; 
110130  } ) ; 
111131} ) ; 
0 commit comments