make listening optional and fixed peer test

This commit is contained in:
Braydon Fuller 2015-03-12 18:50:30 -04:00
parent 7f61fc62d4
commit 6461748cd5
3 changed files with 4 additions and 4 deletions

View File

@ -31,7 +31,7 @@ var util = require('util');
* @constructor
*/
function Peer(options) {
/* jshint maxstatements: 20 */
/* jshint maxstatements: 25 */
/* jshint maxcomplexity: 8 */
if (!(this instanceof Peer)) {
@ -51,6 +51,7 @@ function Peer(options) {
}
this.network = Networks.get(options.network) || Networks.defaultNetwork;
if (!this.port) {
this.port = this.network.port;
}

View File

@ -127,8 +127,6 @@ Pool.prototype.connect = function connect() {
} else {
self._fillConnections();
}
this.listen();
return this;
};
@ -340,7 +338,7 @@ Pool.prototype.sendMessage = function(message) {
Pool.prototype.listen = function() {
var self = this;
// Create server
// Create server
this.server = net.createServer(function(socket) {
var addr = {
ip: {}

View File

@ -139,6 +139,7 @@ describe('Peer', function() {
var peer = new Peer({host: 'localhost'});
var socket = new EventEmitter();
socket.connect = sinon.spy();
socket.destroy = sinon.spy();
peer._getSocket = function() {
return socket;
};