diff --git a/src/core/components/files.js b/src/core/components/files.js index 009e1229ad..28b920668a 100644 --- a/src/core/components/files.js +++ b/src/core/components/files.js @@ -161,9 +161,11 @@ module.exports = function files (self) { } function _lsPullStreamImmutable (ipfsPath) { + const path = normalizePath(ipfsPath) + const depth = path.split('/').length return pull( - exporter(ipfsPath, self._ipldResolver, { maxDepth: 1 }), - pull.filter((node) => node.depth === 1), + exporter(ipfsPath, self._ipldResolver, { maxDepth: depth }), + pull.filter((node) => node.depth === depth), pull.map((node) => { node = Object.assign({}, node, { hash: toB58String(node.hash) }) delete node.content diff --git a/test/cli/bitswap.js b/test/cli/bitswap.js index 40e0ba3455..29220f7b71 100644 --- a/test/cli/bitswap.js +++ b/test/cli/bitswap.js @@ -4,39 +4,39 @@ const expect = require('chai').expect const runOn = require('../utils/on-and-off').on -describe('bitswap', function () { - runOn((thing) => { - this.timeout(30000) - let ipfs - const key = 'QmUBdnXXPyoDFXj3Hj39dNJ5VkN3QFRskXxcGaYFBB8CNR' +describe('bitswap', () => runOn((thing) => { + let ipfs + const key = 'QmUBdnXXPyoDFXj3Hj39dNJ5VkN3QFRskXxcGaYFBB8CNR' - before((done) => { - ipfs = thing.ipfs - ipfs('block get ' + key) - .then(() => {}) - .catch(() => {}) - setTimeout(done, 800) - }) + before((done) => { + ipfs = thing.ipfs + ipfs('block get ' + key) + .then(() => {}) + .catch(() => {}) + setTimeout(done, 800) + }) - it('wantlist', () => { - return ipfs('bitswap wantlist').then((out) => { - expect(out).to.eql(key + '\n') - }) + it('wantlist', function () { + this.timeout(20 * 1000) + return ipfs('bitswap wantlist').then((out) => { + expect(out).to.eql(key + '\n') }) + }) + + it('stat', function () { + this.timeout(20 * 1000) - it('stat', () => { - return ipfs('bitswap stat').then((out) => { - expect(out).to.be.eql([ - 'bitswap status', - ' blocks received: 0', - ' dup blocks received: 0', - ' dup data received: 0B', - ' wantlist [1 keys]', - ` ${key}`, - ' partners [0]', - ' ' - ].join('\n') + '\n') - }) + return ipfs('bitswap stat').then((out) => { + expect(out).to.be.eql([ + 'bitswap status', + ' blocks received: 0', + ' dup blocks received: 0', + ' dup data received: 0B', + ' wantlist [1 keys]', + ` ${key}`, + ' partners [0]', + ' ' + ].join('\n') + '\n') }) }) -}) +})) diff --git a/test/cli/files.js b/test/cli/files.js index 4a8eb70efe..950d1510ce 100644 --- a/test/cli/files.js +++ b/test/cli/files.js @@ -311,6 +311,23 @@ describe('files', () => runOnAndOff((thing) => { }) }) + it('ls ', function () { + this.timeout(20 * 1000) + + return ipfs('ls /ipfs/QmYmW4HiZhotsoSqnv2o1oUusvkRM8b9RweBoH7ao5nki2/init-docs') + .then((out) => { + expect(out).to.eql( + 'QmZTR5bcpQD7cFgTorqxZDYaew1Wqgfbd2ud9QqGPAkK2V 1688 about\n' + + 'QmYCvbfNbCwFR45HiNP45rwJgvatpiW38D961L5qAhUM5Y 200 contact\n' + + 'QmegvLXxpVKiZ4b57Xs1syfBVRd8CbucVHAp7KpLQdGieC 65 docs/\n' + + 'QmY5heUM5qgRubMDD1og9fhCPA6QdkMp3QCwd4s7gJsyE7 322 help\n' + + 'QmdncfsVm2h5Kqq9hPmU7oAVX2zTSVP3L869tgTbPYnsha 1728 quick-start\n' + + 'QmPZ9gcCEpqKTo6aq61g2nXGUhM4iCL3ewB6LDXZCtioEB 1102 readme\n' + + 'QmTumTjvcYCAvRRwQ8sDRxh8ezmrcr88YFU7iYNroGGTBZ 1027 security-notes\n' + + 'QmciSU8hfpAXKjvK5YLUSwApomGSWN5gFbP4EpDAEzu2Te 863 tour/\n') + }) + }) + it('ls --help', function () { this.timeout(20 * 1000)