From 6627278a87db2659a90ef73fa7178d306f9fcf1d Mon Sep 17 00:00:00 2001 From: Vasco Santos Date: Thu, 7 May 2020 15:49:03 +0200 Subject: [PATCH] chore: apply suggestions from code review Co-authored-by: Jacob Heun --- src/peer-store/persistent/index.js | 2 +- test/peer-store/key-book.spec.js | 4 ++-- test/peer-store/peer-store.node.js | 2 ++ 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/peer-store/persistent/index.js b/src/peer-store/persistent/index.js index 8e7c459fb8..366e9bc48f 100644 --- a/src/peer-store/persistent/index.js +++ b/src/peer-store/persistent/index.js @@ -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) diff --git a/test/peer-store/key-book.spec.js b/test/peer-store/key-book.spec.js index c5eab517a5..22b708fbf2 100644 --- a/test/peer-store/key-book.spec.js +++ b/test/peer-store/key-book.spec.js @@ -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) { diff --git a/test/peer-store/peer-store.node.js b/test/peer-store/peer-store.node.js index 30c2230eb8..c6b34eb541 100644 --- a/test/peer-store/peer-store.node.js +++ b/test/peer-store/peer-store.node.js @@ -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)