Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Commit

Permalink
Update peers related files to cover the review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
nazarhussain committed Nov 9, 2017
1 parent af49c2a commit 970d570
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 43 deletions.
2 changes: 1 addition & 1 deletion api/controllers/peers.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ PeersController.getPeers = function (req, res) {
};

// Remove filters with null values
filters = _.pickBy(filters, function (v, k) {
filters = _.pickBy(filters, function (v) {
return !(v === undefined || v === null);
});

Expand Down
2 changes: 1 addition & 1 deletion api/fittings/lisk_params_validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ module.exports = function create (fittingDef, bagpipes) {
});
}
} else {
console.log('not a swagger operation, will not validate response');
error = new Error('Not a swagger operation, will not validate response');
}

cb(error);
Expand Down
2 changes: 1 addition & 1 deletion modules/peers.js
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ Peers.prototype.shared = {
/**
* Utility method to get peers
*
* @param {object} parameters - Object of all parameters
* @param {Object} parameters - Object of all parameters
* @param {string} parameters.ip - IP of the peer
* @param {string} parameters.port - WS Port of the peer
* @param {string} parameters.httpPort - Web Socket Port of the peer
Expand Down
4 changes: 2 additions & 2 deletions schema/swagger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ parameters:
wsPort:
name: wsPort
in: query
description: wsPort for the node or delegate
description: Web socket port for the node or delegate
type: integer
format: int32
minimum: 1
Expand All @@ -175,7 +175,7 @@ parameters:
version:
name: version
in: query
description: Version of the lisk
description: Lisk version run by node
type: string
format: version
minLength: 5
Expand Down
2 changes: 1 addition & 1 deletion test/common/wsServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,4 @@ var wsServer = {
}
};

module.exports = wsServer;
module.exports = wsServer;
2 changes: 1 addition & 1 deletion test/common/wsServerMaster.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function WSServerMaster () {
}

/**
* Start the socket server instance. It will start the server as well an instance of the client.
* Start the socket server master instance. It will start the server and an instance of the client.
*
* @return {Promise}
*/
Expand Down
2 changes: 1 addition & 1 deletion test/functional/http/get/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe('GET /node', function () {
constantsResponse.supply.should.be.equal('10000000000000000');
});

it('should return a result containing version = "0.0.0a"', function () {
it('should return a result containing version = "0.0.1"', function () {
constantsResponse.should.have.property('version').equal('0.0.1');
});

Expand Down
10 changes: 6 additions & 4 deletions test/functional/http/get/peers.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,17 +123,19 @@ describe('GET /api/peers', function () {
});
});

it('using sort = "version:asc" should be ok', function () {
it('using sort = "version:asc" should return results in ascending order by version', function () {
return peersEndpoint.makeRequest({sort: 'version:asc'}, 200)
.then(function (res) {
_.orderBy(_.clone(res.body.peers), ['version'], ['asc']).should.be.eql(res.body.peers);
var versions = _(res.body.peers).map('version').value();
_.clone(versions).sort().should.be.eql(versions);
});
});

it('using sort = "version:desc" should be ok', function () {
it('using sort = "version:desc" should return results in descending order by version', function () {
return peersEndpoint.makeRequest({sort: 'version:desc'}, 200)
.then(function (res) {
_.orderBy(_.clone(res.body.peers), ['version'], ['desc']).should.be.eql(res.body.peers);
var versions = _(res.body.peers).map('version').value();
_.clone(versions).sort().reverse().should.be.eql(versions);
});
});

Expand Down
67 changes: 36 additions & 31 deletions test/functional/ws/transport.handshake.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ var scClient = require('socketcluster-client');
var testConfig = require('../../config.json');
var ws = require('../../common/wsCommunication');
var wsServer = require('../../common/wsServer');
var WSClient = require('../../common/wsClient');

describe('handshake', function () {

Expand Down Expand Up @@ -88,57 +87,63 @@ describe('handshake', function () {

describe('should fail with INVALID_HEADERS code and description', function () {

it('without headers', function () {
return new WSClient(null, {disconnect: function (code, description) {
it('without headers', function (done) {
delete validClientSocketOptions.query;
connect();
expectDisconnect(this, function (code) {
expect(code).equal(failureCodes.INVALID_HEADERS);
}});
done();
});
});

it('with empty headers', function () {
return new WSClient({}, {disconnect: function (code, description) {
it('with empty headers', function (done) {
validClientSocketOptions.query = {};
connect();
expectDisconnect(this, function (code, description) {
expect(code).equal(failureCodes.INVALID_HEADERS);
expect(description).contain('Missing required property');
}}).start();
done();
});
});

it('without port', function () {
var headers = _.clone(frozenHeaders);
delete headers.port;

return new WSClient(headers, {disconnect: function (code, description) {
it('without port', function (done) {
delete validClientSocketOptions.query.port;
connect();
expectDisconnect(this, function (code, description) {
expect(code).equal(failureCodes.INVALID_HEADERS);
expect(description).contain('Expected type integer but found type not-a-number');
}}).start();
done();
});
});

it('without height', function () {
var headers = _.clone(frozenHeaders);
delete headers.height;

return new WSClient(headers, {disconnect: function (code, description) {
it('without height', function (done) {
delete validClientSocketOptions.query.height;
connect();
expectDisconnect(this, function (code, description) {
expect(code).equal(failureCodes.INVALID_HEADERS);
expect(description).contain('#/height: Expected type integer but found type not-a-number');
}}).start();
done();
});
});

it('without version', function () {
var headers = _.clone(frozenHeaders);
delete headers.version;

return new WSClient(headers, {disconnect: function (code, description) {
it('without version', function (done) {
delete validClientSocketOptions.query.version;
connect();
expectDisconnect(this, function (code, description) {
expect(code).equal(failureCodes.INVALID_HEADERS);
expect(description).contain('Missing required property: version');
}}).start();
done();
});
});

it('without nethash', function () {
var headers = _.clone(frozenHeaders);
delete headers.nethash;

return new WSClient(headers, {disconnect: function (code, description) {
it('without nethash', function (done) {
delete validClientSocketOptions.query.nethash;
connect();
expectDisconnect(this, function (code, description) {
expect(code).equal(failureCodes.INVALID_HEADERS);
expect(description).contain('Missing required property: nethash');
}}).start();
done();
});
});
});
});
Expand Down

0 comments on commit 970d570

Please sign in to comment.