mirror of
https://github.com/fluencelabs/js-peer-id
synced 2025-04-25 06:42:25 +00:00
comparing buffers
This commit is contained in:
parent
f55eebcef7
commit
ca9cef6de7
@ -109,9 +109,13 @@ exports.create = function () {
|
||||
const protoPublic64 = formatKey(asnPub, 'Public')
|
||||
const protoPrivate64 = formatKey(asnPriv, 'Private')
|
||||
|
||||
// store the keys as a buffer
|
||||
const bufProtoPub64 = new Buffer(protoPublic64, 'base64')
|
||||
const bufProtoPriv64 = new Buffer(protoPrivate64, 'base64')
|
||||
|
||||
const mhId = multihashing(new Buffer(protoPublic64, 'base64'), 'sha2-256')
|
||||
|
||||
return new Id(mhId, protoPrivate64, protoPublic64)
|
||||
return new Id(mhId, bufProtoPriv64, bufProtoPub64)
|
||||
}
|
||||
|
||||
exports.createFromHexString = function (str) {
|
||||
|
@ -55,5 +55,12 @@ describe('id', function (done) {
|
||||
expect(testIdB58String).to.equal(id.toB58String())
|
||||
done()
|
||||
})
|
||||
|
||||
it('Compare generated ID with one created from PubKey', (done) => {
|
||||
const id1 = PeerId.create()
|
||||
const id2 = PeerId.createFromPubKey(id1.pubKey)
|
||||
expect(id2.id).to.deep.equal(id1.id)
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user