From 96d63f061305319dd08157750868ab6349655cf9 Mon Sep 17 00:00:00 2001 From: Kagami Hiiragi Date: Tue, 24 Feb 2015 19:09:01 +0300 Subject: [PATCH] version.version -> version.protoVersion --- lib/messages.js | 10 +++++----- lib/net/tcp.js | 6 +----- lib/net/ws.js | 2 +- tests/functional.js | 3 ++- tests/run-test-nodes.js | 1 - tests/unit.js | 2 +- 6 files changed, 10 insertions(+), 14 deletions(-) diff --git a/lib/messages.js b/lib/messages.js index 47118c1..320be67 100644 --- a/lib/messages.js +++ b/lib/messages.js @@ -83,10 +83,10 @@ var randomNonce = bmcrypto.randomBytes(8); var version = exports.version = { /** * @typedef {Object} DecodeResult - * @property {number} version - Identifies protocol version being used - * by the node. Should equal 3. Nodes should disconnect if the remote - * node's version is lower but continue with the connection if it is - * higher. + * @property {number} protoVersion - Identifies protocol version being + * used by the node. Should equal 3. Nodes should disconnect if the + * remote node's version is lower but continue with the connection if + * it is higher. * @property {Object} services - * [Service]{@link module:bitmessage/structs.ServicesBitfield} * features to be enabled for this connection @@ -138,7 +138,7 @@ var version = exports.version = { var decodedUa = UserAgent.decode(buf.slice(80)); var decodedStreams = structs.var_int_list.decode(decodedUa.rest); return { - version: protoVersion, + protoVersion: protoVersion, services: services, time: time, remoteHost: addrRecv.host, diff --git a/lib/net/tcp.js b/lib/net/tcp.js index 40c7f52..7533e3b 100644 --- a/lib/net/tcp.js +++ b/lib/net/tcp.js @@ -125,11 +125,7 @@ TcpTransport.prototype._setupClient = function(client, incoming) { } cache = decoded.rest; if (decoded.message) { - self.emit( - "message", - decoded.message.command, - decoded.message.payload, - decoded.message); + self.emit("message", decoded.message.command, decoded.message.payload); } else if (decoded.error) { // TODO(Kagami): Wrap it in custom error class? // TODO(Kagami): Send `error` message and ban node for some time diff --git a/lib/net/ws.js b/lib/net/ws.js index 37da383..91433e3 100644 --- a/lib/net/ws.js +++ b/lib/net/ws.js @@ -117,7 +117,7 @@ WsTransport.prototype._setupClient = function(client, incoming) { "Message decoding error: " + err.message )); } - self.emit("message", decoded.command, decoded.payload, decoded); + self.emit("message", decoded.command, decoded.payload); }); // High-level message processing. diff --git a/tests/functional.js b/tests/functional.js index 758cba8..9c44dad 100644 --- a/tests/functional.js +++ b/tests/functional.js @@ -64,7 +64,7 @@ if (!process.browser) { it("should automatically establish connection", function(done) { tcp.once("established", function(version) { - expect(version.version).to.equal(3); + expect(version.protoVersion).to.equal(3); expect(version.services.get(ServicesBitfield.NODE_NETWORK)).to.be.true; expect(version.remoteHost).to.equal("127.0.0.1"); expect(version.port).to.equal(22333); @@ -127,6 +127,7 @@ describe("WebSocket transport", function() { it("should automatically establish connection", function(done) { ws.once("established", function(version) { + expect(version.protoVersion).to.equal(3); expect(version.services.get(ServicesBitfield.NODE_GATEWAY)).to.be.true; expect(version.remoteHost).to.equal("127.0.0.1"); expect(version.port).to.equal(22334); diff --git a/tests/run-test-nodes.js b/tests/run-test-nodes.js index 4762b32..9f5eded 100644 --- a/tests/run-test-nodes.js +++ b/tests/run-test-nodes.js @@ -37,7 +37,6 @@ module.exports = function() { process.on("exit", cleanup()); process.on("SIGINT", cleanup(true)); - process.on("uncaughtException", cleanup(true)); var tcpNode = spawn("tcp-node.js"); var wsNode = spawn("ws-node.js"); diff --git a/tests/unit.js b/tests/unit.js index 549ed82..3f1c7e1 100644 --- a/tests/unit.js +++ b/tests/unit.js @@ -496,7 +496,7 @@ describe("Message types", function() { }); expect(message.decode(encoded).command).to.equal("version"); var res = version.decode(encoded); - expect(res.version).to.equal(3); + expect(res.protoVersion).to.equal(3); expect(res.services.get(ServicesBitfield.NODE_NETWORK)).to.be.true; expect(res.time).to.be.instanceof(Date); expect(res.remoteHost).to.equal("1.2.3.4");