diff options
author | brunobar79 <brunobar79@gmail.com> | 2018-07-17 07:36:08 +0800 |
---|---|---|
committer | brunobar79 <brunobar79@gmail.com> | 2018-07-17 07:36:08 +0800 |
commit | e5512c306ded1d2a521a0ba0d2c3cdd5878e53bb (patch) | |
tree | aad8b2e2fa6641f1e3a66b687aca22402d2507a8 /app/scripts | |
parent | 41879a983582c832fe3b6b19df3c057a1cc13d2a (diff) | |
download | tangerine-wallet-browser-e5512c306ded1d2a521a0ba0d2c3cdd5878e53bb.tar tangerine-wallet-browser-e5512c306ded1d2a521a0ba0d2c3cdd5878e53bb.tar.gz tangerine-wallet-browser-e5512c306ded1d2a521a0ba0d2c3cdd5878e53bb.tar.bz2 tangerine-wallet-browser-e5512c306ded1d2a521a0ba0d2c3cdd5878e53bb.tar.lz tangerine-wallet-browser-e5512c306ded1d2a521a0ba0d2c3cdd5878e53bb.tar.xz tangerine-wallet-browser-e5512c306ded1d2a521a0ba0d2c3cdd5878e53bb.tar.zst tangerine-wallet-browser-e5512c306ded1d2a521a0ba0d2c3cdd5878e53bb.zip |
added unit tests for metamaskcontroller
Diffstat (limited to 'app/scripts')
-rw-r--r-- | app/scripts/metamask-controller.js | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index b8b7c38e4..2f114e9f0 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -561,10 +561,15 @@ module.exports = class MetamaskController extends EventEmitter { return accounts default: - throw new Error('MetamaskController - Unknown device') + throw new Error('MetamaskController:connectHardware - Unknown device') } } + /** + * Check if the device is unlocked + * + * @returns {Promise<boolean>} + */ async checkHardwareStatus (deviceName) { switch (deviceName) { @@ -574,12 +579,19 @@ module.exports = class MetamaskController extends EventEmitter { 'Trezor Hardware' )[0] if (!keyring) { - return false + throw new Error('MetamaskController:checkHardwareStatus - Trezor Hardware keyring not found') } return keyring.isUnlocked() + default: + throw new Error('MetamaskController:checkHardwareStatus - Unknown device') } } + /** + * Clear + * + * @returns {Promise<boolean>} + */ async forgetDevice (deviceName) { switch (deviceName) { @@ -589,10 +601,12 @@ module.exports = class MetamaskController extends EventEmitter { 'Trezor Hardware' )[0] if (!keyring) { - return false + throw new Error('MetamaskController:forgetDevice - Trezor Hardware keyring not found') } keyring.forgetDevice() return true + default: + throw new Error('MetamaskController:forgetDevice - Unknown device') } } |