diff options
author | Frankie <frankie.diamond@gmail.com> | 2016-09-13 01:22:06 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-09-13 01:22:06 +0800 |
commit | fcc9ca812e557fd5ecc547f5eb597069788d6c00 (patch) | |
tree | 8cf24728e862b048c49e0e94bb1d614b42ddf3bc /test | |
parent | 3e836abc4797445fa97f8d325c2b4801d2106930 (diff) | |
parent | 56b9b1766d5d71ac427e27503e5fc8b51fd85b99 (diff) | |
download | tangerine-wallet-browser-fcc9ca812e557fd5ecc547f5eb597069788d6c00.tar tangerine-wallet-browser-fcc9ca812e557fd5ecc547f5eb597069788d6c00.tar.gz tangerine-wallet-browser-fcc9ca812e557fd5ecc547f5eb597069788d6c00.tar.bz2 tangerine-wallet-browser-fcc9ca812e557fd5ecc547f5eb597069788d6c00.tar.lz tangerine-wallet-browser-fcc9ca812e557fd5ecc547f5eb597069788d6c00.tar.xz tangerine-wallet-browser-fcc9ca812e557fd5ecc547f5eb597069788d6c00.tar.zst tangerine-wallet-browser-fcc9ca812e557fd5ecc547f5eb597069788d6c00.zip |
Merge pull request #638 from MetaMask/i555-SaltVault
Add new eth-lightwallet salting to vault.
Diffstat (limited to 'test')
-rw-r--r-- | test/unit/idStore-test.js | 81 |
1 files changed, 71 insertions, 10 deletions
diff --git a/test/unit/idStore-test.js b/test/unit/idStore-test.js index ee4613236..1ed1bf9a7 100644 --- a/test/unit/idStore-test.js +++ b/test/unit/idStore-test.js @@ -1,6 +1,8 @@ var assert = require('assert') var IdentityStore = require('../../app/scripts/lib/idStore') var configManagerGen = require('../lib/mock-config-manager') +const ethUtil = require('ethereumjs-util') +const async = require('async') describe('IdentityStore', function() { @@ -18,11 +20,12 @@ describe('IdentityStore', function() { idStore = new IdentityStore({ configManager: configManagerGen(), ethStore: { - addAccount(acct) { accounts.push(acct) }, + addAccount(acct) { accounts.push(ethUtil.addHexPrefix(acct)) }, }, }) idStore.createNewVault(password, entropy, (err, seeds) => { + assert.ifError(err, 'createNewVault threw error') seedWords = seeds originalKeystore = idStore._idmgmt.keyStore done() @@ -38,7 +41,7 @@ describe('IdentityStore', function() { idStore = new IdentityStore({ configManager: configManagerGen(), ethStore: { - addAccount(acct) { newAccounts.push(acct) }, + addAccount(acct) { newAccounts.push(ethUtil.addHexPrefix(acct)) }, }, }) }) @@ -57,33 +60,91 @@ describe('IdentityStore', function() { }) describe('#recoverFromSeed BIP44 compliance', function() { - let seedWords = 'picnic injury awful upper eagle junk alert toss flower renew silly vague' - let firstAccount = '0x5d8de92c205279c10e5669f797b853ccef4f739a' + const salt = 'lightwalletSalt' let password = 'secret!' let accounts = [] let idStore + var assertions = [ + { + seed: 'picnic injury awful upper eagle junk alert toss flower renew silly vague', + account: '0x5d8de92c205279c10e5669f797b853ccef4f739a', + }, + { + seed: 'radar blur cabbage chef fix engine embark joy scheme fiction master release', + account: '0xe15d894becb0354c501ae69429b05143679f39e0', + }, + { + seed: 'phone coyote caught pattern found table wedding list tumble broccoli chief swing', + account: '0xb0e868f24bc7fec2bce2efc2b1c344d7569cd9d2', + }, + { + seed: 'recycle tag bird palace blue village anxiety census cook soldier example music', + account: '0xab34a45920afe4af212b96ec51232aaa6a33f663', + }, + { + seed: 'half glimpse tape cute harvest sweet bike voyage actual floor poet lazy', + account: '0x28e9044597b625ac4beda7250011670223de43b2', + }, + { + seed: 'flavor tiger carpet motor angry hungry document inquiry large critic usage liar', + account: '0xb571be96558940c4e9292e1999461aa7499fb6cd', + }, + ] + before(function() { window.localStorage = {} // Hacking localStorage support into JSDom idStore = new IdentityStore({ configManager: configManagerGen(), ethStore: { - addAccount(acct) { accounts.push(acct) }, + addAccount(acct) { accounts.push(ethUtil.addHexPrefix(acct)) }, }, }) }) - it('should return the expected first account', function (done) { + beforeEach(function() { + accounts = [] + }) - idStore.recoverFromSeed(password, seedWords, (err) => { - assert.ifError(err) + it('should enforce seed compliance with TestRPC', function (done) { + const tests = assertions.map((assertion) => { + return function (cb) { + accounts = [] + idStore.recoverFromSeed(password, assertion.seed, (err) => { + assert.ifError(err) + + var received = accounts[0].toLowerCase() + var expected = assertion.account.toLowerCase() + assert.equal(received, expected) + cb() + }) + } + }) - let newKeystore = idStore._idmgmt.keyStore - assert.equal(accounts[0], firstAccount) + async.series(tests, function(err, results) { + assert.ifError(err) done() }) }) + + it('should allow restoring and unlocking again', function (done) { + const assertion = assertions[0] + idStore.recoverFromSeed(password, assertion.seed, (err) => { + assert.ifError(err) + + var received = accounts[0].toLowerCase() + var expected = assertion.account.toLowerCase() + assert.equal(received, expected) + + + idStore.submitPassword(password, function(err, account) { + assert.ifError(err) + assert.equal(account, expected) + done() + }) + }) + }) }) }) |