mirror of
https://github.com/fluencelabs/js-peer-id
synced 2025-06-30 13:01:48 +00:00
feat: create b58 string on creation and throw on id mutation
This commit is contained in:
@ -29,6 +29,17 @@ describe('PeerId', () => {
|
||||
})
|
||||
})
|
||||
|
||||
it('throws on changing the id', (done) => {
|
||||
PeerId.create((err, id) => {
|
||||
expect(err).to.not.exist
|
||||
expect(id.toB58String().length).to.equal(46)
|
||||
expect(() => {
|
||||
id.id = new Buffer('hello')
|
||||
}).to.throw(/immutable/)
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
it('recreate an Id from Hex string', () => {
|
||||
const id = PeerId.createFromHexString(testIdHex)
|
||||
expect(testIdBytes).to.deep.equal(id.id)
|
||||
|
Reference in New Issue
Block a user