diff --git a/src/cli/commands/bitswap/stat.js b/src/cli/commands/bitswap/stat.js index 081dceb595..d7a26680f1 100644 --- a/src/cli/commands/bitswap/stat.js +++ b/src/cli/commands/bitswap/stat.js @@ -1,6 +1,5 @@ 'use strict' -const CID = require('cids') const print = require('../../utils').print module.exports = { @@ -17,11 +16,7 @@ module.exports = { } stats.wantlist = stats.wantlist || [] - stats.wantlist = stats.wantlist.map((entry) => { - const buf = Buffer.from(entry.cid.hash.data) - const cid = new CID(entry.cid.version, entry.cid.codec, buf) - return cid.toBaseEncodedString() - }) + stats.wantlist = stats.wantlist.map(entry => entry['/']) stats.peers = stats.peers || [] print(`bitswap status diff --git a/src/cli/commands/bitswap/wantlist.js b/src/cli/commands/bitswap/wantlist.js index 01170782d7..9397f492ae 100644 --- a/src/cli/commands/bitswap/wantlist.js +++ b/src/cli/commands/bitswap/wantlist.js @@ -3,7 +3,7 @@ const print = require('../../utils').print module.exports = { - command: 'wantlist', + command: 'wantlist [peer]', describe: 'Print out all blocks currently on the bitswap wantlist for the local peer.', diff --git a/src/cli/commands/block/get.js b/src/cli/commands/block/get.js index cb503afef7..dd1e21d7fc 100644 --- a/src/cli/commands/block/get.js +++ b/src/cli/commands/block/get.js @@ -19,9 +19,9 @@ module.exports = { } if (block) { - process.stdout.write(block.data) + print(block.data) } else { - process.stderr.write('Block was unwanted before it could be remotely retrieved') + print('Block was unwanted before it could be remotely retrieved') } }) } diff --git a/src/http/api/resources/bitswap.js b/src/http/api/resources/bitswap.js index 1130aeb832..e54b6f6863 100644 --- a/src/http/api/resources/bitswap.js +++ b/src/http/api/resources/bitswap.js @@ -9,7 +9,6 @@ exports = module.exports exports.wantlist = { handler: (request, reply) => { const peerId = request.query.arg - let list request.server.app.ipfs.bitswap.wantlist(peerId, (err, list) => { if (err) { return reply(boom.badRequest(err)) diff --git a/test/cli/bitswap.js b/test/cli/bitswap.js index 6cdebe61de..e2ab91a800 100644 --- a/test/cli/bitswap.js +++ b/test/cli/bitswap.js @@ -3,9 +3,11 @@ const expect = require('chai').expect const runOn = require('../utils/on-and-off').on +const PeerId = require('peer-id') describe('bitswap', () => runOn((thing) => { let ipfs + let peerId const key = 'QmUBdnXXPyoDFXj3Hj39dNJ5VkN3QFRskXxcGaYFBB8CNR' before((done) => { @@ -13,7 +15,11 @@ describe('bitswap', () => runOn((thing) => { ipfs('block get ' + key) .then(() => {}) .catch(() => {}) - setTimeout(done, 250) + PeerId.create((err, peer) => { + expect(err).to.not.exist() + peerId = peer.toB58String() + setTimeout(done, 250) + }) }) it('wantlist', function () { @@ -23,6 +29,13 @@ describe('bitswap', () => runOn((thing) => { }) }) + it('wantlist peerid', function () { + this.timeout(20 * 1000) + return ipfs('bitswap wantlist ' + peerId).then((out) => { + expect(out).to.eql('') + }) + }) + it('stat', function () { this.timeout(20 * 1000)