Skip to content
This repository was archived by the owner on Feb 12, 2024. It is now read-only.

Commit bd264f2

Browse files
authoredNov 20, 2017
test: all pubsub tests passing (#1094)
* all pubsub tests passing * config.replace is not supported anymore
1 parent b98739f commit bd264f2

File tree

5 files changed

+21
-27
lines changed

5 files changed

+21
-27
lines changed
 

‎package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
"form-data": "^2.3.1",
7777
"gulp": "^3.9.1",
7878
"hat": "0.0.3",
79-
"interface-ipfs-core": "~0.36.6",
79+
"interface-ipfs-core": "~0.36.7",
8080
"ipfsd-ctl": "~0.24.1",
8181
"left-pad": "^1.2.0",
8282
"lodash": "^4.17.4",
@@ -121,7 +121,7 @@
121121
"joi": "^13.0.2",
122122
"libp2p": "~0.13.1",
123123
"libp2p-circuit": "~0.1.4",
124-
"libp2p-floodsub": "~0.11.1",
124+
"libp2p-floodsub": "~0.12.1",
125125
"libp2p-kad-dht": "~0.6.0",
126126
"libp2p-mdns": "~0.9.1",
127127
"libp2p-multiplex": "~0.5.0",

‎src/core/components/pubsub.js

+16-22
Original file line numberDiff line numberDiff line change
@@ -18,27 +18,34 @@ module.exports = function pubsub (self) {
1818
options = {}
1919
}
2020

21+
function subscribe (cb) {
22+
if (self._pubsub.listenerCount(topic) === 0) {
23+
self._pubsub.subscribe(topic)
24+
}
25+
26+
self._pubsub.on(topic, handler)
27+
setImmediate(() => callback())
Has a conversation. Original line has a conversation.
28+
}
29+
2130
if (!callback) {
2231
return new Promise((resolve, reject) => {
23-
subscribe(topic, options, handler, (err) => {
32+
subscribe((err) => {
2433
if (err) {
2534
return reject(err)
2635
}
2736
resolve()
2837
})
2938
})
39+
} else {
40+
subscribe(callback)
3041
}
31-
32-
subscribe(topic, options, handler, callback)
3342
},
3443

3544
unsubscribe: (topic, handler) => {
36-
const ps = self._pubsub
37-
38-
ps.removeListener(topic, handler)
45+
self._pubsub.removeListener(topic, handler)
3946

40-
if (ps.listenerCount(topic) === 0) {
41-
ps.unsubscribe(topic)
47+
if (self._pubsub.listenerCount(topic) === 0) {
48+
self._pubsub.unsubscribe(topic)
4249
}
4350
},
4451

@@ -60,9 +67,7 @@ module.exports = function pubsub (self) {
6067
return setImmediate(() => callback(new Error(OFFLINE_ERROR)))
6168
}
6269

63-
const subscriptions = Array.from(
64-
self._pubsub.subscriptions
65-
)
70+
const subscriptions = Array.from(self._pubsub.subscriptions)
6671

6772
setImmediate(() => callback(null, subscriptions))
6873
}),
@@ -83,15 +88,4 @@ module.exports = function pubsub (self) {
8388
return self._pubsub.setMaxListeners(n)
8489
}
8590
}
86-
87-
function subscribe (topic, options, handler, callback) {
88-
const ps = self._pubsub
89-
90-
if (ps.listenerCount(topic) === 0) {
91-
ps.subscribe(topic)
92-
}
93-
94-
ps.on(topic, handler)
95-
setImmediate(() => callback())
96-
}
9791
}

‎test/cli/config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ describe('config', () => runOnAndOff((thing) => {
7272
})
7373
})
7474

75-
describe('replace', () => {
75+
describe.skip('replace', () => {
7676
it('replace config with file', () => {
7777
const filePath = 'test/fixtures/test-data/otherconfig'
7878
const expectedConfig = JSON.parse(fs.readFileSync(filePath, 'utf8'))

‎test/http-api/over-ipfs-api/config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ module.exports = (ctl) => {
7272

7373
// This one is one stale mode till go-ipfs decides
7474
// what to do with the .replace command
75-
describe('.replace', () => {
75+
describe.skip('.replace', () => {
7676
it('returns error if the config is invalid', (done) => {
7777
const filePath = 'test/fixtures/test-data/badconfig'
7878

‎test/http-api/spec/config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ module.exports = (http) => {
153153
})
154154
})
155155

156-
describe('/config/replace', () => {
156+
describe.skip('/config/replace', () => {
157157
it('returns 400 if no config is provided', (done) => {
158158
const form = new FormData()
159159
const headers = form.getHeaders()

0 commit comments

Comments
 (0)
This repository has been archived.