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

Commit 4058898

Browse files
committed
chore: remove unnecessary describe block
License: MIT Signed-off-by: Alan Shaw <[email protected]>
1 parent db77877 commit 4058898

File tree

1 file changed

+77
-79
lines changed

1 file changed

+77
-79
lines changed

js/src/pubsub/peers.js

Lines changed: 77 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -52,99 +52,97 @@ module.exports = (createCommon, options) => {
5252
], done)
5353
})
5454

55-
describe('.peers', () => {
56-
it('should not error when not subscribed to a topic', (done) => {
57-
const topic = getTopic()
58-
ipfs1.pubsub.peers(topic, (err, peers) => {
59-
expect(err).to.not.exist()
60-
// Should be empty() but as mentioned below go-ipfs returns more than it should
61-
// expect(peers).to.be.empty()
62-
63-
done()
64-
})
55+
it('should not error when not subscribed to a topic', (done) => {
56+
const topic = getTopic()
57+
ipfs1.pubsub.peers(topic, (err, peers) => {
58+
expect(err).to.not.exist()
59+
// Should be empty() but as mentioned below go-ipfs returns more than it should
60+
// expect(peers).to.be.empty()
61+
62+
done()
6563
})
64+
})
6665

67-
it('should not return extra peers', (done) => {
68-
// Currently go-ipfs returns peers that have not been
69-
// subscribed to the topic. Enable when go-ipfs has been fixed
70-
const sub1 = (msg) => {}
71-
const sub2 = (msg) => {}
72-
const sub3 = (msg) => {}
73-
74-
const topic = getTopic()
75-
const topicOther = topic + 'different topic'
76-
77-
parallel([
78-
(cb) => ipfs1.pubsub.subscribe(topic, sub1, cb),
79-
(cb) => ipfs2.pubsub.subscribe(topicOther, sub2, cb),
80-
(cb) => ipfs3.pubsub.subscribe(topicOther, sub3, cb)
81-
], (err) => {
82-
expect(err).to.not.exist()
66+
it('should not return extra peers', (done) => {
67+
// Currently go-ipfs returns peers that have not been
68+
// subscribed to the topic. Enable when go-ipfs has been fixed
69+
const sub1 = (msg) => {}
70+
const sub2 = (msg) => {}
71+
const sub3 = (msg) => {}
8372

84-
ipfs1.pubsub.peers(topic, (err, peers) => {
85-
expect(err).to.not.exist()
86-
expect(peers).to.be.empty()
73+
const topic = getTopic()
74+
const topicOther = topic + 'different topic'
8775

88-
parallel([
89-
(cb) => ipfs1.pubsub.unsubscribe(topic, sub1, cb),
90-
(cb) => ipfs2.pubsub.unsubscribe(topicOther, sub2, cb),
91-
(cb) => ipfs3.pubsub.unsubscribe(topicOther, sub3, cb)
92-
], done)
93-
})
94-
})
95-
})
76+
parallel([
77+
(cb) => ipfs1.pubsub.subscribe(topic, sub1, cb),
78+
(cb) => ipfs2.pubsub.subscribe(topicOther, sub2, cb),
79+
(cb) => ipfs3.pubsub.subscribe(topicOther, sub3, cb)
80+
], (err) => {
81+
expect(err).to.not.exist()
9682

97-
it('should return peers for a topic - one peer', (done) => {
98-
// Currently go-ipfs returns peers that have not been
99-
// subscribed to the topic. Enable when go-ipfs has been fixed
100-
const sub1 = (msg) => {}
101-
const sub2 = (msg) => {}
102-
const sub3 = (msg) => {}
103-
const topic = getTopic()
104-
105-
auto({
106-
sub1: (cb) => ipfs1.pubsub.subscribe(topic, sub1, cb),
107-
sub2: (cb) => ipfs2.pubsub.subscribe(topic, sub2, cb),
108-
sub3: (cb) => ipfs3.pubsub.subscribe(topic, sub3, cb),
109-
peers: ['sub1', 'sub2', 'sub3', (_, cb) => {
110-
waitForPeers(ipfs1, topic, [ipfs2.peerId.id], cb)
111-
}]
112-
}, (err) => {
83+
ipfs1.pubsub.peers(topic, (err, peers) => {
11384
expect(err).to.not.exist()
85+
expect(peers).to.be.empty()
11486

11587
parallel([
11688
(cb) => ipfs1.pubsub.unsubscribe(topic, sub1, cb),
117-
(cb) => ipfs2.pubsub.unsubscribe(topic, sub2, cb),
118-
(cb) => ipfs3.pubsub.unsubscribe(topic, sub3, cb)
89+
(cb) => ipfs2.pubsub.unsubscribe(topicOther, sub2, cb),
90+
(cb) => ipfs3.pubsub.unsubscribe(topicOther, sub3, cb)
11991
], done)
12092
})
12193
})
94+
})
12295

123-
it('should return peers for a topic - multiple peers', (done) => {
124-
const sub1 = (msg) => {}
125-
const sub2 = (msg) => {}
126-
const sub3 = (msg) => {}
127-
const topic = getTopic()
128-
129-
auto({
130-
sub1: (cb) => ipfs1.pubsub.subscribe(topic, sub1, cb),
131-
sub2: (cb) => ipfs2.pubsub.subscribe(topic, sub2, cb),
132-
sub3: (cb) => ipfs3.pubsub.subscribe(topic, sub3, cb),
133-
peers: ['sub1', 'sub2', 'sub3', (_, cb) => {
134-
waitForPeers(ipfs1, topic, [
135-
ipfs2.peerId.id,
136-
ipfs3.peerId.id
137-
], cb)
138-
}]
139-
}, (err) => {
140-
expect(err).to.not.exist()
96+
it('should return peers for a topic - one peer', (done) => {
97+
// Currently go-ipfs returns peers that have not been
98+
// subscribed to the topic. Enable when go-ipfs has been fixed
99+
const sub1 = (msg) => {}
100+
const sub2 = (msg) => {}
101+
const sub3 = (msg) => {}
102+
const topic = getTopic()
103+
104+
auto({
105+
sub1: (cb) => ipfs1.pubsub.subscribe(topic, sub1, cb),
106+
sub2: (cb) => ipfs2.pubsub.subscribe(topic, sub2, cb),
107+
sub3: (cb) => ipfs3.pubsub.subscribe(topic, sub3, cb),
108+
peers: ['sub1', 'sub2', 'sub3', (_, cb) => {
109+
waitForPeers(ipfs1, topic, [ipfs2.peerId.id], cb)
110+
}]
111+
}, (err) => {
112+
expect(err).to.not.exist()
141113

142-
parallel([
143-
(cb) => ipfs1.pubsub.unsubscribe(topic, sub1, cb),
144-
(cb) => ipfs2.pubsub.unsubscribe(topic, sub2, cb),
145-
(cb) => ipfs3.pubsub.unsubscribe(topic, sub3, cb)
146-
], done)
147-
})
114+
parallel([
115+
(cb) => ipfs1.pubsub.unsubscribe(topic, sub1, cb),
116+
(cb) => ipfs2.pubsub.unsubscribe(topic, sub2, cb),
117+
(cb) => ipfs3.pubsub.unsubscribe(topic, sub3, cb)
118+
], done)
119+
})
120+
})
121+
122+
it('should return peers for a topic - multiple peers', (done) => {
123+
const sub1 = (msg) => {}
124+
const sub2 = (msg) => {}
125+
const sub3 = (msg) => {}
126+
const topic = getTopic()
127+
128+
auto({
129+
sub1: (cb) => ipfs1.pubsub.subscribe(topic, sub1, cb),
130+
sub2: (cb) => ipfs2.pubsub.subscribe(topic, sub2, cb),
131+
sub3: (cb) => ipfs3.pubsub.subscribe(topic, sub3, cb),
132+
peers: ['sub1', 'sub2', 'sub3', (_, cb) => {
133+
waitForPeers(ipfs1, topic, [
134+
ipfs2.peerId.id,
135+
ipfs3.peerId.id
136+
], cb)
137+
}]
138+
}, (err) => {
139+
expect(err).to.not.exist()
140+
141+
parallel([
142+
(cb) => ipfs1.pubsub.unsubscribe(topic, sub1, cb),
143+
(cb) => ipfs2.pubsub.unsubscribe(topic, sub2, cb),
144+
(cb) => ipfs3.pubsub.unsubscribe(topic, sub3, cb)
145+
], done)
148146
})
149147
})
150148
})

0 commit comments

Comments
 (0)