Skip to content
This repository was archived by the owner on Mar 10, 2020. It is now read-only.

Fixes timeout ms arg being erroneously passed to pubsub.peers #196

Merged
merged 2 commits into from
Jan 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion SPEC/PUBSUB.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pubsub API
- `topic: string`
- `options: Object` - (Optional), might contain the following properties:
- `discover`: type: Boolean - Will use the DHT to find other peers.
- `handler: (msg) => ()` - Event handler which will be called with a message object everytime one is received. The `msg` has the format `{from: string, seqno: Buffer, data: Buffer, topicCIDs: Array<string>}`.
- `handler: (msg) => ()` - Event handler which will be called with a message object everytime one is received. The `msg` has the format `{from: string, seqno: Buffer, data: Buffer, topicIDs: Array<string>}`.
- `callback: (Error) => ()` (Optional) Called once the subscription is established.

If no `callback` is passed, a [promise][] is returned.
Expand Down
17 changes: 8 additions & 9 deletions src/pubsub.js
Original file line number Diff line number Diff line change
Expand Up @@ -298,16 +298,15 @@ module.exports = (common) => {
(cb) => ipfs3.pubsub.subscribe(topicOther, sub3, cb)
], (err) => {
expect(err).to.not.exist()
setTimeout(() => {
ipfs1.pubsub.peers(topic, (err, peers) => {
expect(err).to.not.exist()

expect(peers).to.be.empty()
ipfs1.pubsub.unsubscribe(topic, sub1)
ipfs2.pubsub.unsubscribe(topicOther, sub2)
ipfs3.pubsub.unsubscribe(topicOther, sub3)
done()
}, 10000)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

10000 is being passed to pubsub.peers not to setTimeout (which I believe is what was intended)

ipfs1.pubsub.peers(topic, (err, peers) => {
expect(err).to.not.exist()

expect(peers).to.be.empty()
ipfs1.pubsub.unsubscribe(topic, sub1)
ipfs2.pubsub.unsubscribe(topicOther, sub2)
ipfs3.pubsub.unsubscribe(topicOther, sub3)
done()
})
})
})
Expand Down