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 authored Nov 4, 2019
1 parent 3468fca commit 170ead1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
5 changes: 2 additions & 3 deletions src/peer-store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ class PeerStore extends EventEmitter {

/**
* Updates an already known peer.
* If already exist, updates ids info if outdated.
* @param {PeerInfo} peerInfo
*/
update (peerInfo) {
Expand Down Expand Up @@ -131,7 +130,7 @@ class PeerStore extends EventEmitter {
}

/**
* Remove the info of the peer with the given id.
* Removes the Peer with the matching `peerId` from the PeerStore
* @param {string} peerId b58str id
* @returns {boolean} true if found and removed
*/
Expand All @@ -140,7 +139,7 @@ class PeerStore extends EventEmitter {
}

/**
* Replace the info stored of the given peer.
* Completely replaces the existing peers metadata with the given `peerInfo`
* @param {PeerInfo} peerInfo
* @returns {void}
*/
Expand Down
5 changes: 3 additions & 2 deletions test/peer-store/peer-store.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ describe('peer-store', () => {
peerStore.on('change:multiaddrs', () => {
throw new Error('should not emit change:multiaddrs')
})
// When updating, "change:protocols" event must not be emitted
// When updating, "change:protocols" event must be emitted
peerStore.on('change:protocols', ({ peerInfo, protocols }) => {
expect(peerInfo).to.exist()
expect(protocols).to.exist()
Expand Down Expand Up @@ -152,10 +152,11 @@ describe('peer-store', () => {
// Put the peer in the store
peerStore.put(peerInfo)

const peers = peerStore.getAllArray()
const peers = peerStore.peers.size
expect(peers).to.have.lengthOf(1)

removed = peerStore.remove(id)
expect(removed).to.eql(true)
expect(peerStore.peers.size).to.equal(0)
})
})

0 comments on commit 170ead1

Please sign in to comment.