aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorDan Finlay <dan@danfinlay.com>2016-11-04 02:34:57 +0800
committerDan Finlay <dan@danfinlay.com>2016-11-04 02:34:57 +0800
commit9ca3c57339571c43106306a6b4fadcfad40d3c19 (patch)
tree0ceb65d3107fdf56e24ba2e02dcb3a3e8f4d4985 /test
parentd8a9ae0f079a602ced40e424389eb05317cc276d (diff)
downloadtangerine-wallet-browser-9ca3c57339571c43106306a6b4fadcfad40d3c19.tar
tangerine-wallet-browser-9ca3c57339571c43106306a6b4fadcfad40d3c19.tar.gz
tangerine-wallet-browser-9ca3c57339571c43106306a6b4fadcfad40d3c19.tar.bz2
tangerine-wallet-browser-9ca3c57339571c43106306a6b4fadcfad40d3c19.tar.lz
tangerine-wallet-browser-9ca3c57339571c43106306a6b4fadcfad40d3c19.tar.xz
tangerine-wallet-browser-9ca3c57339571c43106306a6b4fadcfad40d3c19.tar.zst
tangerine-wallet-browser-9ca3c57339571c43106306a6b4fadcfad40d3c19.zip
Fix vault creation bug
Diffstat (limited to 'test')
-rw-r--r--test/unit/keyring-controller-test.js36
1 files changed, 28 insertions, 8 deletions
diff --git a/test/unit/keyring-controller-test.js b/test/unit/keyring-controller-test.js
index 16a4ae148..6656583e8 100644
--- a/test/unit/keyring-controller-test.js
+++ b/test/unit/keyring-controller-test.js
@@ -9,10 +9,11 @@ const sinon = require('sinon')
describe('KeyringController', function() {
- let keyringController
+ let keyringController, state
let password = 'password123'
let entropy = 'entripppppyy duuude'
- let seedWords
+ let seedWords = 'puzzle seed penalty soldier say clay field arctic metal hen cage runway'
+ let addresses = ['eF35cA8EbB9669A35c31b5F6f249A9941a812AC1'.toLowerCase()]
let accounts = []
let originalKeystore
@@ -31,7 +32,9 @@ describe('KeyringController', function() {
// Browser crypto is tested in the integration test suite.
keyringController.encryptor = mockEncryptor
- keyringController.createNewVaultAndKeychain(password, null, function (err, state) {
+ keyringController.createNewVaultAndKeychain(password, null, function (err, newState) {
+ assert.ifError(err)
+ state = newState
done()
})
})
@@ -42,6 +45,8 @@ describe('KeyringController', function() {
})
describe('#createNewVaultAndKeychain', function () {
+ this.timeout(10000)
+
it('should set a vault on the configManager', function(done) {
keyringController.configManager.setVault(null)
assert(!keyringController.configManager.getVault(), 'no previous vault')
@@ -57,19 +62,21 @@ describe('KeyringController', function() {
describe('#restoreKeyring', function() {
it(`should pass a keyring's serialized data back to the correct type.`, function() {
- keyringController.keyringTypes = [ MockSimpleKeychain ]
-
const mockSerialized = {
- type: MockSimpleKeychain.type(),
- data: [ '0x123456null788890abcdef' ],
+ type: 'HD Key Tree',
+ data: {
+ mnemonic: seedWords,
+ n: 1,
+ }
}
const mock = this.sinon.mock(keyringController)
mock.expects('loadBalanceAndNickname')
.exactly(1)
- var keyring = keyringController.restoreKeyring(0, mockSerialized)
+ var keyring = keyringController.restoreKeyring(mockSerialized)
assert.equal(keyring.wallets.length, 1, 'one wallet restored')
+ assert.equal(keyring.getAccounts()[0], addresses[0])
mock.verify()
})
@@ -85,6 +92,19 @@ describe('KeyringController', function() {
})
})
+ describe('#createNickname', function() {
+ it('should add the address to the identities hash', function() {
+ const fakeAddress = '0x12345678'
+ keyringController.createNickname(fakeAddress)
+ const identities = keyringController.identities
+ const identity = identities[fakeAddress]
+ assert.equal(identity.address, fakeAddress)
+
+ const nick = keyringController.configManager.nicknameForWallet(fakeAddress)
+ assert.equal(typeof nick, 'string')
+ })
+ })
+
})