diff --git a/lib/address.js b/lib/address.js index a1e3a3f..5680c63 100644 --- a/lib/address.js +++ b/lib/address.js @@ -291,7 +291,7 @@ Address.fromPassphrase = function(opts) { } signnonce += 2; encnonce += 2; - }; + } }; module.exports = Address; diff --git a/lib/objects.js b/lib/objects.js index 56efbe6..1e18e7c 100644 --- a/lib/objects.js +++ b/lib/objects.js @@ -27,7 +27,7 @@ exports.getpubkey = { * Decode `getpubkey` object message payload. * @param {Buffer} buf - Message payload * @return {Promise.} A promise that contained decoded - * `object` structure when fulfilled. + * `getpubkey` object structure when fulfilled. */ decodeAsync: function(buf) { return new promise(function(resolve) { @@ -61,7 +61,7 @@ exports.getpubkey = { var addr = Address.decode(opts.to); opts.version = addr.version; opts.stream = addr.stream; - opts.payload = opts.version < 4 ? addr.getRipe() : addr.getTag(); + opts.payload = addr.version < 4 ? addr.getRipe() : addr.getTag(); resolve(object.encode(opts)); }); }, diff --git a/test.js b/test.js index 7c0207b..12ffe60 100644 --- a/test.js +++ b/test.js @@ -418,7 +418,23 @@ describe("Message types", function() { describe("Object types", function() { describe("getpubkey", function() { - it("should encode and decode", function() { + it("should encode and decode getpubkey v3", function() { + return getpubkey.encodeAsync({ + nonce: Buffer(8), + ttl: 100, + to: "BM-2D8Jxw5yiepaQqxrx43iPPNfRqbvWoJLoU", + }).then(getpubkey.decodeAsync) + .then(function(res) { + expect(res.ttl).to.equal(100); + expect(res.type).to.equal(object.GETPUBKEY); + expect(res.version).to.equal(3); + expect(res.stream).to.equal(1); + expect(res.ripe.toString("hex")).to.equal("003ab6655de4bd8c603eba9b00dd5970725fdd56"); + expect(res).to.not.have.property("tag"); + }); + }); + + it("should encode and decode getpubkey v4", function() { return getpubkey.encodeAsync({ nonce: Buffer(8), ttl: 100, @@ -426,8 +442,10 @@ describe("Object types", function() { }).then(getpubkey.decodeAsync) .then(function(res) { expect(res.ttl).to.equal(100); + expect(res.type).to.equal(object.GETPUBKEY); expect(res.version).to.equal(4); expect(res.stream).to.equal(1); + expect(res).to.not.have.property("ripe"); expect(res.tag.toString("hex")).to.equal("facf1e3e6c74916203b7f714ca100d4d60604f0917696d0f09330f82f52bed1a"); }); });