diff options
author | Thomas <thomas.b.huang@gmail.com> | 2018-05-09 16:51:55 +0800 |
---|---|---|
committer | Thomas <thomas.b.huang@gmail.com> | 2018-05-09 16:51:55 +0800 |
commit | 9a1661918f19a258c22d2c61b7ea972f9640667d (patch) | |
tree | f8aa7103a20704963d99c750cb3636be37564276 /test/unit | |
parent | f2e1cb9302320c9abf2814bfdaea98aee7add92e (diff) | |
download | tangerine-wallet-browser-9a1661918f19a258c22d2c61b7ea972f9640667d.tar tangerine-wallet-browser-9a1661918f19a258c22d2c61b7ea972f9640667d.tar.gz tangerine-wallet-browser-9a1661918f19a258c22d2c61b7ea972f9640667d.tar.bz2 tangerine-wallet-browser-9a1661918f19a258c22d2c61b7ea972f9640667d.tar.lz tangerine-wallet-browser-9a1661918f19a258c22d2c61b7ea972f9640667d.tar.xz tangerine-wallet-browser-9a1661918f19a258c22d2c61b7ea972f9640667d.tar.zst tangerine-wallet-browser-9a1661918f19a258c22d2c61b7ea972f9640667d.zip |
ImportAccountWithStrategies Json and Keystore
Diffstat (limited to 'test/unit')
-rw-r--r-- | test/unit/account-import-strategies.spec.js | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/test/unit/account-import-strategies.spec.js b/test/unit/account-import-strategies.spec.js new file mode 100644 index 000000000..e0417299a --- /dev/null +++ b/test/unit/account-import-strategies.spec.js @@ -0,0 +1,30 @@ +const assert = require('assert') +const accountImporter = require('../../app/scripts/account-import-strategies/index') +const ethUtil = require('ethereumjs-util') + +describe('Account Import Strategies', function () { + const privkey = '0x4cfd3e90fc78b0f86bf7524722150bb8da9c60cd532564d7ff43f5716514f553' + const json = '{"version":3,"id":"dbb54385-0a99-437f-83c0-647de9f244c3","address":"a7f92ce3fba24196cf6f4bd2e1eb3db282ba998c","Crypto":{"ciphertext":"bde13d9ade5c82df80281ca363320ce254a8a3a06535bbf6ffdeaf0726b1312c","cipherparams":{"iv":"fbf93718a57f26051b292f072f2e5b41"},"cipher":"aes-128-ctr","kdf":"scrypt","kdfparams":{"dklen":32,"salt":"7ffe00488319dec48e4c49a120ca49c6afbde9272854c64d9541c83fc6acdffe","n":8192,"r":8,"p":1},"mac":"2adfd9c4bc1cdac4c85bddfb31d9e21a684e0e050247a70c5698facf6b7d4681"}}' + + it('imports a private key and strips 0x prefix', async function () { + const importPrivKey = await accountImporter.importAccount('Private Key', [ privkey ]) + assert.equal(importPrivKey, ethUtil.stripHexPrefix(privkey)) + }) + + it('fails when password is incorrect for keystore', async function () { + const wrongPassword = 'password2' + + try { + await accountImporter.importAccount('JSON File', [ json, wrongPassword]) + } catch (error) { + assert.equal(error.message, 'Key derivation failed - possibly wrong passphrase') + } + }) + + it('imports json string and password to return a private key', async function () { + const fileContentsPassword = 'password1' + const importJson = await accountImporter.importAccount('JSON File', [ json, fileContentsPassword]) + console.log(importJson) + }) + +}) |