fix tests
This commit is contained in:
parent
1775d98746
commit
7141dee5c8
2 changed files with 25 additions and 16 deletions
|
|
@ -80,16 +80,20 @@ angular.module('copay.network')
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case 'disconnect':
|
case 'disconnect':
|
||||||
$rootScope.connectedPeers = _arrayRemove(obj.sender, $rootScope.connectedPeers);
|
_onClose(obj.sender);
|
||||||
$rootScope.connectedTo = _arrayRemove(obj.sender, $rootScope.connectedTo);
|
|
||||||
|
|
||||||
_saveDataStorage();
|
|
||||||
|
|
||||||
$rootScope.$digest();
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var _onClose = function(pid) {
|
||||||
|
$rootScope.connectedPeers = _arrayRemove(pid, $rootScope.connectedPeers);
|
||||||
|
$rootScope.connectedTo = _arrayRemove(pid, $rootScope.connectedTo);
|
||||||
|
|
||||||
|
_saveDataStorage();
|
||||||
|
|
||||||
|
$rootScope.$digest();
|
||||||
|
};
|
||||||
|
|
||||||
var _connectToPeers = function(peers) {
|
var _connectToPeers = function(peers) {
|
||||||
var arrayDiff = _arrayDiff(peers, $rootScope.connectedTo);
|
var arrayDiff = _arrayDiff(peers, $rootScope.connectedTo);
|
||||||
|
|
||||||
|
|
@ -99,7 +103,7 @@ angular.module('copay.network')
|
||||||
};
|
};
|
||||||
|
|
||||||
// public methods
|
// public methods
|
||||||
var _init = function(cb) {
|
var init = function(cb) {
|
||||||
peer = new Peer($rootScope.peerId, {
|
peer = new Peer($rootScope.peerId, {
|
||||||
key: 'lwjd5qra8257b9', // TODO: we need our own PeerServer KEY (http://peerjs.com/peerserver)
|
key: 'lwjd5qra8257b9', // TODO: we need our own PeerServer KEY (http://peerjs.com/peerserver)
|
||||||
debug: 3
|
debug: 3
|
||||||
|
|
@ -135,13 +139,17 @@ angular.module('copay.network')
|
||||||
});
|
});
|
||||||
|
|
||||||
c.on('data', _onData);
|
c.on('data', _onData);
|
||||||
|
|
||||||
|
c.on('close', function() {
|
||||||
|
_onClose(c.peer);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
var _connect = function(pid, cb) {
|
var connect = function(pid, cb) {
|
||||||
if (pid !== $rootScope.peerId) {
|
if (pid !== $rootScope.peerId) {
|
||||||
var c = peer.connect(pid, {
|
var c = peer.connect(pid, {
|
||||||
label: 'wallet',
|
label: 'wallet',
|
||||||
|
|
@ -163,6 +171,10 @@ angular.module('copay.network')
|
||||||
});
|
});
|
||||||
|
|
||||||
c.on('data', _onData);
|
c.on('data', _onData);
|
||||||
|
|
||||||
|
c.on('close', function() {
|
||||||
|
_onClose(c.peer);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -175,7 +187,7 @@ angular.module('copay.network')
|
||||||
_sender(pids, data, cb);
|
_sender(pids, data, cb);
|
||||||
};
|
};
|
||||||
|
|
||||||
var _disconnect = function(cb) {
|
var disconnect = function(cb) {
|
||||||
var conns = $rootScope.connectedPeers.length;
|
var conns = $rootScope.connectedPeers.length;
|
||||||
var i = 1;
|
var i = 1;
|
||||||
|
|
||||||
|
|
@ -198,10 +210,10 @@ angular.module('copay.network')
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
init: _init,
|
init: init,
|
||||||
connect: _connect,
|
connect: connect,
|
||||||
send: _send,
|
send: _send,
|
||||||
disconnect: _disconnect
|
disconnect: disconnect
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -252,13 +252,10 @@ describe('PublicKeyRing model', function() {
|
||||||
id: w.id,
|
id: w.id,
|
||||||
});
|
});
|
||||||
w2.addCopayer();
|
w2.addCopayer();
|
||||||
w.merge(w2.toObj());
|
w.merge(w2.toObj()).should.equal(true);
|
||||||
}
|
}
|
||||||
w.haveAllRequiredPubKeys().should.equal(true);
|
w.haveAllRequiredPubKeys().should.equal(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue