Skip to content
This repository has been archived by the owner on Jun 26, 2023. It is now read-only.

Commit

Permalink
chore: apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-Authored-By: Jacob Heun <[email protected]>
  • Loading branch information
vasco-santos and jacobheun committed Apr 16, 2020
1 parent 12f11c8 commit 170c2fd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 13 deletions.
8 changes: 4 additions & 4 deletions src/peer-discovery/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ It returns a `Promise`

### discoverying peers

- `discovery.on('peer', (peerInfo) => {})`
- `discovery.on('peer', (peerData) => {})`

Everytime a peer is discovered by a discovery service, it emmits a `peer` event with the discovered peer's information, which must contain the following properties:
Every time a peer is discovered by a discovery service, it emits a `peer` event with the discovered peer's information, which must contain the following properties:

- `<`[`PeerId`](https://github.com/libp2p/js-peer-id)`>` `peerInfo.id`
- `<Array<`[`Multiaddr`](https://github.com/multiformats/js-multiaddr)`>>` `peerInfo.multiaddrs`
- `<`[`PeerId`](https://github.com/libp2p/js-peer-id)`>` `peerData.id`
- `<Array<`[`Multiaddr`](https://github.com/multiformats/js-multiaddr)`>>` `peerData.multiaddrs`
8 changes: 4 additions & 4 deletions src/peer-discovery/tests/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ module.exports = (common) => {
discovery = await common.setup()
})

after(() => common.teardown && common.teardown())

afterEach('ensure discovery was stopped', async () => {
await discovery.stop()

discovery.removeAllListeners()

common.teardown && common.teardown()
})

it('can start the service', async () => {
Expand All @@ -45,7 +45,7 @@ module.exports = (common) => {
await discovery.start()
})

it('should listen a peer event after start', async () => {
it('should emit a peer event after start', async () => {
const defer = pDefer()
await discovery.start()

Expand All @@ -59,7 +59,7 @@ module.exports = (common) => {
defer.resolve()
})

return defer.promise
await defer.promise
})

it('should not receive a peer event before start', async () => {
Expand Down
7 changes: 2 additions & 5 deletions test/peer-discovery/compliance.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ describe('compliance tests', () => {
let intervalId

tests({
async setup () {
await new Promise(resolve => setTimeout(resolve, 10))

setup () {
const mockDiscovery = new MockDiscovery({
discoveryDelay: 1
})
Expand All @@ -19,9 +17,8 @@ describe('compliance tests', () => {

return mockDiscovery
},
async teardown () {
teardown () {
clearInterval(intervalId)
await new Promise(resolve => setTimeout(resolve, 10))
}
})
})

0 comments on commit 170c2fd

Please sign in to comment.