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

Commit

Permalink
jsipfs swarm
Browse files Browse the repository at this point in the history
libp2p start and stop

not fail on browser tests. separate browser and node.js swarm tests
  • Loading branch information
daviddias committed Apr 17, 2016
1 parent 6f2d879 commit 7143942
Show file tree
Hide file tree
Showing 12 changed files with 158 additions and 7 deletions.
21 changes: 21 additions & 0 deletions src/cli/commands/swarm/addrs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const Command = require('ronin').Command
const utils = require('../../utils')
const bs58 = require('bs58')
const debug = require('debug')
const log = debug('cli:object')
log.error = debug('cli:object:error')

module.exports = Command.extend({
desc: '',

options: {},

run: () => {
utils.getIPFS((err, ipfs) => {
if (err) {
throw err
}
// TODO
})
}
})
21 changes: 21 additions & 0 deletions src/cli/commands/swarm/addrs/local.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const Command = require('ronin').Command
const utils = require('../../../utils')
const bs58 = require('bs58')
const debug = require('debug')
const log = debug('cli:object')
log.error = debug('cli:object:error')

module.exports = Command.extend({
desc: '',

options: {},

run: () => {
utils.getIPFS((err, ipfs) => {
if (err) {
throw err
}
// TODO
})
}
})
21 changes: 21 additions & 0 deletions src/cli/commands/swarm/connect.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const Command = require('ronin').Command
const utils = require('../../utils')
const bs58 = require('bs58')
const debug = require('debug')
const log = debug('cli:object')
log.error = debug('cli:object:error')

module.exports = Command.extend({
desc: '',

options: {},

run: () => {
utils.getIPFS((err, ipfs) => {
if (err) {
throw err
}
// TODO
})
}
})
21 changes: 21 additions & 0 deletions src/cli/commands/swarm/disconnect.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const Command = require('ronin').Command
const utils = require('../../utils')
const bs58 = require('bs58')
const debug = require('debug')
const log = debug('cli:object')
log.error = debug('cli:object:error')

module.exports = Command.extend({
desc: '',

options: {},

run: () => {
utils.getIPFS((err, ipfs) => {
if (err) {
throw err
}
// TODO
})
}
})
21 changes: 21 additions & 0 deletions src/cli/commands/swarm/peers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const Command = require('ronin').Command
const utils = require('../../utils')
const bs58 = require('bs58')
const debug = require('debug')
const log = debug('cli:object')
log.error = debug('cli:object:error')

module.exports = Command.extend({
desc: '',

options: {},

run: () => {
utils.getIPFS((err, ipfs) => {
if (err) {
throw err
}
// TODO
})
}
})
8 changes: 6 additions & 2 deletions src/core/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -323,11 +323,15 @@ function IPFS (repo) {
libp2pNode.swarm.close(callback)
},
swarm: {
peers: () => {},
peers: (callback) => {
callback(null, [])
},
// all the addrs we know
addrs: notImpl,
localAddrs: notImpl,
connect: notImpl,
disconnect: notImpl,
filters: notImpl
filters: notImpl // TODO
},
routing: {},
records: {},
Expand Down
46 changes: 46 additions & 0 deletions src/http-api/routes/swarm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
const resources = require('./../resources')

module.exports = (server) => {
const api = server.select('API')

api.route({
method: 'GET',
path: '/api/v0/swarm/addrs',
config: {
handler: resources.swarm.addrs.handler
}
})

api.route({
method: 'GET',
path: '/api/v0/swarm/addrs/local',
config: {
handler: resources.swarm.localAddrs.handler
}
})

api.route({
method: 'GET',
path: '/api/v0/swarm/connect',
config: {
handler: resources.swarm.connect
}
})

api.route({
method: 'GET',
path: '/api/v0/swarm/disconnect',
config: {
handler: resources.swarm.disconnect
}
})

// TODO
// api.route({
// method: 'GET',
// path: '/api/v0/swarm/filters',
// config: {
// handler: resources.swarm.disconnect
// }
// })
}
2 changes: 1 addition & 1 deletion test/cli-tests/test-commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ describe('commands', () => {
.run((err, stdout, exitcode) => {
expect(err).to.not.exist
expect(exitcode).to.equal(0)
expect(stdout.length).to.equal(40)
expect(stdout.length).to.equal(45)
done()
})
})
Expand Down
1 change: 0 additions & 1 deletion test/core-tests/test-bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

const expect = require('chai').expect

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

describe('bootstrap', () => {
Expand Down
1 change: 0 additions & 1 deletion test/core-tests/test-id.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

const expect = require('chai').expect

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

describe('id', () => {
Expand Down
1 change: 0 additions & 1 deletion test/core-tests/test-swarm-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

const expect = require('chai').expect

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

describe('swarm', () => {
Expand Down
1 change: 0 additions & 1 deletion test/core-tests/test-version.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

const expect = require('chai').expect

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

describe('version', () => {
Expand Down

0 comments on commit 7143942

Please sign in to comment.