From 170c2fd46ea702001ce94ffb1ab6c126c3131088 Mon Sep 17 00:00:00 2001 From: Vasco Santos Date: Thu, 16 Apr 2020 11:27:23 +0200 Subject: [PATCH] chore: apply suggestions from code review Co-Authored-By: Jacob Heun --- src/peer-discovery/README.md | 8 ++++---- src/peer-discovery/tests/index.js | 8 ++++---- test/peer-discovery/compliance.spec.js | 7 ++----- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/peer-discovery/README.md b/src/peer-discovery/README.md index a0551d0c1..f66b0ba7c 100644 --- a/src/peer-discovery/README.md +++ b/src/peer-discovery/README.md @@ -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` -- `>` `peerInfo.multiaddrs` +- `<`[`PeerId`](https://github.com/libp2p/js-peer-id)`>` `peerData.id` +- `>` `peerData.multiaddrs` diff --git a/src/peer-discovery/tests/index.js b/src/peer-discovery/tests/index.js index a9b41da33..bdcda8091 100644 --- a/src/peer-discovery/tests/index.js +++ b/src/peer-discovery/tests/index.js @@ -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 () => { diff --git a/test/peer-discovery/compliance.spec.js b/test/peer-discovery/compliance.spec.js index 6b3568171..7ab0d6ddd 100644 --- a/test/peer-discovery/compliance.spec.js +++ b/test/peer-discovery/compliance.spec.js @@ -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)) } }) })