From 37fd45e5b70a66ff976cab0d1815374063e29d10 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Fri, 25 Mar 2016 12:41:18 -0700 Subject: Convert to bip44 hdTrees Added initial test just to verify we can recover the accounts we generate in this way. Still need to add compliance test to make sure this interoperates with testrpc's new mnemonic flag. --- test/index.js | 57 +++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 49 insertions(+), 8 deletions(-) (limited to 'test') diff --git a/test/index.js b/test/index.js index 1ff7b673a..5a8df78b8 100644 --- a/test/index.js +++ b/test/index.js @@ -1,11 +1,52 @@ -var assert = require('assert'); -var idStore = require('../app/scripts/lib/idStore') +var assert = require('assert') +var IdentityStore = require('../app/scripts/lib/idStore') +var jsdom = require('mocha-jsdom') +jsdom() describe('IdentityStore', function() { - describe('#_createFirstWallet', function () { - it('should return the expected keystore', function () { - assert.equal(1,1) - }); - }); -}); + describe('#createNewVault', function () { + let idStore + let password = 'password123' + let entropy = 'entripppppyy duuude' + let seedWords + let accounts = [] + let originalKeystore + + before(function(done) { + window.localStorage = {} // Hacking localStorage support into JSDom + + idStore = new IdentityStore({ + addAccount(acct) { accounts.push(acct) }, + }) + + idStore.createNewVault(password, entropy, (err, seeds) => { + seedWords = seeds + originalKeystore = idStore._idmgmt.keyStore + done() + }) + }) + + describe('#recoverFromSeed', function() { + + before(function() { + window.localStorage = {} // Hacking localStorage support into JSDom + accounts = [] + + idStore = new IdentityStore({ + addAccount(acct) { accounts.push(acct) }, + }) + }) + + it('should return the expected keystore', function () { + + idStore.recoverFromSeed(password, seedWords, (err) => { + assert.ifError(err) + + let newKeystore = idStore._idmgmt.keyStore + assert.equal(newKeystore, originalKeystore) + }) + }) + }) + }) +}) -- cgit