aboutsummaryrefslogtreecommitdiffstats
path: root/test/integration/lib
diff options
context:
space:
mode:
authorDan Finlay <dan@danfinlay.com>2016-12-09 06:22:02 +0800
committerDan Finlay <dan@danfinlay.com>2016-12-09 06:22:02 +0800
commitab9e15b782620002c0a2477829db3e56a25a7d5c (patch)
treef35f27db6ecd1dc04649a4d9c13625580e4b98e5 /test/integration/lib
parent9e3fa3cfba20299413df87d18158180c7798d2ac (diff)
downloadtangerine-wallet-browser-ab9e15b782620002c0a2477829db3e56a25a7d5c.tar
tangerine-wallet-browser-ab9e15b782620002c0a2477829db3e56a25a7d5c.tar.gz
tangerine-wallet-browser-ab9e15b782620002c0a2477829db3e56a25a7d5c.tar.bz2
tangerine-wallet-browser-ab9e15b782620002c0a2477829db3e56a25a7d5c.tar.lz
tangerine-wallet-browser-ab9e15b782620002c0a2477829db3e56a25a7d5c.tar.xz
tangerine-wallet-browser-ab9e15b782620002c0a2477829db3e56a25a7d5c.tar.zst
tangerine-wallet-browser-ab9e15b782620002c0a2477829db3e56a25a7d5c.zip
Mostly added bad account detection
Currently riddled with logs, because the migrator is inexplicably returning before generating the new style accounts for comparison.
Diffstat (limited to 'test/integration/lib')
-rw-r--r--test/integration/lib/keyring-controller-test.js58
1 files changed, 58 insertions, 0 deletions
diff --git a/test/integration/lib/keyring-controller-test.js b/test/integration/lib/keyring-controller-test.js
index ae5ecc578..e37b5df50 100644
--- a/test/integration/lib/keyring-controller-test.js
+++ b/test/integration/lib/keyring-controller-test.js
@@ -2,6 +2,7 @@ var KeyringController = require('../../../app/scripts/keyring-controller')
var ConfigManager = require('../../../app/scripts/lib/config-manager')
var oldStyleVault = require('../mocks/oldVault.json')
+var badStyleVault = require('../mocks/badVault.json')
var STORAGE_KEY = 'metamask-config'
var PASSWORD = '12345678'
@@ -41,6 +42,63 @@ QUnit.test('keyringController:submitPassword', function (assert) {
this.keyringController.submitPassword(PASSWORD)
.then((state) => {
assert.ok(state.identities[FIRST_ADDRESS])
+ assert.equal(state.lostAccounts.length, 0, 'no lost accounts')
+ done()
+ })
+})
+
+QUnit.test('keyringController:setLocked', function (assert) {
+ var done = assert.async()
+ var self = this
+
+ this.keyringController.setLocked()
+ .then(function() {
+ assert.notOk(self.keyringController.password, 'password should be deallocated')
+ assert.deepEqual(self.keyringController.keyrings, [], 'keyrings should be deallocated')
+ done()
+ })
+ .catch((reason) => {
+ assert.ifError(reason)
+ done()
+ })
+})
+
+QUnit.module('Old Style Vaults with bad HD seed', {
+ beforeEach: function () {
+ window.localStorage[STORAGE_KEY] = JSON.stringify(badStyleVault)
+
+ this.configManager = new ConfigManager({
+ loadData: () => { return JSON.parse(window.localStorage[STORAGE_KEY]) },
+ setData: (data) => { window.localStorage[STORAGE_KEY] = JSON.stringify(data) },
+ })
+
+ this.keyringController = new KeyringController({
+ configManager: this.configManager,
+ getNetwork: () => { return '2' },
+ })
+
+ this.ethStore = {
+ addAccount: () => {},
+ removeAccount: () => {},
+ }
+
+ this.keyringController.setStore(this.ethStore)
+ }
+})
+
+QUnit.test('keyringController:isInitialized', function (assert) {
+ assert.ok(this.keyringController.getState().isInitialized)
+})
+
+QUnit.test('keyringController:submitPassword', function (assert) {
+ var done = assert.async()
+
+ this.keyringController.submitPassword(PASSWORD)
+ .then((state) => {
+ assert.ok(state.identities[FIRST_ADDRESS])
+ assert.equal(state.lostAccounts.length, 1, 'one lost account')
+ assert.equal(state.lostAccounts[0], 'e15D894BeCB0354c501AE69429B05143679F39e0'.toLowerCase())
+ assert.deepEqual(this.configManager.getLostAccounts(), state.lostAccounts, 'persisted')
done()
})
})