From 3abdcdabbbaf977afa289a7383a691581555f01f Mon Sep 17 00:00:00 2001 From: Yahya Date: Thu, 12 Oct 2017 11:09:18 +0300 Subject: [PATCH] fix: Always add public key to constructor if possible, Fix for undefined pubKey in remote peers (#68) * Always add public key to constructor if possible * extending Non-default # of bits test time, travis took 59521ms License: MIT Signed-off-by: Yahya --- src/index.js | 2 +- test/peer-id.spec.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/index.js b/src/index.js index 6722518..e8b6a00 100644 --- a/src/index.js +++ b/src/index.js @@ -202,7 +202,7 @@ exports.createFromPrivKey = function (key, callback) { return callback(err) } - callback(null, new PeerId(digest, privKey)) + callback(null, new PeerId(digest, privKey, privKey.public)) }) } diff --git a/test/peer-id.spec.js b/test/peer-id.spec.js index a7f0eac..4fbff6f 100644 --- a/test/peer-id.spec.js +++ b/test/peer-id.spec.js @@ -85,6 +85,7 @@ describe('PeerId', () => { PeerId.createFromPrivKey(encoded, (err, id2) => { expect(err).to.not.exist() expect(testIdB58String).to.equal(id2.toB58String()) + expect(id.marshalPubKey()).to.deep.equal(id2.marshalPubKey()) done() }) }) @@ -104,7 +105,7 @@ describe('PeerId', () => { it('Non-default # of bits', function (done) { // rsa is slow atm - this.timeout(20000) + this.timeout(100000) PeerId.create({ bits: 1024 }, (err, shortId) => { expect(err).to.not.exist() PeerId.create({ bits: 4096 }, (err, longId) => {