aboutsummaryrefslogtreecommitdiffstats
path: root/test/integration
diff options
context:
space:
mode:
authorDan Finlay <somniac@me.com>2016-12-21 03:50:26 +0800
committerGitHub <noreply@github.com>2016-12-21 03:50:26 +0800
commit674b2689826c770092a3dfee7fe76fb83c0b444a (patch)
tree96dd32380a338c361131aae49a8f664308a591f0 /test/integration
parent4fbea1c7b4e3ca13b76aa49c7a349a3dc2366910 (diff)
parent20d2204ce6a9e8dcd3269c588b2f4ce6ff93408b (diff)
downloadtangerine-wallet-browser-674b2689826c770092a3dfee7fe76fb83c0b444a.tar
tangerine-wallet-browser-674b2689826c770092a3dfee7fe76fb83c0b444a.tar.gz
tangerine-wallet-browser-674b2689826c770092a3dfee7fe76fb83c0b444a.tar.bz2
tangerine-wallet-browser-674b2689826c770092a3dfee7fe76fb83c0b444a.tar.lz
tangerine-wallet-browser-674b2689826c770092a3dfee7fe76fb83c0b444a.tar.xz
tangerine-wallet-browser-674b2689826c770092a3dfee7fe76fb83c0b444a.tar.zst
tangerine-wallet-browser-674b2689826c770092a3dfee7fe76fb83c0b444a.zip
Merge pull request #916 from MetaMask/i894-DetectBadAccounts
I894 detect bad accounts
Diffstat (limited to 'test/integration')
-rw-r--r--test/integration/lib/keyring-controller-test.js60
-rw-r--r--test/integration/mocks/badVault.json1
2 files changed, 61 insertions, 0 deletions
diff --git a/test/integration/lib/keyring-controller-test.js b/test/integration/lib/keyring-controller-test.js
index ae5ecc578..666795a6d 100644
--- a/test/integration/lib/keyring-controller-test.js
+++ b/test/integration/lib/keyring-controller-test.js
@@ -2,11 +2,14 @@ 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'
var FIRST_ADDRESS = '0x4dd5d356c5A016A220bCD69e82e5AF680a430d00'.toLowerCase()
+var BAD_STYLE_FIRST_ADDRESS = '0xac39b311dceb2a4b2f5d8461c1cdaf756f4f7ae9'
+
QUnit.module('Old Style Vaults', {
beforeEach: function () {
@@ -41,6 +44,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, 'vault is initialized')
+})
+
+QUnit.test('keyringController:submitPassword', function (assert) {
+ var done = assert.async()
+
+ this.keyringController.submitPassword(PASSWORD)
+ .then((state) => {
+ assert.ok(state.identities[BAD_STYLE_FIRST_ADDRESS])
+ assert.equal(state.lostAccounts.length, 1, 'one lost account')
+ assert.equal(state.lostAccounts[0], '0xe15D894BeCB0354c501AE69429B05143679F39e0'.toLowerCase())
+ assert.deepEqual(this.configManager.getLostAccounts(), state.lostAccounts, 'persisted')
done()
})
})
diff --git a/test/integration/mocks/badVault.json b/test/integration/mocks/badVault.json
new file mode 100644
index 000000000..a59e4626a
--- /dev/null
+++ b/test/integration/mocks/badVault.json
@@ -0,0 +1 @@
+{"meta":{"version":4},"data":{"fiatCurrency":"USD","conversionRate":8.34908448,"conversionDate":1481227505,"isConfirmed":true,"wallet":"{\"encSeed\":{\"encStr\":\"Te2KyAGY3S01bgUJ+7d4y3BOvr/8TKrXrkRZ29cGI6dgyedtN+YgTQxElC2td/pzuoXm7KeSfr+yAoFCvMgqFAJwRcX3arHOsMFQie8kp8mL5I65zwdg/HB2QecB4OJHytrxgApv2zZiKEo0kbu2cs8zYIn5wNlCBIHwgylYmHpUDIJcO1B4zg==\",\"nonce\":\"xnxqk4iy70bjt721F+KPLV4PNfBFNyct\"},\"ksData\":{\"m/44'/60'/0'/0\":{\"info\":{\"curve\":\"secp256k1\",\"purpose\":\"sign\"},\"encHdPathPriv\":{\"encStr\":\"vNrSjekRKLmaGFf77Uca9+aAebmDlvrBwtAV8YthpQ4OX/mXtLSycmnLsYdk4schaByfJvrm6/Mf9fxzOSaScJk+XvKw5XqNXedkDHtbWrmNnxFpuT+9tuB8Nupr3D9GZK9PgXhJD99/7Bn6Wk7/ne+PIDmbtdmx/SWmrdo3pg==\",\"nonce\":\"zqWq/gtJ5zfUVRWQQJkP/zoYjer6Rozj\"},\"hdIndex\":1,\"encPrivKeys\":{\"e15d894becb0354c501ae69429b05143679f39e0\":{\"key\":\"jBLQ9v1l5LOEY1C3kI8z7LpbJKHP1vpVfPAlz90MNSfa8Oe+XlxKQAGYs8Zb4fWm\",\"nonce\":\"fJyrSRo1t0RMNqp2MsneoJnYJWHQnSVY\"}},\"addresses\":[\"e15d894becb0354c501ae69429b05143679f39e0\"]}},\"encHdRootPriv\":{\"encStr\":\"mbvwiFBQGbjj4BJLmdeYzfYi8jb7gtFtwiCQOPfvmyz4h2/KMbHNGzumM16qRKpifioQXkhnBulMIQHaYg0Jwv1MoFsqHxHmuIAT+QP5XvJjz0MRl6708pHowmIVG+R8CZNTLqzE7XS8YkZ4ElRpTvLEM8Wngi5Sg287mQMP9w==\",\"nonce\":\"i5Tp2lQe92rXQzNhjZcu9fNNhfux6Wf4\"},\"salt\":\"FQpA8D9R/5qSp9WtQ94FILyfWZHMI6YZw6RmBYqK0N0=\",\"version\":2}","config":{"provider":{"type":"testnet"},"selectedAccount":"0xe15d894becb0354c501ae69429b05143679f39e0"},"isEthConfirmed":true,"transactions":[],"TOSHash":"a4f4e23f823a7ac51783e7ffba7914a911b09acdb97263296b7e14b527f80c5b","gasMultiplier":1}}