Skip to content

Commit

Permalink
chore: apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Jacob Heun <jacobheun@gmail.com>
  • Loading branch information
vasco-santos and jacobheun committed May 7, 2020
1 parent d21a138 commit 9eaed58
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/peer-store/persistent/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions test/peer-store/key-book.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down
2 changes: 2 additions & 0 deletions test/peer-store/peer-store.node.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 9eaed58

Please sign in to comment.