From a2c7ccafa6b4cdbd5f1725f7bf40189ad987cffa Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Fri, 25 Mar 2016 14:51:19 -0700 Subject: Implemented BIP44 compliance test. Also added the hdPath that Christian had told me to our calls to the LightWallet, but this does not seem to have made us generate the same accounts as `testrpc` yet. --- test/unit/idStore-test.js | 81 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 test/unit/idStore-test.js (limited to 'test/unit') diff --git a/test/unit/idStore-test.js b/test/unit/idStore-test.js new file mode 100644 index 000000000..4494bf505 --- /dev/null +++ b/test/unit/idStore-test.js @@ -0,0 +1,81 @@ +var assert = require('assert') +var IdentityStore = require('../../app/scripts/lib/idStore') + +describe('IdentityStore', function() { + + 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 (done) { + + idStore.recoverFromSeed(password, seedWords, (err) => { + assert.ifError(err) + + let newKeystore = idStore._idmgmt.keyStore + assert.equal(newKeystore, originalKeystore) + done() + }) + }) + }) + }) + + describe('#recoverFromSeed BIP44 compliance', function() { + let seedWords = 'picnic injury awful upper eagle junk alert toss flower renew silly vague' + let firstAccount = '0xaceef0221414801dde7f732196b1c9d8ea60b637' + let password = 'secret!' + let accounts = [] + let idStore + + before(function() { + window.localStorage = {} // Hacking localStorage support into JSDom + + idStore = new IdentityStore({ + addAccount(acct) { + console.log(`pushing account ${acct}`) + accounts.push(acct) + }, + }) + }) + + it('should return the expected first account', function (done) { + + idStore.recoverFromSeed(password, seedWords, (err) => { + assert.ifError(err) + + let newKeystore = idStore._idmgmt.keyStore + assert.equal(accounts[0], firstAccount) + done() + }) + }) + }) +}) -- cgit v1.2.3