fix tests

This commit is contained in:
Matias Alejo Garcia 2014-06-09 11:41:13 -03:00
parent abcbda8cf4
commit 5ff8ad236a
2 changed files with 5 additions and 8 deletions

View File

@ -161,7 +161,7 @@ Wallet.prototype._handleData = function(senderId, data, isInbound) {
Wallet.prototype._handleConnect = function(newCopayerId) { Wallet.prototype._handleConnect = function(newCopayerId) {
if (newCopayerId) { if (newCopayerId) {
this.log('#### Setting new COPAYER:', newCopayerId); this.log('#### Setting new COPAYER:', newCopayerId);
this.currentDelay = this.reconnectDelay; this.currentDelay = null;
this.sendWalletId(newCopayerId); this.sendWalletId(newCopayerId);
} }
var peerID = this.network.peerFromCopayer(newCopayerId) var peerID = this.network.peerFromCopayer(newCopayerId)
@ -251,6 +251,7 @@ Wallet.prototype.netStart = function() {
if (this.publicKeyRing.isComplete()) { if (this.publicKeyRing.isComplete()) {
this._lockIncomming(); this._lockIncomming();
} }
net.start(startOpts, function() { net.start(startOpts, function() {
self.emit('ready', net.getPeer()); self.emit('ready', net.getPeer());
self.token = net.peer.options.token; self.token = net.peer.options.token;
@ -265,11 +266,9 @@ Wallet.prototype.netStart = function() {
Wallet.prototype.scheduleConnect = function() { Wallet.prototype.scheduleConnect = function() {
var self = this; var self = this;
self.currentDelay = self.currentDelay || self.reconnectDelay;
if (self.network.isOnline()) { if (self.network.isOnline()) {
self.connectToAll(); self.connectToAll();
self.currentDelay *=2; self.currentDelay = self.currentDelay*2 || self.reconnectDelay;
setTimeout(self.scheduleConnect.bind(self), self.currentDelay); setTimeout(self.scheduleConnect.bind(self), self.currentDelay);
} }
} }

View File

@ -237,20 +237,18 @@ describe('Wallet model', function() {
throw (); throw ();
}); });
it.only('call reconnect after interval', function(done) { it('call reconnect after interval', function(done) {
var w = createW2(); var w = createW2();
var testTime = 1000; var testTime = 1000;
var callCount = 0; var callCount = 0;
var cT=w.reconnectDelay; var cT=w.reconnectDelay;
console.log('[test.Wallet.js.238:cT:]',cT); //TODO
var t=0; var t=0;
do { do {
callCount++; callCount++;
t += cT; t += cT;
cT *= 2; cT *= 2;
console.log('[test.Wallet.js.242]',t, callCount); //TODO
} while (t<testTime); } while (t<testTime);
console.log('[test.Wallet.js.241:callCount:]',callCount); //TODO
var spy = sinon.spy(w, 'scheduleConnect'); var spy = sinon.spy(w, 'scheduleConnect');
w.netStart(); w.netStart();