aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorDan Finlay <542863+danfinlay@users.noreply.github.com>2018-08-21 01:23:15 +0800
committerGitHub <noreply@github.com>2018-08-21 01:23:15 +0800
commit097c1e90e3f369817a8121ee5ccac835dc2aa4c8 (patch)
tree34383946dde60ebf026a5bf2609f9629c24c9ef3 /test
parentd636cc35523f52f630162a1b342b5267b6cd246e (diff)
parent51e4a6d3355524cd8622d6d2893cc878a64dc53e (diff)
downloadtangerine-wallet-browser-097c1e90e3f369817a8121ee5ccac835dc2aa4c8.tar
tangerine-wallet-browser-097c1e90e3f369817a8121ee5ccac835dc2aa4c8.tar.gz
tangerine-wallet-browser-097c1e90e3f369817a8121ee5ccac835dc2aa4c8.tar.bz2
tangerine-wallet-browser-097c1e90e3f369817a8121ee5ccac835dc2aa4c8.tar.lz
tangerine-wallet-browser-097c1e90e3f369817a8121ee5ccac835dc2aa4c8.tar.xz
tangerine-wallet-browser-097c1e90e3f369817a8121ee5ccac835dc2aa4c8.tar.zst
tangerine-wallet-browser-097c1e90e3f369817a8121ee5ccac835dc2aa4c8.zip
Merge pull request #5084 from MetaMask/ledger-support-without-provider
Ledger support (in case of rollback)
Diffstat (limited to 'test')
-rw-r--r--test/e2e/beta/from-import-beta-ui.spec.js5
-rw-r--r--test/unit/app/controllers/metamask-controller-test.js36
2 files changed, 29 insertions, 12 deletions
diff --git a/test/e2e/beta/from-import-beta-ui.spec.js b/test/e2e/beta/from-import-beta-ui.spec.js
index e14ee2361..1261b6f95 100644
--- a/test/e2e/beta/from-import-beta-ui.spec.js
+++ b/test/e2e/beta/from-import-beta-ui.spec.js
@@ -366,7 +366,10 @@ describe('Using MetaMask with an existing account', function () {
})
it('should open the TREZOR Connect popup', async () => {
- const connectButtons = await findElements(driver, By.xpath(`//button[contains(text(), 'Connect to Trezor')]`))
+ const trezorButton = await findElements(driver, By.css('.hw-connect__btn'))
+ await trezorButton[1].click()
+ await delay(regularDelayMs)
+ const connectButtons = await findElements(driver, By.xpath(`//button[contains(text(), 'Connect')]`))
await connectButtons[0].click()
await delay(regularDelayMs)
const allWindows = await driver.getAllWindowHandles()
diff --git a/test/unit/app/controllers/metamask-controller-test.js b/test/unit/app/controllers/metamask-controller-test.js
index 9164fe246..9f25cf376 100644
--- a/test/unit/app/controllers/metamask-controller-test.js
+++ b/test/unit/app/controllers/metamask-controller-test.js
@@ -226,9 +226,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')
}
})
@@ -242,14 +242,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')
}
})
@@ -265,7 +275,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')
}
})
@@ -282,7 +292,7 @@ describe('MetaMaskController', function () {
})
})
- describe('unlockTrezorAccount', function () {
+ describe('unlockHardwareWalletAccount', function () {
let accountToUnlock
let windowOpenStub
let addNewAccountStub
@@ -305,16 +315,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'
)
@@ -322,7 +336,7 @@ describe('MetaMaskController', function () {
})
- it('should call keyringController.addNewAccount', async function () {
+ it('should call keyringController.addNewAccount', async function () {
assert(metamaskController.keyringController.addNewAccount.calledOnce)
})