fixed bug with incoming connections not having a port on addr
This commit is contained in:
parent
df632f35c6
commit
c555671bde
@ -366,6 +366,7 @@ Pool.prototype.listen = function() {
|
||||
} else {
|
||||
addr.ip.v4 = socket.remoteAddress;
|
||||
}
|
||||
addr.port = socket.remotePort;
|
||||
|
||||
addr = self._addAddr(addr);
|
||||
self._addConnectedPeer(socket, addr);
|
||||
|
||||
22
test/pool.js
22
test/pool.js
@ -486,6 +486,28 @@ describe('Pool', function() {
|
||||
pool.listen();
|
||||
});
|
||||
|
||||
it('include port for addr on incoming connections', function(done) {
|
||||
var port = 12345;
|
||||
sinon.stub(net, 'createServer', function(callback) {
|
||||
callback({
|
||||
remoteAddress: '127.0.0.1',
|
||||
remotePort: port
|
||||
});
|
||||
return {
|
||||
listen: sinon.stub()
|
||||
};
|
||||
});
|
||||
var pool = new Pool({network: Networks.livenet, maxSize: 1});
|
||||
pool._addAddr = function(addr) {
|
||||
should.exist(addr.port);
|
||||
addr.port.should.equal(port);
|
||||
net.createServer.restore();
|
||||
done();
|
||||
};
|
||||
pool._addConnectedPeer = sinon.stub();
|
||||
pool.listen();
|
||||
});
|
||||
|
||||
it('should handle an ipv4 connection', function(done) {
|
||||
var ipv4 = '127.0.0.1';
|
||||
sinon.stub(net, 'createServer', function(callback) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user