mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-10-22 19:26:13 +02:00
Ensure the extension can be unlocked without network access (#9295)
move checkForLatestBlock to separate catch block add test case remove duplicate checkForLatestBlock call
This commit is contained in:
parent
707c7193e0
commit
f02ba2d561
@ -766,7 +766,11 @@ export default class MetamaskController extends EventEmitter {
|
|||||||
async submitPassword (password) {
|
async submitPassword (password) {
|
||||||
await this.keyringController.submitPassword(password)
|
await this.keyringController.submitPassword(password)
|
||||||
|
|
||||||
await this.blockTracker.checkForLatestBlock()
|
try {
|
||||||
|
await this.blockTracker.checkForLatestBlock()
|
||||||
|
} catch (error) {
|
||||||
|
log.error('Error while unlocking extension.', error)
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const threeBoxSyncingAllowed = this.threeBoxController.getThreeBoxSyncingState()
|
const threeBoxSyncingAllowed = this.threeBoxController.getThreeBoxSyncingState()
|
||||||
@ -778,7 +782,7 @@ export default class MetamaskController extends EventEmitter {
|
|||||||
this.threeBoxController.turnThreeBoxSyncingOn()
|
this.threeBoxController.turnThreeBoxSyncingOn()
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
log.error(error)
|
log.error('Error while unlocking extension.', error)
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.keyringController.fullUpdate()
|
return this.keyringController.fullUpdate()
|
||||||
|
@ -196,6 +196,17 @@ describe('MetaMaskController', function () {
|
|||||||
assert(threeBoxSpies.init.calledOnce)
|
assert(threeBoxSpies.init.calledOnce)
|
||||||
assert(threeBoxSpies.turnThreeBoxSyncingOn.calledOnce)
|
assert(threeBoxSpies.turnThreeBoxSyncingOn.calledOnce)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('succeeds even if blockTracker or threeBoxController throw', async function () {
|
||||||
|
const throwErr = sinon.fake.throws('foo')
|
||||||
|
metamaskController.blockTracker.checkForLatestBlock = throwErr
|
||||||
|
metamaskController.threeBoxController.getThreeBoxSyncingState = throwErr
|
||||||
|
await metamaskController.submitPassword(password)
|
||||||
|
assert.ok(
|
||||||
|
throwErr.calledTwice,
|
||||||
|
'should have called checkForLatestBlock and getThreeBoxSyncingState',
|
||||||
|
)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('#createNewVaultAndKeychain', function () {
|
describe('#createNewVaultAndKeychain', function () {
|
||||||
|
Loading…
Reference in New Issue
Block a user