aboutsummaryrefslogtreecommitdiffstats
path: root/test/unit/keyring-controller-test.js
diff options
context:
space:
mode:
authorDan Finlay <dan@danfinlay.com>2016-10-22 04:11:30 +0800
committerDan Finlay <dan@danfinlay.com>2016-10-22 04:11:30 +0800
commit626b52d24a3db05bf4f4e05df53f886615cc9538 (patch)
tree5a3ce6d5a08205a3f939292ebd3469f613ff7965 /test/unit/keyring-controller-test.js
parentee73e373a0736e1dd1304cedf662e9d575d178c7 (diff)
downloadtangerine-wallet-browser-626b52d24a3db05bf4f4e05df53f886615cc9538.tar
tangerine-wallet-browser-626b52d24a3db05bf4f4e05df53f886615cc9538.tar.gz
tangerine-wallet-browser-626b52d24a3db05bf4f4e05df53f886615cc9538.tar.bz2
tangerine-wallet-browser-626b52d24a3db05bf4f4e05df53f886615cc9538.tar.lz
tangerine-wallet-browser-626b52d24a3db05bf4f4e05df53f886615cc9538.tar.xz
tangerine-wallet-browser-626b52d24a3db05bf4f4e05df53f886615cc9538.tar.zst
tangerine-wallet-browser-626b52d24a3db05bf4f4e05df53f886615cc9538.zip
Fix bug in new KeyringController vault restoring logic.
Diffstat (limited to 'test/unit/keyring-controller-test.js')
-rw-r--r--test/unit/keyring-controller-test.js31
1 files changed, 31 insertions, 0 deletions
diff --git a/test/unit/keyring-controller-test.js b/test/unit/keyring-controller-test.js
index 738aa1a84..e216b0960 100644
--- a/test/unit/keyring-controller-test.js
+++ b/test/unit/keyring-controller-test.js
@@ -4,6 +4,8 @@ var configManagerGen = require('../lib/mock-config-manager')
const ethUtil = require('ethereumjs-util')
const async = require('async')
const mockEncryptor = require('../lib/mock-encryptor')
+const MockSimpleKeychain = require('../lib/mock-simple-keychain')
+const sinon = require('sinon')
describe('KeyringController', function() {
@@ -15,6 +17,7 @@ describe('KeyringController', function() {
let originalKeystore
beforeEach(function(done) {
+ this.sinon = sinon.sandbox.create()
window.localStorage = {} // Hacking localStorage support into JSDom
keyringController = new KeyringController({
@@ -33,8 +36,14 @@ describe('KeyringController', function() {
})
})
+ afterEach(function() {
+ // Cleanup mocks
+ this.sinon.restore()
+ })
+
describe('#createNewVault', function () {
it('should set a vault on the configManager', function(done) {
+ keyringController.configManager.setVault(null)
assert(!keyringController.configManager.getVault(), 'no previous vault')
keyringController.createNewVault(password, null, function (err, state) {
assert.ifError(err)
@@ -44,6 +53,28 @@ describe('KeyringController', function() {
})
})
})
+
+ describe('#restoreKeyring', function(done) {
+
+ it(`should pass a keyring's serialized data back to the correct type.`, function() {
+ keyringController.keyringTypes = [ MockSimpleKeychain ]
+
+ const mockSerialized = {
+ type: MockSimpleKeychain.type(),
+ data: [ '0x123456null788890abcdef' ],
+ }
+ const mock = this.sinon.mock(keyringController)
+
+ mock.expects('loadBalanceAndNickname')
+ .exactly(1)
+
+ var keyring = keyringController.restoreKeyring(0, mockSerialized)
+ assert.equal(keyring.wallets.length, 1, 'one wallet restored')
+ mock.verify()
+ })
+
+ })
+
})