You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
82 lines
2.1 KiB
82 lines
2.1 KiB
9 years ago
|
var assert = require('assert')
|
||
9 years ago
|
var IdentityStore = require('../../app/scripts/lib/idStore')
|
||
9 years ago
|
|
||
|
describe('IdentityStore', function() {
|
||
|
|
||
9 years ago
|
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) },
|
||
|
})
|
||
|
})
|
||
|
|
||
9 years ago
|
it('should return the expected keystore', function (done) {
|
||
9 years ago
|
|
||
|
idStore.recoverFromSeed(password, seedWords, (err) => {
|
||
|
assert.ifError(err)
|
||
|
|
||
|
let newKeystore = idStore._idmgmt.keyStore
|
||
|
assert.equal(newKeystore, originalKeystore)
|
||
9 years ago
|
done()
|
||
9 years ago
|
})
|
||
|
})
|
||
|
})
|
||
|
})
|
||
9 years ago
|
|
||
|
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()
|
||
|
})
|
||
|
})
|
||
|
})
|
||
9 years ago
|
})
|