|
|
@ -57,27 +57,29 @@ describe('hd-keyring', function() { |
|
|
|
|
|
|
|
|
|
|
|
describe('#deserialize a private key', function() { |
|
|
|
describe('#deserialize a private key', function() { |
|
|
|
it('serializes what it deserializes', function(done) { |
|
|
|
it('serializes what it deserializes', function(done) { |
|
|
|
|
|
|
|
console.log('deserializing ' + sampleMnemonic) |
|
|
|
keyring.deserialize({ |
|
|
|
keyring.deserialize({ |
|
|
|
mnemonic: sampleMnemonic, |
|
|
|
mnemonic: sampleMnemonic, |
|
|
|
numberOfAccounts: 1 |
|
|
|
numberOfAccounts: 1 |
|
|
|
}) |
|
|
|
}) |
|
|
|
.then(() => { |
|
|
|
.then(() => { |
|
|
|
|
|
|
|
console.dir(keyring) |
|
|
|
assert.equal(keyring.wallets.length, 1, 'restores two accounts') |
|
|
|
assert.equal(keyring.wallets.length, 1, 'restores two accounts') |
|
|
|
keyring.addAccounts(1) |
|
|
|
return keyring.addAccounts(1) |
|
|
|
|
|
|
|
}).then(() => { |
|
|
|
const accounts = keyring.getAccounts() |
|
|
|
return keyring.getAccounts() |
|
|
|
|
|
|
|
}).then((accounts) => { |
|
|
|
assert.equal(accounts[0], firstAcct) |
|
|
|
assert.equal(accounts[0], firstAcct) |
|
|
|
assert.equal(accounts[1], secondAcct) |
|
|
|
assert.equal(accounts[1], secondAcct) |
|
|
|
assert.equal(accounts.length, 2) |
|
|
|
assert.equal(accounts.length, 2) |
|
|
|
|
|
|
|
|
|
|
|
keyring.serialize() |
|
|
|
return keyring.serialize() |
|
|
|
.then((serialized) => { |
|
|
|
}).then((serialized) => { |
|
|
|
assert.equal(serialized.mnemonic, sampleMnemonic) |
|
|
|
assert.equal(serialized.mnemonic, sampleMnemonic) |
|
|
|
done() |
|
|
|
done() |
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
describe('#addAccounts', function() { |
|
|
|
describe('#addAccounts', function() { |
|
|
|
describe('with no arguments', function() { |
|
|
|
describe('with no arguments', function() { |
|
|
|