Merge pull request #87 from ryanxcharles/bug/fix-tests
add setFromObj to FakeStorage - and fix publicKeyring capitalization
This commit is contained in:
commit
f90decca0e
3 changed files with 10 additions and 2 deletions
|
|
@ -166,7 +166,7 @@ Wallet.prototype.toObj = function() {
|
||||||
var optsObj = this._optsToObj();
|
var optsObj = this._optsToObj();
|
||||||
var walletObj = {
|
var walletObj = {
|
||||||
opts: optsObj,
|
opts: optsObj,
|
||||||
publicKeyring: this.publicKeyRing.toObj(),
|
publicKeyRing: this.publicKeyRing.toObj(),
|
||||||
txProposals: this.txProposals.toObj(),
|
txProposals: this.txProposals.toObj(),
|
||||||
privateKey: this.privateKey.toObj()
|
privateKey: this.privateKey.toObj()
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -48,11 +48,13 @@ WalletFactory.prototype._checkRead = function(walletId) {
|
||||||
};
|
};
|
||||||
|
|
||||||
WalletFactory.prototype.read = function(walletId) {
|
WalletFactory.prototype.read = function(walletId) {
|
||||||
if (! this._checkRead(walletId)) return false;
|
if (! this._checkRead(walletId))
|
||||||
|
throw Error('Check read failed');
|
||||||
|
|
||||||
var s = this.storage;
|
var s = this.storage;
|
||||||
var opts = s.get(walletId, 'opts');
|
var opts = s.get(walletId, 'opts');
|
||||||
|
|
||||||
|
opts.id = walletId;
|
||||||
opts.publicKeyRing = new PublicKeyRing.fromObj(s.get(walletId, 'publicKeyRing'));
|
opts.publicKeyRing = new PublicKeyRing.fromObj(s.get(walletId, 'publicKeyRing'));
|
||||||
opts.txProposals = new TxProposals.fromObj(s.get(walletId, 'txProposals'));
|
opts.txProposals = new TxProposals.fromObj(s.get(walletId, 'txProposals'));
|
||||||
opts.privateKey = new PrivateKey.fromObj(s.get(walletId, 'privateKey'));
|
opts.privateKey = new PrivateKey.fromObj(s.get(walletId, 'privateKey'));
|
||||||
|
|
|
||||||
|
|
@ -27,4 +27,10 @@ FakeStorage.prototype.getWalletIds = function() {
|
||||||
return [];
|
return [];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
FakeStorage.prototype.setFromObj = function(walletId, obj) {
|
||||||
|
for (var i in obj) {
|
||||||
|
this.storage[walletId + '-' + i] = obj[i];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
module.exports = require('soop')(FakeStorage);
|
module.exports = require('soop')(FakeStorage);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue