Merge pull request #1921 from matiu/tests

Tests
This commit is contained in:
Matias Alejo Garcia 2014-12-02 17:46:12 -03:00
commit 0060c9a0c9
25 changed files with 216 additions and 35 deletions

View file

@ -2,7 +2,7 @@
var EventEmitter = require('events').EventEmitter;
var bitcore = require('bitcore');
var log = require('../log');
var log = require('../util/log');
var AuthMessage = bitcore.AuthMessage;
var util = bitcore.util;
var nodeUtil = require('util');

View file

@ -5,7 +5,7 @@ var Wallet = require('./Wallet');
var cryptoUtils = require('../util/crypto');
var CryptoJS = require('node-cryptojs-aes').CryptoJS;
var sjcl = require('../../lib/sjcl');
var log = require('../log');
var log = require('../util/log');
var preconditions = require('preconditions').instance();
var _ = require('lodash');

View file

@ -3,7 +3,6 @@ var _ = require('lodash');
var preconditions = require('preconditions').singleton();
var inherits = require('inherits');
var events = require('events');
var log = require('../log');
var async = require('async');
var bitcore = require('bitcore');
@ -14,9 +13,9 @@ var PrivateKey = require('./PrivateKey');
var Wallet = require('./Wallet');
var PluginManager = require('./PluginManager');
var Async = require('./Async');
var version = require('../../version').version;
var cryptoUtil = require('../util/crypto');
var log = require('../util/log');
var version = require('../../version').version;
/**
* @desc

View file

@ -3,14 +3,16 @@
var util = require('util');
var async = require('async');
var request = require('request');
var bitcore = require('bitcore');
var io = require('socket.io-client');
var _ = require('lodash');
var log = require('../log');
var EventEmitter = require('events').EventEmitter;
var preconditions = require('preconditions').singleton();
var bitcore = require('bitcore');
var log = require('../util/log.js');
/*
This class lets interfaces with the blockchain, making general queries and
subscribing to transactions on adressess and blocks.

View file

@ -1,6 +1,6 @@
'use strict';
var preconditions = require('preconditions').singleton();
var log = require('../log');
var log = require('../util/log');
function PluginManager(config) {
this.registered = {};

View file

@ -2,7 +2,7 @@
var preconditions = require('preconditions').instance();
var _ = require('lodash');
var log = require('../log');
var log = require('../util/log');
var bitcore = require('bitcore');
var HK = bitcore.HierarchicalKey;
var Address = bitcore.Address;
@ -110,7 +110,7 @@ PublicKeyRing.fromObj = function(opts) {
}
if (opts.cache && opts.cache.addressToPath) {
log.info('PublicKeyRing: Using address cache');
log.debug('PublicKeyRing: Using address cache');
pkr.cache.addressToPath = opts.cache.addressToPath;
pkr.rebuildCache();
}

View file

@ -2,7 +2,7 @@
var util = require('util');
var _ = require('lodash');
var log = require('../log');
var log = require('../util/log');
var preconditions = require('preconditions').singleton();
var request = require('request');

View file

@ -10,7 +10,7 @@ var TransactionBuilder = bitcore.TransactionBuilder;
var Script = bitcore.Script;
var Key = bitcore.Key;
var log = require('../log');
var log = require('../util/log');
var TX_MAX_SIZE_KB = 50;
var VERSION = 1;

View file

@ -9,7 +9,7 @@ var Script = bitcore.Script;
var Key = bitcore.Key;
var buffertools = bitcore.buffertools;
var log = require('../log');
var log = require('../util/log');
var TxProposal = require('./TxProposal');;
function TxProposals(opts) {

View file

@ -18,7 +18,7 @@ var Address = bitcore.Address;
var PayPro = bitcore.PayPro;
var Transaction = bitcore.Transaction;
var log = require('../log');
var log = require('../util/log');
var cryptoUtil = require('../util/crypto');
var httpUtil = require('../util/HTTP');
var HDParams = require('./HDParams');

View file

@ -1,7 +1,7 @@
var cryptoUtil = require('../util/crypto');
var InsightStorage = require('./InsightStorage');
var inherits = require('inherits');
var log = require('../log');
var log = require('../util/log');
var SEPARATOR = '%^#@';
function EncryptedInsightStorage(config) {

View file

@ -1,5 +1,5 @@
var cryptoUtil = require('../util/crypto');
var log = require('../log');
var log = require('../util/log');
var LocalStorage = require('./LocalStorage');
var inherits = require('inherits');

View file

@ -3,7 +3,7 @@
var preconditions = require('preconditions').singleton();
var loaded = 0;
var SCOPES = 'https://www.googleapis.com/auth/drive';
var log = require('../log');
var log = require('../util/log');
function GoogleDrive(config) {
preconditions.checkArgument(config && config.clientId, 'No clientId at GoogleDrive config');

View file

@ -4,7 +4,7 @@ var bitcore = require('bitcore');
var buffers = require('buffer');
var querystring = require('querystring');
var Identity = require('../models/Identity');
var log = require('../log');
var log = require('../util/log');
var SEPARATOR = '|';

View file

@ -1,8 +1,12 @@
'use strict';
var _ = require('lodash');
var preconditions = require('preconditions').singleton();
function LocalStorage() {
this.type = 'DB';
preconditions.checkState(typeof localStorage !== 'undefined',
'localstorage not available, cannot run plugin');
};
LocalStorage.prototype.init = function() {

View file

@ -1,3 +1,5 @@
var preconditions = require('preconditions').singleton();
module.exports = {
request: function(options, callback) {
preconditions.checkArgument(_.isObject(options));
@ -25,9 +27,9 @@ module.exports = {
var req = options;
req.headers = req.headers || {};
req.body = req.body || req.data || {};
req.body = req.body || req.data || '';
var xhr = new XMLHttpRequest();
var xhr = options.xhr || new XMLHttpRequest();
xhr.open(method, url, true);
Object.keys(req.headers).forEach(function(key) {
@ -51,6 +53,7 @@ module.exports = {
headers[$1.toLowerCase()] = $2;
}
);
return ret._success(buf, xhr.status, headers, options);
};

View file

@ -2,8 +2,9 @@
* Small module for some helpers that wrap sjcl with some good practices.
*/
var sjcl = require('sjcl');
var log = require('../log.js');
var _ = require('lodash');
var log = require('../util/log.js');
var config = require('../../config');
var defaultSalt = (config && config.passphraseConfig && config.passphraseConfig.storageSalt) || 'mjuBtGybi/4=';

View file

@ -1,6 +1,11 @@
var config = config || require('../config');
var config = config || require('../../config');
var _ = require('lodash');
var ls;
try {
var LS = require('../plugins/LocalStorage');
ls = new LS();
} catch(e) {};
/**
* @desc
@ -119,13 +124,18 @@ Logger.prototype.setLevel = function(level) {
var logger = new Logger('copay');
var error = new Error();
var logLevel = config.logLevel;
var logLevel = config.logLevel || 'info';
if (typeof localStorage !== "undefined" && localStorage.getItem) {
var localConfig = JSON.parse(localStorage.getItem("config"));
if (localConfig && localConfig.logLevel)
logLevel = localConfig.logLevel;
if (ls && ls.getItem) {
ls.getItem("config", function(err, value) {
if (err) return;
var localConfig = JSON.parse(value);
if (localConfig && localConfig.logLevel)
logLevel = localConfig.logLevel;
logger.setLevel(logLevel);
});
} else {
logger.setLevel(logLevel);
}
logger.setLevel(logLevel);
module.exports = logger;