mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Fix more keyring asyncifying tests
This commit is contained in:
parent
600f5c31db
commit
230a0ab876
@ -281,7 +281,7 @@ module.exports = class KeyringController extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
persistAllKeyrings () {
|
persistAllKeyrings () {
|
||||||
Promise.all(this.keyrings.map((keyring) => {
|
return Promise.all(this.keyrings.map((keyring) => {
|
||||||
return Promise.all([keyring.type, keyring.serialize()])
|
return Promise.all([keyring.type, keyring.serialize()])
|
||||||
.then((serializedKeyringArray) => {
|
.then((serializedKeyringArray) => {
|
||||||
// Label the output values on each serialized Keyring:
|
// Label the output values on each serialized Keyring:
|
||||||
@ -314,13 +314,14 @@ module.exports = class KeyringController extends EventEmitter {
|
|||||||
const { type, data } = serialized
|
const { type, data } = serialized
|
||||||
const Keyring = this.getKeyringClassForType(type)
|
const Keyring = this.getKeyringClassForType(type)
|
||||||
const keyring = new Keyring()
|
const keyring = new Keyring()
|
||||||
keyring.deserialize(data)
|
return keyring.deserialize(data)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
return keyring.getAccounts()
|
return keyring.getAccounts()
|
||||||
})
|
})
|
||||||
.then((accounts) => {
|
.then((accounts) => {
|
||||||
this.setupAccounts(accounts)
|
this.setupAccounts(accounts)
|
||||||
this.keyrings.push(keyring)
|
this.keyrings.push(keyring)
|
||||||
|
return keyring
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,10 +77,17 @@ describe('KeyringController', function() {
|
|||||||
keyringController.restoreKeyring(mockSerialized)
|
keyringController.restoreKeyring(mockSerialized)
|
||||||
.then((keyring) => {
|
.then((keyring) => {
|
||||||
assert.equal(keyring.wallets.length, 1, 'one wallet restored')
|
assert.equal(keyring.wallets.length, 1, 'one wallet restored')
|
||||||
assert.equal(keyring.getAccounts()[0], addresses[0])
|
return keyring.getAccounts()
|
||||||
|
})
|
||||||
|
.then((accounts) => {
|
||||||
|
assert.equal(accounts[0], addresses[0])
|
||||||
mock.verify()
|
mock.verify()
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
|
.catch((reason) => {
|
||||||
|
assert.ifError(reason)
|
||||||
|
done()
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user