chore: apply suggestions from code review

Co-Authored-By: Jacob Heun <jacobheun@gmail.com>
This commit is contained in:
Vasco Santos 2020-04-16 11:27:23 +02:00 committed by Jacob Heun
parent 12f11c88e2
commit 170c2fd46e
3 changed files with 10 additions and 13 deletions

View File

@ -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`

View File

@ -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 () => {
@ -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()
@ -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 () => {

View File

@ -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
})
@ -19,9 +17,8 @@ describe('compliance tests', () => {
return mockDiscovery
},
async teardown () {
teardown () {
clearInterval(intervalId)
await new Promise(resolve => setTimeout(resolve, 10))
}
})
})