trying to fix tests
This commit is contained in:
parent
64072f83bc
commit
52a8423df9
2 changed files with 23 additions and 16 deletions
|
|
@ -37,7 +37,8 @@ var Storage = module.exports.Storage = require('../Storage');
|
||||||
|
|
||||||
function WalletFactory(config, version, pluginManager) {
|
function WalletFactory(config, version, pluginManager) {
|
||||||
var self = this;
|
var self = this;
|
||||||
config = config || {};
|
preconditions.checkArgument(config);
|
||||||
|
preconditions.checkArgument(config.network);
|
||||||
|
|
||||||
this.Storage = config.Storage || Storage;
|
this.Storage = config.Storage || Storage;
|
||||||
this.Network = config.Network || Async;
|
this.Network = config.Network || Async;
|
||||||
|
|
@ -62,7 +63,7 @@ function WalletFactory(config, version, pluginManager) {
|
||||||
'testnet': new this.Blockchain(config.network.testnet),
|
'testnet': new this.Blockchain(config.network.testnet),
|
||||||
};
|
};
|
||||||
|
|
||||||
this.walletDefaults = config.walle || {};
|
this.walletDefaults = config.wallet || {};
|
||||||
this.version = version;
|
this.version = version;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -94,9 +95,6 @@ WalletFactory.prototype.fromObj = function(obj, skipFields) {
|
||||||
obj.opts = obj.opts || {};
|
obj.opts = obj.opts || {};
|
||||||
obj.opts.reconnectDelay = this.walletDefaults.reconnectDelay;
|
obj.opts.reconnectDelay = this.walletDefaults.reconnectDelay;
|
||||||
|
|
||||||
// this is only used if private key or public key ring is skipped
|
|
||||||
obj.opts.networkName = networkName;
|
|
||||||
|
|
||||||
skipFields = skipFields || [];
|
skipFields = skipFields || [];
|
||||||
skipFields.forEach(function(k) {
|
skipFields.forEach(function(k) {
|
||||||
if (obj[k]) {
|
if (obj[k]) {
|
||||||
|
|
|
||||||
|
|
@ -131,30 +131,39 @@ describe('WalletFactory model', function() {
|
||||||
iterations: 100,
|
iterations: 100,
|
||||||
storageSalt: 'mjuBtGybi/4=',
|
storageSalt: 'mjuBtGybi/4=',
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// network layer config
|
||||||
|
network: {
|
||||||
|
testnet: {
|
||||||
|
url: 'https://test-insight.bitpay.com:443'
|
||||||
|
},
|
||||||
|
livenet: {
|
||||||
|
url: 'https://insight.bitpay.com:443'
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
describe('#constructor', function() {
|
describe('#constructor', function() {
|
||||||
it('should create the factory', function() {
|
it('should create the factory', function() {
|
||||||
var wf = new WalletFactory(config, '0.0.1');
|
var wf = new WalletFactory(config, '0.0.1');
|
||||||
should.exist(wf);
|
should.exist(wf);
|
||||||
wf.networkName.should.equal(config.networkName);
|
|
||||||
wf.walletDefaults.should.deep.equal(config.wallet);
|
wf.walletDefaults.should.deep.equal(config.wallet);
|
||||||
wf.version.should.equal('0.0.1');
|
wf.version.should.equal('0.0.1');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('#fromObj / #toObj', function() {
|
describe('#fromObj / #toObj', function() {
|
||||||
it('round trip', function() {
|
it.only('round trip', function() {
|
||||||
var wf = new WalletFactory(config, '0.0.5');
|
var wf = new WalletFactory(config, '0.0.5');
|
||||||
var w = wf.fromObj(JSON.parse(o));
|
var original = JSON.parse(o);
|
||||||
|
var o2 = wf.fromObj(original).toObj();
|
||||||
|
|
||||||
should.exist(w);
|
console.log('[test.WalletFactory.js.169]', original.opts); //TODO
|
||||||
w.id.should.equal("dbfe10c3fae71cea");
|
['addressBook', 'networkNonce','networkNonces', 'opts', 'privateKey','copayersExtPubKeys'].forEach(function(k){
|
||||||
should.exist(w.publicKeyRing.getCopayerId);
|
o2[k].should.be.deep.equal(original[k], k + ' differs');
|
||||||
should.exist(w.txProposals.toObj());
|
})
|
||||||
should.exist(w.privateKey.toObj());
|
//assertObjectEqual(w.toObj(), JSON.parse(o));
|
||||||
|
|
||||||
assertObjectEqual(w.toObj(), JSON.parse(o));
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('round trip, using old copayerIndex', function() {
|
it('round trip, using old copayerIndex', function() {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue