diff --git a/src/lib/test/keyring.test.js b/src/lib/test/keyring.test.js index efa1314..9e1b7d4 100644 --- a/src/lib/test/keyring.test.js +++ b/src/lib/test/keyring.test.js @@ -22,7 +22,7 @@ beforeAll(async() => { result = await vault.generateVault(bufView,pin,phrase) vaultAddress=result.response - await vault.getAccounts(bufView); + await vault.getAccounts(); }); describe('exportMnemonic' , ()=>{ @@ -115,14 +115,14 @@ describe('addAccount' , ()=>{ }) - test('addAccount/empty encryption key' , async()=>{ + test('addAccount/empty encryption key' , async()=>{ try{ let result = await vault.addAccount(null,pin) } catch(e){ - expect(e.message).toBe("Cannot read properties of undefined (reading 'length')") + expect(e.message).toBe("Incorrect Encryption Key or vault string") } - + }) test('addAccount/empty pin' , async()=>{ @@ -892,6 +892,18 @@ describe('changePin',()=>{ }) + test('changePin/wrong currentpin' , async()=>{ + try{ + let result = await vault.changePin(111111,pin,bufView) + + } + catch(e){ + expect(e).toBe('Wrong pin type, format or length') + } + + + }) + test('changePin/invalid currentpin' , async()=>{ try{ let result = await vault.changePin('aefe',pin,bufView) @@ -942,19 +954,23 @@ describe('changePin',()=>{ }) test('changePin/empty encryption key' , async()=>{ - - let result = await vault.changePin(pin,pin,null) - expect(result).toHaveProperty('response') - - - + try{ + let result = await vault.changePin(pin,pin,null) + } + catch(e){ + expect(e.message).toBe("Incorrect Encryption Key or vault string") + } + }) test('changePin/invalid encryption key' , async()=>{ - + try{ let result = await vault.changePin(pin,pin,'efefe') - expect(result).toHaveProperty('response') + } + catch(e){ + expect(e.message).toBe("Incorrect Encryption Key or vault string") + } @@ -996,17 +1012,23 @@ describe('deleteAccount',()=>{ }) test('deleteAccount/empty encryption key' , async()=>{ - + try{ let result = await vault.deleteAccount(null,accAddress,pin) - expect(result.error).toBe('This address is not present in the vault') + } + catch(e){ + expect(e.message).toBe("Incorrect Encryption Key or vault string") + } }) test('deleteAccount/invalid encryption key' , async()=>{ - + try{ let result = await vault.deleteAccount(null,accAddress,pin) - expect(result.error).toBe('This address is not present in the vault') + } + catch(e){ + expect(e.message).toBe("Incorrect Encryption Key or vault string") + } }) @@ -1066,22 +1088,11 @@ describe('deleteAccount',()=>{ describe('getAccounts',()=>{ test('getAccounts/valid' , async()=>{ await vault.restoreKeyringState(vaultAddress,pin,bufView) - let result = await vault.getAccounts(bufView) + let result = await vault.getAccounts() expect(result).toHaveProperty('response') }) - test('getAccounts/empty encryption key ' , async()=>{ - - let result = await vault.getAccounts(null) - expect(result.error).toBe('Incorrect Encryption Key or vault string') - - }) - test('getAccounts/invalid encryption key ' , async()=>{ - - let result = await vault.getAccounts("aefefe") - expect(result.error).toBe('Incorrect Encryption Key or vault string') - - }) + }) @@ -1142,7 +1153,7 @@ describe('signTransaction',()=>{ } catch(e){ - expect(e.message).toBe("No keyring found for the requested account.") + expect(e.message).toBe("Cannot read properties of undefined (reading 'toLowerCase')") } @@ -1173,7 +1184,7 @@ describe('signTransaction',()=>{ } catch(e){ - expect(e.message).toBe("No keyring found for the requested account.") + expect(e.message).toBe("Cannot read properties of undefined (reading 'toLowerCase')") } diff --git a/src/lib/test/vault.test.js b/src/lib/test/vault.test.js index 061ad16..9a89324 100644 --- a/src/lib/test/vault.test.js +++ b/src/lib/test/vault.test.js @@ -12,7 +12,7 @@ describe('getSupportedChains' , ()=>{ test('getSupportedChains' , async()=>{ - let result = await new Vault().getSupportedChains() + let result = await new Vault({}).getSupportedChains() expect({ evmChains: { ethereum: 'ETH', bsc: 'BSC', polygon: 'MATIC', optimism: 'OP', arbitrum: 'ARB', mantle: 'MNT', velas: 'VLX' }, nonEvmChains: { bitcoin: 'BTC' } @@ -28,7 +28,7 @@ describe('generateMnemonic' , ()=>{ test('generateMnemonic' , async()=>{ - let result = await new Vault().generateMnemonic() + let result = await new Vault({}).generateMnemonic() Mnemonic=result expect(typeof(result)).toBe("string") @@ -58,7 +58,7 @@ describe("generateVault",()=>{ const buf = new ArrayBuffer(32); const bufView = new Uint8Array(buf); - let result = await new Vault().generateVault(bufView,null,Mnemonic) + let result = await new Vault({}).generateVault(bufView,null,Mnemonic) expect(result.error).toBe("Wrong pin type, format or length") }) @@ -66,14 +66,14 @@ describe("generateVault",()=>{ test('generateVault/empty encrption key' , async()=>{ const buf = new ArrayBuffer(32); const bufView = new Uint8Array(buf); - let result = await new Vault().generateVault(null,1111,Mnemonic) + let result = await new Vault({}).generateVault(null,1111,Mnemonic) expect(result.error).toBe('Wrong pin type, format or length') }) test('generateVault/empty encrption key' , async()=>{ const buf = new ArrayBuffer(32); const bufView = new Uint8Array(buf); - let result = await new Vault().generateVault(null,111111,Mnemonic) + let result = await new Vault({}).generateVault(null,111111,Mnemonic) expect(result.error).toBe('Please enter both encryptionKey and pin') }) @@ -82,7 +82,7 @@ describe("generateVault",()=>{ const buf = new ArrayBuffer(32); const bufView = new Uint8Array(buf); try{ - let result = await new Vault().generateVault(bufView,1111,null) + let result = await new Vault({}).generateVault(bufView,1111,null) } catch(e){ expect(e.message).toBe('Seed phrase is invalid.') @@ -95,7 +95,7 @@ describe("generateVault",()=>{ const buf = new ArrayBuffer(32); const bufView = new Uint8Array(buf); - let result = await new Vault().generateVault(null,null,null) + let result = await new Vault({}).generateVault(null,null,null) expect(result.error).toBe("Wrong pin type, format or length")