aboutsummaryrefslogtreecommitdiffstats
path: root/test/unit
diff options
context:
space:
mode:
authorPaul Bouchon <mail@bitpshr.net>2018-04-30 11:18:34 +0800
committerGitHub <noreply@github.com>2018-04-30 11:18:34 +0800
commitdaaaab3ab06688cc7b3d349ce436c59909f54f5c (patch)
treec35780fcba1428516d1c687f3455a9b20e8235d0 /test/unit
parent141884ee6ad55da98f5a0752b76e55238ddc5c5d (diff)
downloadtangerine-wallet-browser-daaaab3ab06688cc7b3d349ce436c59909f54f5c.tar
tangerine-wallet-browser-daaaab3ab06688cc7b3d349ce436c59909f54f5c.tar.gz
tangerine-wallet-browser-daaaab3ab06688cc7b3d349ce436c59909f54f5c.tar.bz2
tangerine-wallet-browser-daaaab3ab06688cc7b3d349ce436c59909f54f5c.tar.lz
tangerine-wallet-browser-daaaab3ab06688cc7b3d349ce436c59909f54f5c.tar.xz
tangerine-wallet-browser-daaaab3ab06688cc7b3d349ce436c59909f54f5c.tar.zst
tangerine-wallet-browser-daaaab3ab06688cc7b3d349ce436c59909f54f5c.zip
Verify identities state after restoring new accounts (#4091)
Diffstat (limited to 'test/unit')
-rw-r--r--test/unit/metamask-controller-test.js33
1 files changed, 25 insertions, 8 deletions
diff --git a/test/unit/metamask-controller-test.js b/test/unit/metamask-controller-test.js
index adeca9b5f..18c3f9ab9 100644
--- a/test/unit/metamask-controller-test.js
+++ b/test/unit/metamask-controller-test.js
@@ -6,6 +6,12 @@ const MetaMaskController = require('../../app/scripts/metamask-controller')
const blacklistJSON = require('../stub/blacklist')
const firstTimeState = require('../../app/scripts/first-time-state')
+const DEFAULT_LABEL = 'Account 1'
+const TEST_SEED = 'debris dizzy just program just float decrease vacant alarm reduce speak stadium'
+const TEST_ADDRESS = '0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc'
+const TEST_SEED_ALT = 'setup olympic issue mobile velvet surge alcohol burger horse view reopen gentle'
+const TEST_ADDRESS_ALT = '0xc42edfcc21ed14dda456aa0756c153f7985d8813'
+
describe('MetaMaskController', function () {
let metamaskController
const sandbox = sinon.sandbox.create()
@@ -87,17 +93,28 @@ describe('MetaMaskController', function () {
describe('#createNewVaultAndRestore', function () {
it('should be able to call newVaultAndRestore despite a mistake.', async function () {
-
const password = 'what-what-what'
- const wrongSeed = 'debris dizzy just program just float decrease vacant alarm reduce speak stadiu'
- const rightSeed = 'debris dizzy just program just float decrease vacant alarm reduce speak stadium'
- await metamaskController.createNewVaultAndRestore(password, wrongSeed)
- .catch((e) => {
- return
- })
- await metamaskController.createNewVaultAndRestore(password, rightSeed)
+ await metamaskController.createNewVaultAndRestore(password, TEST_SEED.slice(0, -1)).catch((e) => null)
+ await metamaskController.createNewVaultAndRestore(password, TEST_SEED)
assert(metamaskController.keyringController.createNewVaultAndRestore.calledTwice)
})
+
+ it('should clear previous identities after vault restoration', async () => {
+ await metamaskController.createNewVaultAndRestore('foobar1337', TEST_SEED)
+ assert.deepEqual(metamaskController.getState().identities, {
+ [TEST_ADDRESS]: { address: TEST_ADDRESS, name: DEFAULT_LABEL },
+ })
+
+ await metamaskController.keyringController.saveAccountLabel(TEST_ADDRESS, 'Account Foo')
+ assert.deepEqual(metamaskController.getState().identities, {
+ [TEST_ADDRESS]: { address: TEST_ADDRESS, name: 'Account Foo' },
+ })
+
+ await metamaskController.createNewVaultAndRestore('foobar1337', TEST_SEED_ALT)
+ assert.deepEqual(metamaskController.getState().identities, {
+ [TEST_ADDRESS_ALT]: { address: TEST_ADDRESS_ALT, name: DEFAULT_LABEL },
+ })
+ })
})
})