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 <ya7yaz@gmail.com>
This commit is contained in:
Yahya
2017-10-12 11:09:18 +03:00
committed by David Dias
parent 7d3cb8e87c
commit 3abdcdabbb
2 changed files with 3 additions and 2 deletions

View File

@ -202,7 +202,7 @@ exports.createFromPrivKey = function (key, callback) {
return callback(err) return callback(err)
} }
callback(null, new PeerId(digest, privKey)) callback(null, new PeerId(digest, privKey, privKey.public))
}) })
} }

View File

@ -85,6 +85,7 @@ describe('PeerId', () => {
PeerId.createFromPrivKey(encoded, (err, id2) => { PeerId.createFromPrivKey(encoded, (err, id2) => {
expect(err).to.not.exist() expect(err).to.not.exist()
expect(testIdB58String).to.equal(id2.toB58String()) expect(testIdB58String).to.equal(id2.toB58String())
expect(id.marshalPubKey()).to.deep.equal(id2.marshalPubKey())
done() done()
}) })
}) })
@ -104,7 +105,7 @@ describe('PeerId', () => {
it('Non-default # of bits', function (done) { it('Non-default # of bits', function (done) {
// rsa is slow atm // rsa is slow atm
this.timeout(20000) this.timeout(100000)
PeerId.create({ bits: 1024 }, (err, shortId) => { PeerId.create({ bits: 1024 }, (err, shortId) => {
expect(err).to.not.exist() expect(err).to.not.exist()
PeerId.create({ bits: 4096 }, (err, longId) => { PeerId.create({ bits: 4096 }, (err, longId) => {