From 59fd86383fbf379724c3bcca6da9d5a6192bbcf2 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Sat, 10 Sep 2016 12:08:27 -0700 Subject: Correctly clear ethStore cache on new vault restore --- test/unit/idStore-test.js | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) (limited to 'test/unit/idStore-test.js') diff --git a/test/unit/idStore-test.js b/test/unit/idStore-test.js index 3d28ddf90..422db6f7b 100644 --- a/test/unit/idStore-test.js +++ b/test/unit/idStore-test.js @@ -1,6 +1,7 @@ var assert = require('assert') var IdentityStore = require('../../app/scripts/lib/idStore') var configManagerGen = require('../lib/mock-config-manager') +const ethUtil = require('ethereumjs-util') describe('IdentityStore', function() { @@ -18,7 +19,7 @@ describe('IdentityStore', function() { idStore = new IdentityStore({ configManager: configManagerGen(), ethStore: { - addAccount(acct) { accounts.push(acct) }, + addAccount(acct) { accounts.push(ethUtil.addHexPrefix(acct)) }, }, }) @@ -39,7 +40,7 @@ describe('IdentityStore', function() { idStore = new IdentityStore({ configManager: configManagerGen(), ethStore: { - addAccount(acct) { newAccounts.push(acct) }, + addAccount(acct) { newAccounts.push(ethUtil.addHexPrefix(acct)) }, }, }) }) @@ -62,6 +63,9 @@ describe('IdentityStore', function() { let firstAccount = '0x5d8de92c205279c10e5669f797b853ccef4f739a' const salt = 'lightwalletSalt' + const secondSeed = 'radar blur cabbage chef fix engine embark joy scheme fiction master release' + const secondAcct = '0xac39b311dceb2a4b2f5d8461c1cdaf756f4f7ae9' + let password = 'secret!' let accounts = [] let idStore @@ -72,11 +76,15 @@ describe('IdentityStore', function() { idStore = new IdentityStore({ configManager: configManagerGen(), ethStore: { - addAccount(acct) { accounts.push('0x' + acct) }, + addAccount(acct) { accounts.push(ethUtil.addHexPrefix(acct)) }, }, }) }) + beforeEach(function() { + accounts = [] + }) + it('should return the expected first account', function (done) { idStore.recoverFromSeed(password, seedWords, (err) => { @@ -87,9 +95,6 @@ describe('IdentityStore', function() { assert.equal(accounts[0], firstAccount) accounts = [] - const secondSeed = 'radar blur cabbage chef fix engine embark joy scheme fiction master release' - const secondAcct = '0xac39b311dceb2a4b2f5d8461c1cdaf756f4f7ae9' - idStore.recoverFromSeed(password, secondSeed, (err) => { let accounts = idStore._getAddresses() @@ -98,5 +103,16 @@ describe('IdentityStore', function() { }) }) }) + + it('should return the expected second account', function (done) { + idStore.recoverFromSeed(password, secondSeed, (err) => { + assert.ifError(err) + + let newKeystore = idStore._idmgmt.keyStore + + assert.equal(accounts[0], firstAccount) + done() + }) + }) }) }) -- cgit