ALL TEST PASSING!!!

This commit is contained in:
Matias Alejo Garcia 2014-09-15 13:56:38 -03:00
commit 5cf4fe0b66
5 changed files with 184 additions and 71 deletions

View file

@ -111,7 +111,7 @@ Storage.prototype.getSessionId = function(cb) {
return cb(sessionId);
sessionId = bitcore.SecureRandom.getRandomBuffer(8).toString('hex');
self.sessionStorage.setItem('sessionId', sessionId, function(){
self.sessionStorage.setItem('sessionId', sessionId, function() {
return cb(sessionId);
});
});
@ -232,31 +232,36 @@ Storage.prototype.deleteWallet = function(walletId, cb) {
preconditions.checkArgument(walletId);
preconditions.checkArgument(cb);
var err;
var self = this;
var toDelete = {};
toDelete['nameFor::' + walletId] = 1;
this.storage.allKeys(function(allKeys) {
for (var key in allKeys) {
for (var ii in allKeys) {
var key = allKeys[ii];
var split = key.split('::');
if (split.length == 2 && split[0] === walletId) {
toDelete[key] = 1;
};
}
var l = Object.keys(toDelete).length,
j = 0;
if (!l)
return cb(new Error('WNOTFOUND: Wallet not found'));
toDelete['nameFor::' + walletId] = 1;
l++;
for (var i in toDelete) {
self.removeGlobal(i, function() {
if (++j == l)
return cb(err);
});
}
});
var l = toDelete.length,
j = 0;
if (!l)
return cb(new Error('WNOTFOUND: Wallet not found'));
for (var i in toDelete) {
this.removeGlobal(i, function() {
if (++j == l)
return cb(err);
});
}
};
Storage.prototype.setLastOpened = function(walletId, cb) {

View file

@ -53,6 +53,7 @@ function WalletFactory(config, version, pluginManager) {
this.storage = new this.Storage(storageOpts);
<<<<<<< HEAD
this.networks = {
'livenet': new this.Network(config.network.livenet),
'testnet': new this.Network(config.network.testnet),
@ -63,6 +64,10 @@ function WalletFactory(config, version, pluginManager) {
};
this.walletDefaults = config.wallet;
=======
this.networkName = config.networkName;
this.walletDefaults = config.wallet || {};
>>>>>>> ALL TEST PASSING!!!
this.version = version;
};
@ -90,7 +95,6 @@ WalletFactory.prototype.fromObj = function(obj, skipFields) {
preconditions.checkState(networkName);
preconditions.checkArgument(obj);
// not stored options
obj.opts = obj.opts || {};
obj.opts.reconnectDelay = this.walletDefaults.reconnectDelay;
@ -418,7 +422,7 @@ WalletFactory.prototype.joinCreateSession = function(opts, cb) {
joinNetwork.start(opts, function() {
joinNetwork.greet(decodedSecret.pubKey, opts.secretNumber);
joinNetwork.on('data', function(sender, data) {
if (data.type === 'walletId') {
if (data.type === 'walletId' && data.opts) {
if (data.networkName !== decodedSecret.networkName) {
return cb('badNetwork');
}