aboutsummaryrefslogtreecommitdiffstats
path: root/test/unit/app/controllers
diff options
context:
space:
mode:
authorDan Finlay <542863+danfinlay@users.noreply.github.com>2018-08-18 02:26:38 +0800
committerGitHub <noreply@github.com>2018-08-18 02:26:38 +0800
commitc7f5436143a87369ab29c019a1c988c20a98d810 (patch)
treea92c329bc53f99f88fdd0a72e522dc94f4dfb83e /test/unit/app/controllers
parent755369e4e48e71b04b4dbb9cb702353c09b66e28 (diff)
parentbd904c86f6f27eb50e0633f46af6831869b99893 (diff)
downloadtangerine-wallet-browser-c7f5436143a87369ab29c019a1c988c20a98d810.tar.gz
tangerine-wallet-browser-c7f5436143a87369ab29c019a1c988c20a98d810.tar.zst
tangerine-wallet-browser-c7f5436143a87369ab29c019a1c988c20a98d810.zip
Merge pull request #5050 from MetaMask/ledger-support
Add Ledger hardware wallet support
Diffstat (limited to 'test/unit/app/controllers')
-rw-r--r--test/unit/app/controllers/metamask-controller-test.js36
1 files changed, 25 insertions, 11 deletions
diff --git a/test/unit/app/controllers/metamask-controller-test.js b/test/unit/app/controllers/metamask-controller-test.js
index e51cd66aa..1fc604c9c 100644
--- a/test/unit/app/controllers/metamask-controller-test.js
+++ b/test/unit/app/controllers/metamask-controller-test.js
@@ -286,9 +286,9 @@ describe('MetaMaskController', function () {
it('should throw if it receives an unknown device name', async function () {
try {
- await metamaskController.connectHardware('Some random device name', 0)
+ await metamaskController.connectHardware('Some random device name', 0, `m/44/0'/0'`)
} catch (e) {
- assert.equal(e, 'Error: MetamaskController:connectHardware - Unknown device')
+ assert.equal(e, 'Error: MetamaskController:getKeyringForDevice - Unknown device')
}
})
@@ -302,14 +302,24 @@ describe('MetaMaskController', function () {
assert.equal(keyrings.length, 1)
})
+ it('should add the Ledger Hardware keyring', async function () {
+ sinon.spy(metamaskController.keyringController, 'addNewKeyring')
+ await metamaskController.connectHardware('ledger', 0).catch((e) => null)
+ const keyrings = await metamaskController.keyringController.getKeyringsByType(
+ 'Ledger Hardware'
+ )
+ assert.equal(metamaskController.keyringController.addNewKeyring.getCall(0).args, 'Ledger Hardware')
+ assert.equal(keyrings.length, 1)
+ })
+
})
describe('checkHardwareStatus', function () {
it('should throw if it receives an unknown device name', async function () {
try {
- await metamaskController.checkHardwareStatus('Some random device name')
+ await metamaskController.checkHardwareStatus('Some random device name', `m/44/0'/0'`)
} catch (e) {
- assert.equal(e, 'Error: MetamaskController:checkHardwareStatus - Unknown device')
+ assert.equal(e, 'Error: MetamaskController:getKeyringForDevice - Unknown device')
}
})
@@ -325,7 +335,7 @@ describe('MetaMaskController', function () {
try {
await metamaskController.forgetDevice('Some random device name')
} catch (e) {
- assert.equal(e, 'Error: MetamaskController:forgetDevice - Unknown device')
+ assert.equal(e, 'Error: MetamaskController:getKeyringForDevice - Unknown device')
}
})
@@ -342,7 +352,7 @@ describe('MetaMaskController', function () {
})
})
- describe('unlockTrezorAccount', function () {
+ describe('unlockHardwareWalletAccount', function () {
let accountToUnlock
let windowOpenStub
let addNewAccountStub
@@ -365,16 +375,20 @@ describe('MetaMaskController', function () {
sinon.spy(metamaskController.preferencesController, 'setAddresses')
sinon.spy(metamaskController.preferencesController, 'setSelectedAddress')
sinon.spy(metamaskController.preferencesController, 'setAccountLabel')
- await metamaskController.connectHardware('trezor', 0).catch((e) => null)
- await metamaskController.unlockTrezorAccount(accountToUnlock).catch((e) => null)
+ await metamaskController.connectHardware('trezor', 0, `m/44/0'/0'`).catch((e) => null)
+ await metamaskController.unlockHardwareWalletAccount(accountToUnlock, 'trezor', `m/44/0'/0'`)
})
afterEach(function () {
- metamaskController.keyringController.addNewAccount.restore()
window.open.restore()
+ metamaskController.keyringController.addNewAccount.restore()
+ metamaskController.keyringController.getAccounts.restore()
+ metamaskController.preferencesController.setAddresses.restore()
+ metamaskController.preferencesController.setSelectedAddress.restore()
+ metamaskController.preferencesController.setAccountLabel.restore()
})
- it('should set accountToUnlock in the keyring', async function () {
+ it('should set unlockedAccount in the keyring', async function () {
const keyrings = await metamaskController.keyringController.getKeyringsByType(
'Trezor Hardware'
)
@@ -382,7 +396,7 @@ describe('MetaMaskController', function () {
})
- it('should call keyringController.addNewAccount', async function () {
+ it('should call keyringController.addNewAccount', async function () {
assert(metamaskController.keyringController.addNewAccount.calledOnce)
})