1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-10-22 11:22:43 +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:
Erik Marks 2020-09-08 22:29:24 -07:00 committed by GitHub
parent 707c7193e0
commit f02ba2d561
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 2 deletions

View File

@ -766,7 +766,11 @@ export default class MetamaskController extends EventEmitter {
async 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 {
const threeBoxSyncingAllowed = this.threeBoxController.getThreeBoxSyncingState()
@ -778,7 +782,7 @@ export default class MetamaskController extends EventEmitter {
this.threeBoxController.turnThreeBoxSyncingOn()
}
} catch (error) {
log.error(error)
log.error('Error while unlocking extension.', error)
}
return this.keyringController.fullUpdate()

View File

@ -196,6 +196,17 @@ describe('MetaMaskController', function () {
assert(threeBoxSpies.init.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 () {