chore: apply suggestions from code review

Co-authored-by: Jacob Heun <jacobheun@gmail.com>
This commit is contained in:
Vasco Santos 2020-05-07 15:49:03 +02:00 committed by Jacob Heun
parent 65e87460b0
commit 6627278a87
3 changed files with 5 additions and 3 deletions

View File

@ -112,7 +112,7 @@ class PersistentPeerStore extends PeerStore {
const batch = this._datastore.batch()
for (const peerIdStr of commitPeers) {
// PeerId
const peerId = this.keyBook.data.get(peerIdStr) || PeerId.createFromB58String(peerIdStr)
const peerId = this.keyBook.data.get(peerIdStr) || PeerId.createFromCID(peerIdStr)
// Address Book
this._batchAddressBook(peerId, batch)

View File

@ -23,7 +23,7 @@ describe('keyBook', () => {
kb = peerStore.keyBook
})
it('throwns invalid parameters error if invalid PeerId is provided in set', () => {
it('throws invalid parameters error if invalid PeerId is provided in set', () => {
try {
kb.set('invalid peerId')
} catch (err) {
@ -33,7 +33,7 @@ describe('keyBook', () => {
throw new Error('invalid peerId should throw error')
})
it('throwns invalid parameters error if invalid PeerId is provided in get', () => {
it('throws invalid parameters error if invalid PeerId is provided in get', () => {
try {
kb.get('invalid peerId')
} catch (err) {

View File

@ -39,6 +39,8 @@ describe('libp2p.peerStore', () => {
const localPeers = libp2p.peerStore.peers
expect(localPeers.size).to.equal(1)
// TODO: needs https://github.com/NodeFactoryIo/js-libp2p-noise/issues/58
// const publicKeyInLocalPeer = localPeers.get(remoteIdStr).id.pubKey
// expect(publicKeyInLocalPeer.bytes).to.equalBytes(remoteLibp2p.peerId.pubKey.bytes)