add toJSON and fromJSOn and cli to quickly generate

This commit is contained in:
David Dias
2016-05-23 15:25:30 +01:00
parent 4afbedb525
commit b358530dfb
4 changed files with 40 additions and 9 deletions

View File

@ -93,4 +93,12 @@ describe('id', function (done) {
expect(id.toBytes().toString('hex')).to.equal(testIdBytes.toString('hex'))
done()
})
it('toJSON', (done) => {
const id = PeerId.create()
expect(id.toB58String()).to.equal(PeerId.createFromJSON(id.toJSON()).toB58String())
expect(id.privKey).to.deep.equal(PeerId.createFromJSON(id.toJSON()).privKey)
expect(id.pubKey).to.deep.equal(PeerId.createFromJSON(id.toJSON()).pubKey)
done()
})
})