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

Commit 82a6ea5

Browse files
committed
jsipfs swarm
libp2p start and stop not fail on browser tests. separate browser and node.js swarm tests
1 parent d7b6654 commit 82a6ea5

File tree

6 files changed

+52
-6
lines changed

6 files changed

+52
-6
lines changed

src/core/index.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -323,11 +323,15 @@ function IPFS (repo) {
323323
libp2pNode.swarm.close(callback)
324324
},
325325
swarm: {
326-
peers: () => {},
326+
peers: (callback) => {
327+
callback(null, [])
328+
},
329+
// all the addrs we know
327330
addrs: notImpl,
331+
localAddrs: notImpl,
328332
connect: notImpl,
329333
disconnect: notImpl,
330-
filters: notImpl
334+
filters: notImpl // TODO
331335
},
332336
routing: {},
333337
records: {},

src/http-api/routes/swarm.js

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
const resources = require('./../resources')
2+
3+
module.exports = (server) => {
4+
const api = server.select('API')
5+
6+
api.route({
7+
method: 'GET',
8+
path: '/api/v0/swarm/addrs',
9+
config: {
10+
handler: resources.swarm.addrs.handler
11+
}
12+
})
13+
14+
api.route({
15+
method: 'GET',
16+
path: '/api/v0/swarm/addrs/local',
17+
config: {
18+
handler: resources.swarm.localAddrs.handler
19+
}
20+
})
21+
22+
api.route({
23+
method: 'GET',
24+
path: '/api/v0/swarm/connect',
25+
config: {
26+
handler: resources.swarm.connect
27+
}
28+
})
29+
30+
api.route({
31+
method: 'GET',
32+
path: '/api/v0/swarm/disconnect',
33+
config: {
34+
handler: resources.swarm.disconnect
35+
}
36+
})
37+
38+
// TODO
39+
// api.route({
40+
// method: 'GET',
41+
// path: '/api/v0/swarm/filters',
42+
// config: {
43+
// handler: resources.swarm.disconnect
44+
// }
45+
// })
46+
}

test/core-tests/test-bootstrap.js

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
const expect = require('chai').expect
44

5-
process.env.IPFS_PATH = process.cwd() + '/tests/repo-example'
65
const IPFS = require('../../src/core')
76

87
describe('bootstrap', () => {

test/core-tests/test-id.js

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
const expect = require('chai').expect
44

5-
process.env.IPFS_PATH = process.cwd() + '/tests/repo-example'
65
const IPFS = require('../../src/core')
76

87
describe('id', () => {

test/core-tests/test-swarm-node.js

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
const expect = require('chai').expect
44

5-
process.env.IPFS_PATH = process.cwd() + '/tests/repo-example'
65
const IPFS = require('../../src/core')
76

87
describe('swarm', () => {

test/core-tests/test-version.js

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
const expect = require('chai').expect
44

5-
process.env.IPFS_PATH = process.cwd() + '/tests/repo-example'
65
const IPFS = require('../../src/core')
76

87
describe('version', () => {

0 commit comments

Comments
 (0)