Fixed caching bug

Fixed bug where the second new vault created in an IdStore would initially return the accounts from the original store.

Also fixed some tests that were incorrect.
feature/default_network_editable
Dan Finlay 8 years ago
parent 5e60b2f0c4
commit 9b861b6687
  1. 7
      app/scripts/lib/idStore.js
  2. 11
      test/unit/idStore-test.js

@ -75,7 +75,6 @@ IdentityStore.prototype.recoverFromSeed = function (password, seed, cb) {
if (err) return cb(err) if (err) return cb(err)
this._loadIdentities() this._loadIdentities()
this._didUpdate()
cb(null, this.getState()) cb(null, this.getState())
}) })
} }
@ -394,7 +393,6 @@ IdentityStore.prototype._loadIdentities = function () {
var addresses = this._getAddresses() var addresses = this._getAddresses()
addresses.forEach((address, i) => { addresses.forEach((address, i) => {
// // add to ethStore // // add to ethStore
this._ethStore.addAccount(address)
// add to identities // add to identities
const defaultLabel = 'Wallet ' + (i + 1) const defaultLabel = 'Wallet ' + (i + 1)
const nickname = configManager.nicknameForWallet(address) const nickname = configManager.nicknameForWallet(address)
@ -413,7 +411,6 @@ IdentityStore.prototype.saveAccountLabel = function (account, label, cb) {
configManager.setNicknameForWallet(account, label) configManager.setNicknameForWallet(account, label)
this._loadIdentities() this._loadIdentities()
cb(null, label) cb(null, label)
this._didUpdate()
} }
// mayBeFauceting // mayBeFauceting
@ -481,8 +478,6 @@ IdentityStore.prototype._createIdmgmt = function (password, seedPhrase, entropy,
}) })
cb() cb()
this._loadIdentities()
this._didUpdate()
}) })
}) })
} }
@ -497,9 +492,9 @@ IdentityStore.prototype._createFirstWallet = function (derivedKey) {
const keyStore = this._keyStore const keyStore = this._keyStore
keyStore.setDefaultHdDerivationPath(this.hdPathString) keyStore.setDefaultHdDerivationPath(this.hdPathString)
keyStore.generateNewAddress(derivedKey, 1) keyStore.generateNewAddress(derivedKey, 1)
this.configManager.setWallet(keyStore.serialize())
var addresses = keyStore.getAddresses() var addresses = keyStore.getAddresses()
this._ethStore.addAccount(addresses[0]) this._ethStore.addAccount(addresses[0])
this.configManager.setWallet(keyStore.serialize())
} }
// get addresses and normalize address hexString // get addresses and normalize address hexString

@ -73,7 +73,7 @@ describe('IdentityStore', function() {
}, },
{ {
seed: 'radar blur cabbage chef fix engine embark joy scheme fiction master release', seed: 'radar blur cabbage chef fix engine embark joy scheme fiction master release',
account: '0xe15D894BeCB0354c501AE69429B05143679F39e0', account: '0xe15d894becb0354c501ae69429b05143679f39e0',
}, },
{ {
seed: 'phone coyote caught pattern found table wedding list tumble broccoli chief swing', seed: 'phone coyote caught pattern found table wedding list tumble broccoli chief swing',
@ -91,10 +91,6 @@ describe('IdentityStore', function() {
seed: 'flavor tiger carpet motor angry hungry document inquiry large critic usage liar', seed: 'flavor tiger carpet motor angry hungry document inquiry large critic usage liar',
account: '0xb571be96558940c4e9292e1999461aa7499fb6cd', account: '0xb571be96558940c4e9292e1999461aa7499fb6cd',
}, },
{
seed: 'this is a twelve word phrase seven eight nine ten eleven twelve',
account: '0x814e8ec0c3647e140b8e09228fc374b2a867fe48',
},
] ]
before(function() { before(function() {
@ -115,10 +111,13 @@ describe('IdentityStore', function() {
it('should enforce seed compliance with TestRPC', function (done) { it('should enforce seed compliance with TestRPC', function (done) {
const tests = assertions.map((assertion) => { const tests = assertions.map((assertion) => {
return function (cb) { return function (cb) {
accounts = []
idStore.recoverFromSeed(password, assertion.seed, (err) => { idStore.recoverFromSeed(password, assertion.seed, (err) => {
assert.ifError(err) assert.ifError(err)
assert.equal(accounts[0], assertion.account) var received = accounts[0].toLowerCase()
var expected = assertion.account.toLowerCase()
assert.equal(received, expected)
cb() cb()
}) })
} }

Loading…
Cancel
Save