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

Commit

Permalink
feat(bitswap tests, config, id): cope with the nuances of the config …
Browse files Browse the repository at this point in the history
…API (.replace) and make necessary changes to make it all work again
  • Loading branch information
daviddias committed Aug 20, 2016
1 parent 97af048 commit cc0c8fd
Show file tree
Hide file tree
Showing 14 changed files with 111 additions and 96 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"fs-blob-store": "^5.2.1",
"glob": "^7.0.5",
"hapi": "^14.0.0",
"ipfs-api": "ipfs/js-ipfs-api#8cc853f",
"ipfs-api": "^7.0.0",
"ipfs-bitswap": "^0.6.0",
"ipfs-block": "^0.3.0",
"ipfs-block-service": "^0.4.0",
Expand Down
1 change: 1 addition & 0 deletions src/core/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ function IPFS (repoInstance) {
this.block = block(this)
this.object = object(this)
this.libp2p = libp2p(this)
this.swarm = this.libp2p.swarm // for interface-ipfs-core sake
this.files = files(this)
this.cat = files(this).cat // Alias for js-ipfs-api cat
this.bitswap = bitswap(this)
Expand Down
10 changes: 5 additions & 5 deletions src/core/ipfs/id.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ module.exports = function id (self) {

function ready () {
callback(null, {
ID: self._peerInfo.id.toB58String(),
PublicKey: self._peerInfo.id.pubKey.bytes.toString('base64'),
Addresses: self._peerInfo.multiaddrs.map((ma) => { return ma.toString() }).sort(),
AgentVersion: 'js-ipfs',
ProtocolVersion: '9000'
id: self._peerInfo.id.toB58String(),
publicKey: self._peerInfo.id.pubKey.bytes.toString('base64'),
addresses: self._peerInfo.multiaddrs.map((ma) => { return ma.toString() }).sort(),
agentVersion: 'js-ipfs',
protocolVersion: '9000'
})
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/http-api/resources/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ exports.getOrSet = {
}
}

exports.show = (request, reply) => {
exports.get = (request, reply) => {
return request.server.app.ipfs.config.get((err, config) => {
if (err) {
log.error(err)
Expand Down
13 changes: 11 additions & 2 deletions src/http-api/resources/id.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,16 @@ exports = module.exports

exports.get = (request, reply) => {
request.server.app.ipfs.id((err, id) => {
if (err) { return reply(boom.badRequest(err)) }
return reply(id)
if (err) {
return reply(boom.badRequest(err))
}

return reply({
ID: id.id,
PublicKey: id.publicKey,
Addresses: id.addresses,
AgentVersion: id.agentVersion,
ProtocolVersion: id.protocolVersion
})
})
}
8 changes: 4 additions & 4 deletions src/http-api/routes/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ module.exports = (server) => {

// https://github.com/ipfs/http-api-spec/blob/master/apiary.apib#L818
api.route({
method: 'GET',
method: '*',
path: '/api/v0/bootstrap',
handler: resources.bootstrap.list
})

// https://github.com/ipfs/http-api-spec/blob/master/apiary.apib#L866
api.route({
method: 'GET',
method: '*',
path: '/api/v0/bootstrap/add',
handler: resources.bootstrap.add,
config: {
Expand All @@ -30,14 +30,14 @@ module.exports = (server) => {

// https://github.com/ipfs/http-api-spec/blob/master/apiary.apib#L1081
api.route({
method: 'GET',
method: '*',
path: '/api/v0/bootstrap/list',
handler: resources.bootstrap.list
})

// https://github.com/ipfs/http-api-spec/blob/master/apiary.apib#L1131
api.route({
method: 'GET',
method: '*',
path: '/api/v0/bootstrap/rm',
handler: resources.bootstrap.rm,
config: {
Expand Down
2 changes: 1 addition & 1 deletion src/http-api/routes/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module.exports = (server) => {
api.route({
method: '*',
path: '/api/v0/config/show',
handler: resources.config.show
handler: resources.config.get
})

api.route({
Expand Down
2 changes: 1 addition & 1 deletion src/http-api/routes/id.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module.exports = (server) => {
const api = server.select('API')

api.route({
method: 'GET',
method: '*',
path: '/api/v0/id',
handler: resources.id.get
})
Expand Down
2 changes: 1 addition & 1 deletion src/http-api/routes/repo.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module.exports = (server) => {
const api = server.select('API')

api.route({
method: 'GET',
method: '*',
path: '/api/v0/repo',
handler: resources.repo
})
Expand Down
12 changes: 6 additions & 6 deletions src/http-api/routes/swarm.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,31 @@ module.exports = (server) => {
const api = server.select('API')

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

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

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

api.route({
method: 'GET',
method: '*',
path: '/api/v0/swarm/connect',
config: {
pre: [
Expand All @@ -41,7 +41,7 @@ module.exports = (server) => {
})

// api.route({
// method: 'GET',
// method: '*',
// path: '/api/v0/swarm/disconnect',
// config: {
// handler: resources.swarm.disconnect
Expand All @@ -50,7 +50,7 @@ module.exports = (server) => {

// TODO
// api.route({
// method: 'GET',
// method: '*',
// path: '/api/v0/swarm/filters',
// config: {
// handler: resources.swarm.disconnect
Expand Down
2 changes: 1 addition & 1 deletion src/http-api/routes/version.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module.exports = (server) => {
const api = server.select('API')

api.route({
method: 'GET',
method: '*',
path: '/api/v0/version',
handler: resources.version.get
})
Expand Down
Loading

0 comments on commit cc0c8fd

Please sign in to comment.