make listening optional and fixed peer test
This commit is contained in:
parent
7f61fc62d4
commit
6461748cd5
@ -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;
|
||||
}
|
||||
|
||||
@ -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: {}
|
||||
|
||||
@ -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;
|
||||
};
|
||||
|
||||
Loading…
Reference in New Issue
Block a user