diff --git a/src/cli/commands/add.js b/src/cli/commands/add.js index e60e0c78c0..6a0341d588 100644 --- a/src/cli/commands/add.js +++ b/src/cli/commands/add.js @@ -1,3 +1,4 @@ +/* eslint-disable complexity */ 'use strict' const promisify = require('promisify-es6') diff --git a/src/cli/commands/ping.js b/src/cli/commands/ping.js index 778af48138..1b3ad82aff 100644 --- a/src/cli/commands/ping.js +++ b/src/cli/commands/ping.js @@ -21,7 +21,7 @@ module.exports = { return new Promise((resolve, reject) => { const peerId = argv.peerId - const count = argv.count || 10 + const count = argv.count pull( ipfs.pingPullStream(peerId, { count }), pull.drain(({ success, time, text }) => { diff --git a/test/cli/bitswap.js b/test/cli/bitswap.js index 75165811b2..7de899ae24 100644 --- a/test/cli/bitswap.js +++ b/test/cli/bitswap.js @@ -3,13 +3,11 @@ const { expect } = require('interface-ipfs-core/src/utils/mocha') const runOn = require('../utils/on-and-off').on -const PeerId = require('peer-id') const CID = require('cids') const waitFor = require('../utils/wait-for') describe('bitswap', () => runOn((thing) => { let ipfs - let peerId const key0 = 'QmUBdnXXPyoDFXj3Hj39dNJ5VkN3QFRskXxcGaYFBB8CNR' const key1 = 'zb2rhafnd6kEUujnoMkozHnWXY7XpWttyVDWKXfChqA42VTDU' @@ -22,14 +20,6 @@ describe('bitswap', () => runOn((thing) => { ipfs('block get ' + key1).catch(() => {}) }) - before(function (done) { - PeerId.create({ bits: 512 }, (err, peer) => { - expect(err).to.not.exist() - peerId = peer.toB58String() - done() - }) - }) - before(async () => { const test = async () => { const out = await ipfs('bitswap wantlist') @@ -43,12 +33,6 @@ describe('bitswap', () => runOn((thing) => { }) }) - it('wantlist', async function () { - const out = await ipfs('bitswap wantlist') - expect(out).to.include(key0) - expect(out).to.include(key1) - }) - it('should get wantlist with CIDs encoded in specified base', async function () { this.timeout(20 * 1000) @@ -56,32 +40,6 @@ describe('bitswap', () => runOn((thing) => { expect(out).to.include(new CID(key1).toBaseEncodedString('base64') + '\n') }) - it('wantlist peerid', async function () { - this.timeout(20 * 1000) - - const out = await ipfs('bitswap wantlist ' + peerId) - expect(out).to.eql('') - }) - - it('stat', async function () { - this.timeout(20 * 1000) - - const out = await ipfs('bitswap stat') - - expect(out).to.include('bitswap status') - expect(out).to.match(/provides buffer:\s\d+$/m) - expect(out).to.match(/blocks received:\s\d+$/m) - expect(out).to.match(/blocks sent:\s\d+$/m) - expect(out).to.match(/data received:\s\d+$/m) - expect(out).to.match(/data sent:\s\d+$/m) - expect(out).to.match(/dup blocks received:\s\d+$/m) - expect(out).to.match(/dup data received:\s\d+$/m) - expect(out).to.match(/wantlist\s\[\d+\skeys\]$/m) - expect(out).to.include(key0) - expect(out).to.include(key1) - expect(out).to.match(/partners\s\[\d+\]$/m) - }) - it('stat --human', async function () { this.timeout(20 * 1000) @@ -108,8 +66,5 @@ describe('bitswap', () => runOn((thing) => { expect(out).to.include(new CID(key1).toBaseEncodedString('base64')) }) - it('unwant', async function () { - const out = await ipfs('bitswap unwant ' + key0) - expect(out).to.eql(`Key ${key0} removed from wantlist\n`) - }) + // TODO: missing unwant with cid-base arg })) diff --git a/test/cli/block.js b/test/cli/block.js index 3304c8fcb9..7526a2eb79 100644 --- a/test/cli/block.js +++ b/test/cli/block.js @@ -11,13 +11,6 @@ describe('block', () => runOnAndOff((thing) => { ipfs = thing.ipfs }) - it('put', async function () { - this.timeout(40 * 1000) - - const out = await ipfs('block put test/fixtures/test-data/hello') - expect(out).to.eql('QmZjTnYw2TFhn9Nn7tjmPSoTBoY7YRkwPzwSrSbabY24Kp\n') - }) - it('put with flags, format and mhtype', async function () { this.timeout(40 * 1000) @@ -32,13 +25,6 @@ describe('block', () => runOnAndOff((thing) => { expect(out).to.eql('mAXASIKlIkE8vD0ebj4GXaUswGEsNLtHBzSoewPuF0pmhkqRH\n') }) - it('get', async function () { - this.timeout(40 * 1000) - - const out = await ipfs('block get QmZjTnYw2TFhn9Nn7tjmPSoTBoY7YRkwPzwSrSbabY24Kp') - expect(out).to.eql('hello world\n') - }) - it('get block from file without a final newline', async function () { this.timeout(40 * 1000) @@ -49,15 +35,7 @@ describe('block', () => runOnAndOff((thing) => { expect(out2).to.eql('there is no newline at end of this file') }) - it('stat', async function () { - this.timeout(40 * 1000) - - const out = await ipfs('block stat QmZjTnYw2TFhn9Nn7tjmPSoTBoY7YRkwPzwSrSbabY24Kp') - expect(out).to.eql([ - 'Key: QmZjTnYw2TFhn9Nn7tjmPSoTBoY7YRkwPzwSrSbabY24Kp', - 'Size: 12' - ].join('\n') + '\n') - }) + // TODO: missing block.get error test when block is undefined it('should stat and print CID encoded in specified base', async function () { this.timeout(80 * 1000) @@ -72,15 +50,6 @@ describe('block', () => runOnAndOff((thing) => { ].join('\n') + '\n') }) - it('rm', async function () { - this.timeout(40 * 1000) - - await ipfs('block put test/fixtures/test-data/hello') - - const out = await ipfs('block rm QmZjTnYw2TFhn9Nn7tjmPSoTBoY7YRkwPzwSrSbabY24Kp') - expect(out).to.eql('removed QmZjTnYw2TFhn9Nn7tjmPSoTBoY7YRkwPzwSrSbabY24Kp\n') - }) - it('rm quietly', async function () { this.timeout(40 * 1000) diff --git a/test/cli/bootstrap.js b/test/cli/bootstrap.js index b9e4f1659b..cef7003b4b 100644 --- a/test/cli/bootstrap.js +++ b/test/cli/bootstrap.js @@ -12,85 +12,6 @@ describe('bootstrap', () => runOnAndOff((thing) => { ipfs = thing.ipfs }) - const defaultList = [ - '/ip4/104.236.176.52/tcp/4001/ipfs/QmSoLnSGccFuZQJzRadHn95W2CrSFmZuTdDWP8HXaHca9z', - '/ip4/104.131.131.82/tcp/4001/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ', - '/ip4/104.236.179.241/tcp/4001/ipfs/QmSoLPppuBtQSGwKDZT2M73ULpjvfd3aZ6ha4oFGL1KrGM', - '/ip4/162.243.248.213/tcp/4001/ipfs/QmSoLueR4xBeUbY9WZ9xGUUxunbKWcrNFTDAadQJmocnWm', - '/ip4/128.199.219.111/tcp/4001/ipfs/QmSoLSafTMBsPKadTEgaXctDQVcqN88CNLHXMkTNwMKPnu', - '/ip4/104.236.76.40/tcp/4001/ipfs/QmSoLV4Bbm51jM9C4gDYZQ9Cy3U6aXMJDAbzgu2fzaDs64', - '/ip4/178.62.158.247/tcp/4001/ipfs/QmSoLer265NRgSp2LA3dPaeykiS1J6DifTC88f5uVQKNAd', - '/ip4/178.62.61.185/tcp/4001/ipfs/QmSoLMeWqB7YGVLJN3pNLQpmmEk35v6wYtsMGLzSr5QBU3', - '/ip4/104.236.151.122/tcp/4001/ipfs/QmSoLju6m7xTh3DuokvT3886QRYqxAzb1kShaanJgW36yx', - '/ip6/2604:a880:1:20::1f9:9001/tcp/4001/ipfs/QmSoLnSGccFuZQJzRadHn95W2CrSFmZuTdDWP8HXaHca9z', - '/ip6/2604:a880:1:20::203:d001/tcp/4001/ipfs/QmSoLPppuBtQSGwKDZT2M73ULpjvfd3aZ6ha4oFGL1KrGM', - '/ip6/2604:a880:0:1010::23:d001/tcp/4001/ipfs/QmSoLueR4xBeUbY9WZ9xGUUxunbKWcrNFTDAadQJmocnWm', - '/ip6/2400:6180:0:d0::151:6001/tcp/4001/ipfs/QmSoLSafTMBsPKadTEgaXctDQVcqN88CNLHXMkTNwMKPnu', - '/ip6/2604:a880:800:10::4a:5001/tcp/4001/ipfs/QmSoLV4Bbm51jM9C4gDYZQ9Cy3U6aXMJDAbzgu2fzaDs64', - '/ip6/2a03:b0c0:0:1010::23:1001/tcp/4001/ipfs/QmSoLer265NRgSp2LA3dPaeykiS1J6DifTC88f5uVQKNAd', - '/ip6/2a03:b0c0:1:d0::e7:1/tcp/4001/ipfs/QmSoLMeWqB7YGVLJN3pNLQpmmEk35v6wYtsMGLzSr5QBU3', - '/ip6/2604:a880:1:20::1d9:6001/tcp/4001/ipfs/QmSoLju6m7xTh3DuokvT3886QRYqxAzb1kShaanJgW36yx', - '/dns4/node0.preload.ipfs.io/tcp/443/wss/ipfs/QmZMxNdpMkewiVZLMRxaNxUeZpDUb34pWjZ1kZvsd16Zic', - '/dns4/node1.preload.ipfs.io/tcp/443/wss/ipfs/Qmbut9Ywz9YEDrz8ySBSgWyJk41Uvm2QJPhwDJzJyGFsD6' - ] - - const updatedList = [ - '/ip4/104.236.176.52/tcp/4001/ipfs/QmSoLnSGccFuZQJzRadHn95W2CrSFmZuTdDWP8HXaHca9z', - '/ip4/104.131.131.82/tcp/4001/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ', - '/ip4/104.236.179.241/tcp/4001/ipfs/QmSoLPppuBtQSGwKDZT2M73ULpjvfd3aZ6ha4oFGL1KrGM', - '/ip4/162.243.248.213/tcp/4001/ipfs/QmSoLueR4xBeUbY9WZ9xGUUxunbKWcrNFTDAadQJmocnWm', - '/ip4/128.199.219.111/tcp/4001/ipfs/QmSoLSafTMBsPKadTEgaXctDQVcqN88CNLHXMkTNwMKPnu', - '/ip4/104.236.76.40/tcp/4001/ipfs/QmSoLV4Bbm51jM9C4gDYZQ9Cy3U6aXMJDAbzgu2fzaDs64', - '/ip4/178.62.158.247/tcp/4001/ipfs/QmSoLer265NRgSp2LA3dPaeykiS1J6DifTC88f5uVQKNAd', - '/ip4/178.62.61.185/tcp/4001/ipfs/QmSoLMeWqB7YGVLJN3pNLQpmmEk35v6wYtsMGLzSr5QBU3', - '/ip4/104.236.151.122/tcp/4001/ipfs/QmSoLju6m7xTh3DuokvT3886QRYqxAzb1kShaanJgW36yx', - '/ip6/2604:a880:1:20::1f9:9001/tcp/4001/ipfs/QmSoLnSGccFuZQJzRadHn95W2CrSFmZuTdDWP8HXaHca9z', - '/ip6/2604:a880:1:20::203:d001/tcp/4001/ipfs/QmSoLPppuBtQSGwKDZT2M73ULpjvfd3aZ6ha4oFGL1KrGM', - '/ip6/2604:a880:0:1010::23:d001/tcp/4001/ipfs/QmSoLueR4xBeUbY9WZ9xGUUxunbKWcrNFTDAadQJmocnWm', - '/ip6/2400:6180:0:d0::151:6001/tcp/4001/ipfs/QmSoLSafTMBsPKadTEgaXctDQVcqN88CNLHXMkTNwMKPnu', - '/ip6/2604:a880:800:10::4a:5001/tcp/4001/ipfs/QmSoLV4Bbm51jM9C4gDYZQ9Cy3U6aXMJDAbzgu2fzaDs64', - '/ip6/2a03:b0c0:0:1010::23:1001/tcp/4001/ipfs/QmSoLer265NRgSp2LA3dPaeykiS1J6DifTC88f5uVQKNAd', - '/ip6/2a03:b0c0:1:d0::e7:1/tcp/4001/ipfs/QmSoLMeWqB7YGVLJN3pNLQpmmEk35v6wYtsMGLzSr5QBU3', - '/ip6/2604:a880:1:20::1d9:6001/tcp/4001/ipfs/QmSoLju6m7xTh3DuokvT3886QRYqxAzb1kShaanJgW36yx', - '/dns4/node0.preload.ipfs.io/tcp/443/wss/ipfs/QmZMxNdpMkewiVZLMRxaNxUeZpDUb34pWjZ1kZvsd16Zic', - '/dns4/node1.preload.ipfs.io/tcp/443/wss/ipfs/Qmbut9Ywz9YEDrz8ySBSgWyJk41Uvm2QJPhwDJzJyGFsD6', - '/ip4/111.111.111.111/tcp/1001/ipfs/QmcyFFKfLDGJKwufn2GeitxvhricsBQyNKTkrD14psikoD' - ] - - it('add default', async function () { - this.timeout(40 * 1000) - - const out = await ipfs('bootstrap add --default') - expect(out).to.equal(defaultList.join('\n') + '\n') - }) - - it('list the bootstrap nodes', async function () { - this.timeout(40 * 1000) - - const out = await ipfs('bootstrap list') - expect(out).to.equal(defaultList.join('\n') + '\n') - }) - - it('add another bootstrap node', async function () { - this.timeout(40 * 1000) - - const out = await ipfs('bootstrap add /ip4/111.111.111.111/tcp/1001/ipfs/QmcyFFKfLDGJKwufn2GeitxvhricsBQyNKTkrD14psikoD') - expect(out).to.equal('/ip4/111.111.111.111/tcp/1001/ipfs/QmcyFFKfLDGJKwufn2GeitxvhricsBQyNKTkrD14psikoD\n') - - const out2 = await ipfs('bootstrap list') - expect(out2).to.equal(updatedList.join('\n') + '\n') - }) - - it('rm a bootstrap node', async function () { - this.timeout(40 * 1000) - - const out = await ipfs('bootstrap rm /ip4/111.111.111.111/tcp/1001/ipfs/QmcyFFKfLDGJKwufn2GeitxvhricsBQyNKTkrD14psikoD') - expect(out).to.equal('/ip4/111.111.111.111/tcp/1001/ipfs/QmcyFFKfLDGJKwufn2GeitxvhricsBQyNKTkrD14psikoD\n') - - const out2 = await ipfs('bootstrap list') - expect(out2).to.equal(defaultList.join('\n') + '\n') - }) - it('rm all bootstrap nodes', async function () { this.timeout(40 * 1000) diff --git a/test/cli/config.js b/test/cli/config.js index 6b7741dcae..2f52e248a5 100644 --- a/test/cli/config.js +++ b/test/cli/config.js @@ -69,12 +69,10 @@ describe('config', () => runOnAndOff((thing) => { describe('show', function () { this.timeout(40 * 1000) - it('returns the full config', async () => { - const out = await ipfs('config show') - expect(JSON.parse(out)).to.be.eql(updatedConfig()) - }) + // TODO test json output format }) + // TODO unskip this test describe.skip('replace', () => { it('replace config with file', async () => { const filePath = 'test/fixtures/test-data/otherconfig' diff --git a/test/cli/dag.js b/test/cli/dag.js index dcd8521573..e5c43be11d 100644 --- a/test/cli/dag.js +++ b/test/cli/dag.js @@ -21,6 +21,9 @@ describe('dag', () => runOnAndOff.off((thing) => { }) describe('get', () => { + // TODO test local-resolve + // TODO output format + // TODO err output format it('get', async function () { this.timeout(20 * 1000) @@ -36,19 +39,14 @@ describe('dag', () => runOnAndOff.off((thing) => { }) describe('resolve', () => { + // TODO test err output format + // TODO test empty lastCid logic it('resolve cid', async function () { this.timeout(20 * 1000) const out = await ipfs('dag resolve Qmaj2NmcyAXT8dFmZRRytE12wpcaHADzbChKToMEjBsj5Z') expect(out).to.equal('Qmaj2NmcyAXT8dFmZRRytE12wpcaHADzbChKToMEjBsj5Z\n') }) - - it('resolve sub directory', async function () { - this.timeout(20 * 1000) - - const out = await ipfs('dag resolve Qmaj2NmcyAXT8dFmZRRytE12wpcaHADzbChKToMEjBsj5Z/init-docs/tour/0.0-intro') - expect(out).to.equal('QmYE7xo6NxbHEVEHej1yzxijYaNY51BaeKxjXxn6Ssa6Bs\n') - }) }) describe('put', () => { diff --git a/test/cli/dns.js b/test/cli/dns.js index 34722404ad..7032310f5a 100644 --- a/test/cli/dns.js +++ b/test/cli/dns.js @@ -1,56 +1,17 @@ /* eslint-env mocha */ 'use strict' -const { expect } = require('interface-ipfs-core/src/utils/mocha') +// const { expect } = require('interface-ipfs-core/src/utils/mocha') const runOnAndOff = require('../utils/on-and-off') -const isIPFS = require('is-ipfs') +// const isIPFS = require('is-ipfs') describe('dns', () => runOnAndOff((thing) => { - let ipfs + // let ipfs before(function () { this.timeout(60 * 1000) - ipfs = thing.ipfs + // ipfs = thing.ipfs }) - it('recursively resolve ipfs.io dns', async function () { - this.timeout(60 * 1000) - - const res = await ipfs('dns ipfs.io') - expect(res.substr(0, 6)).to.eql('/ipfs/') - const resultingDomainOrCid = res.split('/')[2].trim() - expect(isIPFS.cid(resultingDomainOrCid)).to.eql(true) - }) - - it('recursively resolve _dnslink.ipfs.io dns', async function () { - this.timeout(60 * 1000) - - const res = await ipfs('dns _dnslink.ipfs.io') - expect(res.substr(0, 6)).to.eql('/ipfs/') - const resultingDomainOrCid = res.split('/')[2].trim() - expect(isIPFS.cid(resultingDomainOrCid)).to.eql(true) - }) - - it('non-recursive resolve ipfs.io', async function () { - this.timeout(60 * 1000) - - const res = await ipfs('dns --recursive false ipfs.io') - expect(res.substr(0, 6)).to.eql('/ipns/') - const resultingDomainOrCid = res.split('/')[2].trim() - expect(isIPFS.cid(resultingDomainOrCid)).to.eql(false) - }) - - it('resolve subdomain docs.ipfs.io dns', async function () { - this.timeout(60 * 1000) - - const res = await ipfs('dns docs.ipfs.io') - expect(res.substr(0, 6)).to.eql('/ipfs/') - }) - - it('resolve subdomain _dnslink.docs.ipfs.io dns', async function () { - this.timeout(60 * 1000) - - const res = await ipfs('dns _dnslink.docs.ipfs.io') - expect(res.substr(0, 6)).to.eql('/ipfs/') - }) + // TODO add smoke test plus maybe errors just to make sure this works })) diff --git a/test/cli/file.js b/test/cli/file.js deleted file mode 100644 index 86a15d499d..0000000000 --- a/test/cli/file.js +++ /dev/null @@ -1,38 +0,0 @@ -/* eslint-env mocha */ -'use strict' - -const { expect } = require('interface-ipfs-core/src/utils/mocha') -const runOnAndOff = require('../utils/on-and-off') -const file = 'QmR56UJmAaZLXLdTT1ALrE9vVqV8soUEekm9BMd4FnuYqV' -const dir = 'Qmaj2NmcyAXT8dFmZRRytE12wpcaHADzbChKToMEjBsj5Z' - -describe('file ls', () => runOnAndOff((thing) => { - let ipfs - - before(async function () { - this.timeout(50 * 1000) - ipfs = thing.ipfs - await ipfs('add -r test/fixtures/test-data/recursive-get-dir') - }) - - it('prints a filename', async () => { - const out = await ipfs(`file ls ${file}`) - - expect(out).to.eql( - 'This functionality is deprecated, and will be removed in future versions. If possible, please use \'ipfs ls\' instead.\n' + - `${file}\n` - ) - }) - - it('prints the filenames in a directory', async () => { - const out = await ipfs(`file ls ${dir}`) - expect(out).to.eql( - 'This functionality is deprecated, and will be removed in future versions. If possible, please use \'ipfs ls\' instead.\n' + - 'QmamKEPmEH9RUsqRQsfNf5evZQDQPYL9KXg1ADeT7mkHkT\n' + - 'QmPkWYfSLCEBLZu7BZt4kigGDMe3cpogMbeVf97gN2xJDN\n' + - 'QmUqyZtPmsRy1U5Mo8kz2BAMmk1hfJ7yW1KAFTMB2odsFv\n' + - 'QmUhUuiTKkkK8J6JZ9zmj8iNHPuNfGYcszgRumzhHBxEEU\n' + - 'QmR56UJmAaZLXLdTT1ALrE9vVqV8soUEekm9BMd4FnuYqV\n' - ) - }) -})) diff --git a/test/cli/files.js b/test/cli/files.js index b1376b7d59..86f565d12f 100644 --- a/test/cli/files.js +++ b/test/cli/files.js @@ -2,144 +2,29 @@ 'use strict' const fs = require('fs') -const os = require('os') const { expect } = require('interface-ipfs-core/src/utils/mocha') const path = require('path') -const hat = require('hat') const compareDir = require('dir-compare').compareSync const rimraf = require('rimraf').sync -const CID = require('cids') -const mh = require('multihashes') const runOnAndOff = require('../utils/on-and-off') -const clean = require('../utils/clean') -const delay = require('delay') - -// TODO: Test against all algorithms Object.keys(mh.names) -// This subset is known to work with both go-ipfs and js-ipfs as of 2017-09-05 -const HASH_ALGS = [ - 'sha1', - 'sha2-256', - 'sha2-512', - 'keccak-224', - 'keccak-256', - 'keccak-384', - 'keccak-512' -] describe('files', () => runOnAndOff((thing) => { let ipfs const readme = fs.readFileSync(path.join(process.cwd(), '/src/init-files/init-docs/readme')) .toString('utf-8') - const recursiveGetDirResults = [ - 'added QmdgaiKe1HFfhrZvLwTFCrXmgTojhSWuBvyFXUVc8KzJVc recursive-get-dir/blocks/CIQBE/CIQBED3K6YA5I3QQWLJOCHWXDRK5EXZQILBCKAPEDUJENZ5B5HJ5R3A.data', - 'added Qmbm7ToWsTta4Y1RipmRudCenKF7qAHRVTCtTPuoVqfY8H recursive-get-dir/blocks/CIQDD/CIQDDVW2EZIJF4NQH7WJNESD7XHQSXA5EGJVNTPVHD7444C2KLKXHDI.data', - 'added QmTpxXKswGwhTYLn1qL4EG9aLGFXS2LSnreceV2FJeArVh recursive-get-dir/blocks/CIQDD/CIQDDZ5EDQK5AP7LRTLZHQZUR2R3GECRFV3WPKNL7PL2SKFIL2LXC4Y.data', - 'added QmSynZ3cTjBzpMTSPCP5Q6RJSa9WEAA8p178cZRLnKdahz recursive-get-dir/blocks/CIQDM/CIQDMKFEUGKSLXMEXO774EZOYCYNHPRVFD53ZSAU7237F67XDSQGCYQ.data', - 'added QmQCYnQWAHqSy1ts7VmHbp18BFEmbVvfX7FASVQF21uo5g recursive-get-dir/blocks/CIQDV/CIQDVKITASFS55MC2TXCX5XMZLMGTYVODWPEDIW7JYEG7YXBIA7IUWY.data', - 'added QmPbgB6GzeUEnvXqQgYLTJnrdcm95kGRWH36euTr2eAB2w recursive-get-dir/blocks/CIQEN/CIQENVCICS44LLYUDQ5KVN6ALXC6QRHK2X4R6EUFRMBB5OSFO2FUYDQ.data', - 'added QmPiJAUg2J3dWWnQvtKXbkr8g1qCxX4RCPkU3wFmxd6x8H recursive-get-dir/blocks/CIQER/CIQERMRAAFXUAUOX3V2DCW7R77FRIVHQ3V5OIPPS3XQBX34KRPNOIRQ.data', - 'added QmcozcFvmaTqVPaFXgZUHPsroSG8YP6tHEYyFaFhnonwSG recursive-get-dir/blocks/CIQEU/CIQEUWUVLBXVFYSYCHHSCRTXCYHGIOBXKWUMKFR3UPAFHQ5WK5362FQ.data', - 'added QmNtkNt8oZASY7AYVpswA3RQ43hASjP1NGj8GB1L6vgHUx recursive-get-dir/blocks/CIQFE/CIQFEAGMNNXXTYKYQSANT6IBNTFN7WR5RPD5F6GN6MBKUUO25DNOTWQ.data', - 'added QmVdfEEiQmem5GanTjja7HKHNFpfa2LB8196fD9m9b656Q recursive-get-dir/blocks/CIQFF/CIQFFRR4O52TS2Z7QLDDTF32OIR4FWLKT5YLL7MLDVIT7DC3NHOK5VA.data', - 'added QmSMYdQtDTqykd7oLKZq3vJtS7KoWZwjL7GA9zj6UsCngE recursive-get-dir/blocks/CIQFT/CIQFTFEEHEDF6KLBT32BFAGLXEZL4UWFNWM4LFTLMXQBCERZ6CMLX3Y.data', - 'added QmabxyrxY1uUzHcd7mTBCfibFwemGC89vuJFUw4UkebmSn recursive-get-dir/blocks/CIQGF/CIQGFTQ7FSI2COUXWWLOQ45VUM2GUZCGAXLWCTOKKPGTUWPXHBNIVOY.data', - 'added QmWGima5TqLfUTzUsCF6h3oXGvwu3QQ1zjZYLDMaGeFRbB recursive-get-dir/blocks/CIQGP/CIQGPALRQ24P6NS4OWHTQ7R247ZI7KJWP3QWPQYS43LFULQC5ANLQFI.data', - 'added QmZe7irS2FotZtsUx9wpy5QPKJF6YEaAEZLHLUwQy6XgY8 recursive-get-dir/blocks/CIQH7/CIQH7OEYWXL34RWYL7VXLWEU4FWPVGT24VJT7DUZPTNLF25N25IGGQA.data', - 'added QmVLdEzvgvM5k7NUWWSgURAZuJmiQBnbuZga3EpRip8xTu recursive-get-dir/blocks/CIQHA/CIQHAKDLTL5GMIFGN5YVY4BA22FPHUIODJEXS4LCTQDWA275XAJDAPI.data', - 'added QmU7mw6KaaAJA6tHi9FdiHu2HtA6rjb6e1aYuWscwTJ9yV recursive-get-dir/blocks/CIQHB/CIQHBGZNZRPWVEFNMTLP4OS5EAVHFMCX2HD7FZUC2B3WUU3D4LGKS5A.data', - 'added QmRfQcw4qrW91Vqj3evXiH11MuvRVJb7S7vKSgau7aBzRa recursive-get-dir/blocks/CIQHP/CIQHPUVCWD6JA6AFUVD6VA64TGWP67KYA3AIMBUMVWGZ5AQN2L2HSWQ.data', - 'added QmazVLpyExfPkwASngrz3MDZD1pdaBUxj7VqAkjAFAWaa9 recursive-get-dir/blocks/CIQIX/CIQIXBZMUTXFC5QIGMLJNXLLHZOPGSL2PBC65D4UIVWM6TI5F5TAFNI.data', - 'added Qmb7AKKnZwLLFtseMZiHkq4fKNhP5rSggcvN2oGXUBZv8B recursive-get-dir/blocks/CIQJ2/CIQJ23BL4UHXA2KTI6NLTXZM4PW4VEFWQBJ4ACZQAS37BLGL4HUO5XY.data', - 'added QmTt3mbtfVGEfqqjec9WZcWaC4SkesErDPAhhr8NRfsWFp recursive-get-dir/blocks/CIQJB/CIQJBQD2O6K4CGJVCCTJNUP57QHR4SKHZ74OIITBBGLOMCO3ZOLWLGA.data', - 'added QmWNXfkCTxSAuFBdNQ8gGmyxnZ28XrzRbjjmvCViLoNU5W recursive-get-dir/blocks/CIQJF/CIQJFGRQHQ45VCQLM7AJNF2GF5UHUAGGHC6LLAH6VYDEKLQMD4QLILY.data', - 'added QmWR1EuH5cui4EW5W16ADxzmYEFPjHDs1LcPe3uQL3CmiS recursive-get-dir/blocks/CIQJG/CIQJGO2B2N75IUEM372FSMG76VV256I4PXBULZZ5ASNLK4FL4EG7XOI.data', - 'added Qmd4FKC6GcKnhJHnEJJwqg9A1eDd7JXKkG5v3iv9XSHtwq recursive-get-dir/blocks/CIQKK/CIQKKLBWAIBQZOIS5X7E32LQAL6236OUKZTMHPQSFIXPWXNZHQOV7JQ.data', - 'added QmQ8ag7ysVyCMzJGFjxrUStwWtniQ69c7G9aezbmsKeNYD recursive-get-dir/blocks/CIQLB/CIQLBK52T5EHVHZY5URTG5JS3JCUJDQM2DRB5RVF33DCUUOFJNGVDUI.data', - 'added QmaSjzSSRanYzRGPXQY6m5SWfSkkfcnzNkurJEQc4chPJx recursive-get-dir/blocks/CIQLB/CIQLBS5HG4PRCRQ7O4EBXFD5QN6MTI5YBYMCVQJDXPKCOVR6RMLHZFQ.data', - 'added Qmc1nasezDdPyZiXB5VB6Aygzswcr6QkauzzXMeUGouHTN recursive-get-dir/blocks/CIQMB/CIQMB7DLJFKD267QJ2B5FJNHZPTSVA7IB6OHXSQ2XSVEEKMKK6RT75I.data', - 'added QmbFMke1KXqnYyBBWxB74N4c5SBnJMVAiMNRcGu6x1AwQH recursive-get-dir/blocks/CIQOH/CIQOHMGEIKMPYHAUTL57JSEZN64SIJ5OIHSGJG4TJSSJLGI3PBJLQVI.data', - 'added QmeBypQ2yE4t4Loybhby15DjkeLDXJKCcgMfxTXeFnHa8F recursive-get-dir/blocks/CIQOL/CIQOLBQZSZAODJGGH6RYYVBUXHTS3SM5EORZDU63LYPEFUAFE4SBM4I.data', - 'added QmTH5Jc2uhu5LqGEFAgrn2HwoDHLpvQd9b6fyoUGi6aeQu recursive-get-dir/blocks/CIQOM/CIQOMBKARLB7PAITVSNH7VEGIQJRPL6J7FT2XYVKAXT4MQPXXPUYUNY.data', - 'added QmaTXag3TaaG6hFUXGxybEuMUk7UHSutZobZgDtjr6aXjf recursive-get-dir/blocks/CIQON/CIQONICFQZH7QVU6IPSIM3AK7AD554D3BWZPAGEAQYQOWMFZQDUUAEI.data', - 'added QmTU72W5EAnNUAtnVW1qoFzdDD8FyiBjpF5MUzjBAFnHS6 recursive-get-dir/blocks/CIQOY/CIQOYW2THIZBRGI7IN33ROGCKOFZLXJJ2MPKYZBTV4H3N7GYHXMAO6A.data', - 'added QmbJgQa4XNBFvGQcLbWBNtvWZetbCUKiyAQNfePoTzwf9L recursive-get-dir/blocks/CIQPD/CIQPDQJBGYDZNMOAGGYNRNMP2VDKWBWGAEDDEJDACM3SGG3VIANDDXI.data', - 'added QmPkWYfSLCEBLZu7BZt4kigGDMe3cpogMbeVf97gN2xJDN recursive-get-dir/config', - 'added QmfExFwdFKspsY2q5WnhQjd1QDKnjpTQ4UkiHqqQxV7h67 recursive-get-dir/datastore/000002.ldb', - 'added QmPFVLPmp9zv5Z5KUqLhe2EivAGccQW2r7M7jhVJGLZoZU recursive-get-dir/datastore/000005.ldb', - 'added QmcJ6TXPMPm6puSC9vpxuG57PyfGpr8bvTgkKU9SHHU5Uo recursive-get-dir/datastore/000010.ldb', - 'added QmVJi93Yj5RW3NuqqxonGz3jAXUYHrdQvWrURxg1TiLEuX recursive-get-dir/datastore/CURRENT', - 'added QmbFMke1KXqnYyBBWxB74N4c5SBnJMVAiMNRcGu6x1AwQH recursive-get-dir/datastore/LOCK', - 'added QmbFNLNr9at9eK5LrNyUdyE5cdLb5yaT9DkjXw7BK68kcM recursive-get-dir/datastore/LOG', - 'added QmQpc75sJGUv59dAwHF7vazBGV9o6C7z587Dp9nv7HYAps recursive-get-dir/datastore/LOG.old', - 'added QmeiTxVN4xAjxUzHzBqCpK3GaT3GeiLQeJRpYDXDfLeEmR recursive-get-dir/datastore/MANIFEST-000014', - 'added QmZTR5bcpQD7cFgTorqxZDYaew1Wqgfbd2ud9QqGPAkK2V recursive-get-dir/init-docs/about', - 'added QmYCvbfNbCwFR45HiNP45rwJgvatpiW38D961L5qAhUM5Y recursive-get-dir/init-docs/contact', - 'added QmQN88TEidd3RY2u3dpib49fERTDfKtDpvxnvczATNsfKT recursive-get-dir/init-docs/docs/index', - 'added QmY5heUM5qgRubMDD1og9fhCPA6QdkMp3QCwd4s7gJsyE7 recursive-get-dir/init-docs/help', - 'added QmdncfsVm2h5Kqq9hPmU7oAVX2zTSVP3L869tgTbPYnsha recursive-get-dir/init-docs/quick-start', - 'added QmPZ9gcCEpqKTo6aq61g2nXGUhM4iCL3ewB6LDXZCtioEB recursive-get-dir/init-docs/readme', - 'added QmTumTjvcYCAvRRwQ8sDRxh8ezmrcr88YFU7iYNroGGTBZ recursive-get-dir/init-docs/security-notes', - 'added QmYE7xo6NxbHEVEHej1yzxijYaNY51BaeKxjXxn6Ssa6Bs recursive-get-dir/init-docs/tour/0.0-intro', - 'added QmR56UJmAaZLXLdTT1ALrE9vVqV8soUEekm9BMd4FnuYqV recursive-get-dir/version', - 'added QmYwUkwNwJN2cevwXKL48DRpbbjbdLWyyLANG3BKTtsTZ8 recursive-get-dir/blocks/CIQBE', - 'added QmSCq2peGvGDXZKuX565UczxRpgzsiPPF3PgcJq9zDbByL recursive-get-dir/blocks/CIQDD', - 'added QmNS3zMGDTPRTuR8nbPz4ddQpGN4gtuVyZ5G3mn3ajg4Rb recursive-get-dir/blocks/CIQDM', - 'added QmQaTiy1CufRfP3zTCW8fAtNWjvdeWuMkvTi4q6dykNDif recursive-get-dir/blocks/CIQDV', - 'added QmZCxJdNTR1MHRNGGWgZRZdW66FTpyTLdT8odbUz1CP7J9 recursive-get-dir/blocks/CIQEN', - 'added QmboWqKvhjxdBw1AfxQ56sqhqrrtG7ibaGhHb19TPnjr69 recursive-get-dir/blocks/CIQER', - 'added QmVU52FEpQQF3ViFGUKLhLeJaRKpCZfqN4AWLuzAXyrzyU recursive-get-dir/blocks/CIQEU', - 'added QmXrrAYhbThjuHRPA23HujCLFbTrnwd3jmvNbZBAnKEddk recursive-get-dir/blocks/CIQFE', - 'added QmUcLzGWDuBPA6iVF65n676KiCbQNXV4owecfSR4QFVy3U recursive-get-dir/blocks/CIQFF', - 'added QmWjMLA3ppmngQaHs8YEQ3Bru4tKoDeJh2cKv7U7dtLUuf recursive-get-dir/blocks/CIQFT', - 'added QmYLZ3uqYLkViS7Bh3vxcT5yrPscyWMV11iqFVJnqA7JVT recursive-get-dir/blocks/CIQGF', - 'added QmZMHzPS1qema8HvLk4jRuSLrUjRHZ8Siu6Wc4njAmx8MG recursive-get-dir/blocks/CIQGP', - 'added Qmb5NqTFar7MnxyRwwQtfb81nyS6g5NRG1bdo6AefmvhXU recursive-get-dir/blocks/CIQH7', - 'added QmddXWuKjfCbF6HXR9jStKDoLEAZ7xc8SZgDanQLMiGjpn recursive-get-dir/blocks/CIQHA', - 'added Qma1ytRhbzt3tGcJopMvd7g3ZE38mRKTTuJuRaHmguq8mN recursive-get-dir/blocks/CIQHB', - 'added QmRsyLntZoGPWURqtemAmgRdtmuCjbbdZ5xzkCAEUhh4iU recursive-get-dir/blocks/CIQHP', - 'added QmNM7hxdJfaApCJe1ubCrhAQSA6AWQXUvKZrHcf5RxsNvn recursive-get-dir/blocks/CIQIX', - 'added QmT1zKYzUpt2kF8AEV2igH9hXwzGu4q8pc4uJ9BLWqjMhT recursive-get-dir/blocks/CIQJ2', - 'added QmQebEvyaFbez884asHoTrNsbck1JdMLcM8EhUFYCraGHZ recursive-get-dir/blocks/CIQJB', - 'added QmWjsRHRK7ENAhMvgwfkze9bkySxjAsNMGXrMGMsFcrDWU recursive-get-dir/blocks/CIQJF', - 'added QmWrs7zVFkbpsTEbEpe3MyAB8ssUNp8jamE7i4PZ736zWy recursive-get-dir/blocks/CIQJG', - 'added QmUBsjP45UUHzKymAUqwEFJsuCvfC1AcaLvBgMsoGMipoG recursive-get-dir/blocks/CIQKK', - 'added Qmbqod68qdYiEs7kkTGu7G59adekUbAFAAg7WEyM6iPP5z recursive-get-dir/blocks/CIQLB', - 'added QmeqJBkwmzsVR79HBKLW7AYhfAMxMaJs5dGHSgey5ezy7N recursive-get-dir/blocks/CIQMB', - 'added QmTnaav9VTSVyLu8PvRzh4gJ8heF9rpdWzeDb7rMx5DkxV recursive-get-dir/blocks/CIQOH', - 'added Qmd6s8LXAEjW7y9QbGSzeuewrRBYjJHmcazG3Hk7cJ74da recursive-get-dir/blocks/CIQOL', - 'added Qmec4atiyfysPR8HU5gPfjKY1NpQDY2kmSeeadx8wLEBqY recursive-get-dir/blocks/CIQOM', - 'added QmNi9kKnfKJGuofhBRKMdKj5R6BQAYHWRtu3vXJHRy69TE recursive-get-dir/blocks/CIQON', - 'added QmQ1mNtPTJ6JG3TNNq73m2orvsfKCKrqMKoXyXwRKWM1ma recursive-get-dir/blocks/CIQOY', - 'added QmSCUPYy4CfFt9nA61J9v2DMfJygQAJjaUcRmygDbVME2D recursive-get-dir/blocks/CIQPD', - 'added QmamKEPmEH9RUsqRQsfNf5evZQDQPYL9KXg1ADeT7mkHkT recursive-get-dir/blocks', - 'added QmUqyZtPmsRy1U5Mo8kz2BAMmk1hfJ7yW1KAFTMB2odsFv recursive-get-dir/datastore', - 'added QmegvLXxpVKiZ4b57Xs1syfBVRd8CbucVHAp7KpLQdGieC recursive-get-dir/init-docs/docs', - 'added QmciSU8hfpAXKjvK5YLUSwApomGSWN5gFbP4EpDAEzu2Te recursive-get-dir/init-docs/tour', - 'added QmUhUuiTKkkK8J6JZ9zmj8iNHPuNfGYcszgRumzhHBxEEU recursive-get-dir/init-docs', - 'added Qmaj2NmcyAXT8dFmZRRytE12wpcaHADzbChKToMEjBsj5Z recursive-get-dir' - ] - before(() => { ipfs = thing.ipfs }) it('add with progress', async function () { this.timeout(30 * 1000) - + // TODO actually test something related to progress const out = await ipfs('add -p src/init-files/init-docs/readme') expect(out) .to.eql('added QmPZ9gcCEpqKTo6aq61g2nXGUhM4iCL3ewB6LDXZCtioEB readme\n') }) - it('add', async function () { - this.timeout(30 * 1000) - - const out = await ipfs('add src/init-files/init-docs/readme') - expect(out) - .to.eql('added QmPZ9gcCEpqKTo6aq61g2nXGUhM4iCL3ewB6LDXZCtioEB readme\n') - }) - it('add multiple', async function () { this.timeout(30 * 1000) @@ -150,35 +35,6 @@ describe('files', () => runOnAndOff((thing) => { .to.include('added QmT78zSuBmuS4z925WZfrqQ1qHaJ56DQaTfyMUF7F8ff5o hello\n') }) - it('add alias', async function () { - this.timeout(30 * 1000) - - const out = await ipfs('add src/init-files/init-docs/readme') - expect(out) - .to.eql('added QmPZ9gcCEpqKTo6aq61g2nXGUhM4iCL3ewB6LDXZCtioEB readme\n') - }) - - it('add recursively test', async function () { - this.timeout(60 * 1000) - - const out = await ipfs('add -r test/fixtures/test-data/recursive-get-dir') - expect(out).to.equal(recursiveGetDirResults.join('\n') + '\n') - }) - - it('add recursively including hidden files', async function () { - this.timeout(60 * 1000) - - const out = await ipfs('add -r -H test/fixtures/test-data/recursive-get-dir') - expect(out).to.include('added QmdBd5zgdJQHsyaaAm9Vnth7NWwj23gj3Ew17r6bTvVkch recursive-get-dir/.hidden.txt') - }) - - it('add directory with trailing slash test', async function () { - this.timeout(30 * 1000) - - const out = await ipfs('add -r test/fixtures/test-data/recursive-get-dir/') - expect(out).to.equal(recursiveGetDirResults.join('\n') + '\n') - }) - it('add directory with odd name', async function () { this.timeout(30 * 1000) const expected = [ @@ -191,72 +47,6 @@ describe('files', () => runOnAndOff((thing) => { expect(out).to.eql(expected.join('\n') + '\n') }) - it('add and wrap with a directory', async function () { - this.timeout(30 * 1000) - - const out = await ipfs('add -w src/init-files/init-docs/readme') - expect(out).to.be.eql([ - 'added QmPZ9gcCEpqKTo6aq61g2nXGUhM4iCL3ewB6LDXZCtioEB readme', - 'added QmapdaVPjHXdcswef82FnGQUauMNpk9xYFkLDZKgAxhMwq' - ].join('\n') + '\n') - }) - - it('add with cid-version=0', async function () { - this.timeout(30 * 1000) - - const out = await ipfs('add src/init-files/init-docs/readme --cid-version=0') - expect(out) - .to.eql('added QmPZ9gcCEpqKTo6aq61g2nXGUhM4iCL3ewB6LDXZCtioEB readme\n') - }) - - it('add with cid-version=1 < default max chunk size', async function () { - this.timeout(30 * 1000) - - const out = await ipfs('add test/fixtures/less-than-default-max-chunk-size --cid-version=1') - expect(out) - .to.eql('added bafkreie3abdlmy7dtxddm4vkbhd2x2yax5scf4m35eyxf3ywj2uwkjbhgi less-than-default-max-chunk-size\n') - }) - - it('add with cid-version=1 > default max chunk size', async function () { - this.timeout(30 * 1000) - - const out = await ipfs('add test/fixtures/greater-than-default-max-chunk-size --cid-version=1') - expect(out) - .to.eql('added bafybeiebjiahgamnil3r3os2hqorjualrgx6hpqh5zuqbhjmt7tyjqqttm greater-than-default-max-chunk-size\n') - }) - - it('add with cid-version=1 and raw-leaves=false < default max chunk size', async function () { - this.timeout(30 * 1000) - - const out = await ipfs('add test/fixtures/less-than-default-max-chunk-size --cid-version=1 --raw-leaves=false') - expect(out) - .to.eql('added bafybeiaoh5okvpnuhndsz4kgdhulnkm566rz7w7il6r2zm6wxu5f5uqlsu less-than-default-max-chunk-size\n') - }) - - it('add with cid-version=1 and raw-leaves=false > default max chunk size', async function () { - this.timeout(30 * 1000) - - const out = await ipfs('add test/fixtures/greater-than-default-max-chunk-size --cid-version=1 --raw-leaves=false') - expect(out) - .to.eql('added bafybeiajpcrr2qglyeq3biilzt25ty6kpjs7huy2lfxopqfke6riaaxnim greater-than-default-max-chunk-size\n') - }) - - it('add with cid-version=1 and raw-leaves=true < default max chunk size', async function () { - this.timeout(30 * 1000) - - const out = await ipfs('add test/fixtures/less-than-default-max-chunk-size --cid-version=1 --raw-leaves=true') - expect(out) - .to.eql('added bafkreie3abdlmy7dtxddm4vkbhd2x2yax5scf4m35eyxf3ywj2uwkjbhgi less-than-default-max-chunk-size\n') - }) - - it('add with cid-version=1 and raw-leaves=true > default max chunk size', async function () { - this.timeout(30 * 1000) - - const out = await ipfs('add test/fixtures/greater-than-default-max-chunk-size --cid-version=1 --raw-leaves=true') - expect(out) - .to.eql('added bafybeiebjiahgamnil3r3os2hqorjualrgx6hpqh5zuqbhjmt7tyjqqttm greater-than-default-max-chunk-size\n') - }) - it('add from pipe', async () => { const proc = ipfs('add') proc.stdin.write(Buffer.from('hello\n')) @@ -291,68 +81,6 @@ describe('files', () => runOnAndOff((thing) => { .to.eql('') }) - it('add --only-hash outputs correct hash', async function () { - const out = await ipfs('add --only-hash src/init-files/init-docs/readme') - expect(out) - .to.eql('added QmPZ9gcCEpqKTo6aq61g2nXGUhM4iCL3ewB6LDXZCtioEB readme\n') - }) - - it('add --only-hash does not add a file to the datastore', async function () { - this.timeout(30 * 1000) - this.slow(10 * 1000) - const content = hat() - const filepath = path.join(os.tmpdir(), `${content}.txt`) - fs.writeFileSync(filepath, content) - - const out = await ipfs(`add --only-hash ${filepath}`) - const hash = out.split(' ')[1] - - // 'jsipfs object get ' should timeout with the daemon on - // and should fail fast with the daemon off - await Promise.race([ - ipfs.fail(`object get ${hash}`), - delay(4000) - ]) - await clean(filepath) - }) - - it('add pins by default', async function () { - this.timeout(10 * 1000) - const filePath = path.join(os.tmpdir(), hat()) - const content = hat() - fs.writeFileSync(filePath, content) - - const out = await ipfs(`add -Q ${filePath}`) - const hash = out.trim() - const ls = await ipfs(`pin ls ${hash}`) - expect(ls).to.include(hash) - - await clean(filePath) - }) - - it('add does not pin with --pin=false', async function () { - this.timeout(20 * 1000) - const filePath = path.join(os.tmpdir(), hat()) - const content = hat() - fs.writeFileSync(filePath, content) - - const out = await ipfs(`add -Q --pin=false ${filePath}`) - await ipfs.fail(`pin ls ${out.trim()}`) - - await clean(filePath) - }) - - HASH_ALGS.forEach((name) => { - it(`add with hash=${name} and raw-leaves=false`, async function () { - this.timeout(30 * 1000) - - const out = await ipfs(`add src/init-files/init-docs/readme --hash=${name} --raw-leaves=false`) - const hash = out.split(' ')[1] - const cid = new CID(hash) - expect(mh.decode(cid.multihash).name).to.equal(name) - }) - }) - it('should add and print CID encoded in specified base', async function () { this.timeout(30 * 1000) @@ -367,21 +95,8 @@ describe('files', () => runOnAndOff((thing) => { expect(out).to.eql(readme) }) - it('cat part of a file using `count`', async function () { - this.timeout(30 * 1000) - - const out = await ipfs('cat QmPZ9gcCEpqKTo6aq61g2nXGUhM4iCL3ewB6LDXZCtioEB --offset 21 --count 5') - expect(out).to.eql(readme.substring(21, 26)) - }) - - it('cat part of a file using `length`', async function () { - this.timeout(30 * 1000) - - const out = await ipfs('cat QmPZ9gcCEpqKTo6aq61g2nXGUhM4iCL3ewB6LDXZCtioEB --offset 21 --length 5') - expect(out).to.eql(readme.substring(21, 26)) - }) - it('cat non-existent file', async () => { + // TODO test a specific error const err = await ipfs.fail('cat QmPZ9gcCEpqKTo6aq61g2nXGUhM4iCL3ewB6LDXZCtioEB/dummy') expect(err).to.exist() }) @@ -400,21 +115,8 @@ describe('files', () => runOnAndOff((thing) => { rimraf(file) }) - it('get alias', async function () { - this.timeout(20 * 1000) - - const out = await ipfs('get QmPZ9gcCEpqKTo6aq61g2nXGUhM4iCL3ewB6LDXZCtioEB') - expect(out) - .to.eql('Saving file(s) QmPZ9gcCEpqKTo6aq61g2nXGUhM4iCL3ewB6LDXZCtioEB\n') - - const file = path.join(process.cwd(), 'QmPZ9gcCEpqKTo6aq61g2nXGUhM4iCL3ewB6LDXZCtioEB') - - expect(fs.readFileSync(file).toString()).to.eql(readme) - - rimraf(file) - }) - - it('get recursively', async function () { + // TODO depends on others fix! + it.skip('get recursively', async function () { this.timeout(20 * 1000) const outDir = path.join(process.cwd(), 'QmTCaAvZ5dquoa2jrgTRa3gn9n4Ymrz8mEdePP8jiaTvf9') diff --git a/test/cli/init.js b/test/cli/init.js index d3614a18f1..9e729792c5 100644 --- a/test/cli/init.js +++ b/test/cli/init.js @@ -51,20 +51,6 @@ describe('init', function () { expect(out2).to.equal(readme) }) - it('bits', async function () { - await ipfs('init --bits 1024') - expect(repoDirSync('blocks')).to.have.length.above(2) - expect(repoExistsSync('config')).to.equal(true) - expect(repoExistsSync('version')).to.equal(true) - }) - - it('empty', async function () { - await ipfs('init --bits 1024 --empty-repo true') - expect(repoDirSync('blocks')).to.have.length(2) - expect(repoExistsSync('config')).to.equal(true) - expect(repoExistsSync('version')).to.equal(true) - }) - it('profile', async function () { this.timeout(40 * 1000) @@ -72,14 +58,6 @@ describe('init', function () { expect(repoConfSync().Swarm.ConnMgr.LowWater).to.equal(20) }) - it('profile multiple', async function () { - this.timeout(40 * 1000) - - await ipfs('init --profile server,lowpower') - expect(repoConfSync().Discovery.MDNS.Enabled).to.equal(false) - expect(repoConfSync().Swarm.ConnMgr.LowWater).to.equal(20) - }) - it('profile non-existent', async function () { this.timeout(40 * 1000) @@ -88,17 +66,6 @@ describe('init', function () { .and.to.have.property('stdout').that.includes('Could not find profile') }) - it('should present ipfs path help when option help is received', async function () { - const res = await ipfs('init --help') - - expect(res).to.have.string('export IPFS_PATH=/path/to/ipfsrepo') - }) - - it('should present ipfs path help when option help is received', async function () { - const res = await ipfs('init --help') - expect(res).to.have.string('export IPFS_PATH=/path/to/ipfsrepo') - }) - it('default config argument', async () => { const configPath = tempWrite.sync('{"Addresses": {"API": "/ip4/127.0.0.1/tcp/9999"}}', 'config.json') await ipfs(`init ${configPath}`) @@ -106,4 +73,6 @@ describe('init', function () { const config = JSON.parse(configRaw) expect(config.Addresses.API).to.be.eq('/ip4/127.0.0.1/tcp/9999') }) + + // TODO test error for the config arg }) diff --git a/test/cli/key.js b/test/cli/key.js index 90b5992421..f3bc8b64ea 100644 --- a/test/cli/key.js +++ b/test/cli/key.js @@ -17,28 +17,28 @@ describe('key', () => runOnAndOff.off((thing) => { it('gen', async function () { this.timeout(40 * 1000) - + // TODO test the full output const out = await ipfs(`${pass} key gen ${name} --type rsa --size 2048`) expect(out).to.include(name) }) it('list', async function () { this.timeout(20 * 1000) - + // TODO test the full output const out = await ipfs(`${pass} key list`) expect(out).to.include(name) }) it('rename', async function () { this.timeout(20 * 1000) - + // TODO test the full output const out = await ipfs(`${pass} key rename ${name} ${newName}`) expect(out).to.include(newName) }) it('rm', async function () { this.timeout(20 * 1000) - + // TODO test the full output const out = await ipfs(`${pass} key rm ${newName}`) expect(out).to.include(newName) }) diff --git a/test/cli/ls.js b/test/cli/ls.js index dc4d1de661..1ba02482b1 100644 --- a/test/cli/ls.js +++ b/test/cli/ls.js @@ -64,15 +64,6 @@ describe('ls', () => runOnAndOff((thing) => { ) }) - it('supports recursive listing through intermediate directories', async function () { - this.timeout(20 * 1000) - const out = await ipfs('ls -r Qmaj2NmcyAXT8dFmZRRytE12wpcaHADzbChKToMEjBsj5Z/blocks/CIQLB') - expect(out).to.eql( - 'QmQ8ag7ysVyCMzJGFjxrUStwWtniQ69c7G9aezbmsKeNYD 10849 CIQLBK52T5EHVHZY5URTG5JS3JCUJDQM2DRB5RVF33DCUUOFJNGVDUI.data\n' + - 'QmaSjzSSRanYzRGPXQY6m5SWfSkkfcnzNkurJEQc4chPJx 10807 CIQLBS5HG4PRCRQ7O4EBXFD5QN6MTI5YBYMCVQJDXPKCOVR6RMLHZFQ.data\n' - ) - }) - it('prints nothing for non-existant hashes', async function () { if (thing.on) { // If the daemon is on, ls should search until it hits a timeout @@ -99,41 +90,6 @@ describe('ls', () => runOnAndOff((thing) => { ) }) - it('follows a path, /', async function () { - this.timeout(20 * 1000) - - const out = await ipfs('ls /ipfs/Qmaj2NmcyAXT8dFmZRRytE12wpcaHADzbChKToMEjBsj5Z/init-docs') - expect(out).to.eql( - 'QmZTR5bcpQD7cFgTorqxZDYaew1Wqgfbd2ud9QqGPAkK2V 1677 about\n' + - 'QmYCvbfNbCwFR45HiNP45rwJgvatpiW38D961L5qAhUM5Y 189 contact\n' + - 'QmegvLXxpVKiZ4b57Xs1syfBVRd8CbucVHAp7KpLQdGieC - docs/\n' + - 'QmY5heUM5qgRubMDD1og9fhCPA6QdkMp3QCwd4s7gJsyE7 311 help\n' + - 'QmdncfsVm2h5Kqq9hPmU7oAVX2zTSVP3L869tgTbPYnsha 1717 quick-start\n' + - 'QmPZ9gcCEpqKTo6aq61g2nXGUhM4iCL3ewB6LDXZCtioEB 1091 readme\n' + - 'QmTumTjvcYCAvRRwQ8sDRxh8ezmrcr88YFU7iYNroGGTBZ 1016 security-notes\n' + - 'QmciSU8hfpAXKjvK5YLUSwApomGSWN5gFbP4EpDAEzu2Te - tour/\n' - ) - }) - - it('recursively follows folders, -r', async function () { - this.slow(2000) - this.timeout(20 * 1000) - - const out = await ipfs('ls -r /ipfs/Qmaj2NmcyAXT8dFmZRRytE12wpcaHADzbChKToMEjBsj5Z/init-docs') - expect(out).to.eql( - 'QmZTR5bcpQD7cFgTorqxZDYaew1Wqgfbd2ud9QqGPAkK2V 1677 about\n' + - 'QmYCvbfNbCwFR45HiNP45rwJgvatpiW38D961L5qAhUM5Y 189 contact\n' + - 'QmegvLXxpVKiZ4b57Xs1syfBVRd8CbucVHAp7KpLQdGieC - docs/\n' + - 'QmQN88TEidd3RY2u3dpib49fERTDfKtDpvxnvczATNsfKT 6 index\n' + - 'QmY5heUM5qgRubMDD1og9fhCPA6QdkMp3QCwd4s7gJsyE7 311 help\n' + - 'QmdncfsVm2h5Kqq9hPmU7oAVX2zTSVP3L869tgTbPYnsha 1717 quick-start\n' + - 'QmPZ9gcCEpqKTo6aq61g2nXGUhM4iCL3ewB6LDXZCtioEB 1091 readme\n' + - 'QmTumTjvcYCAvRRwQ8sDRxh8ezmrcr88YFU7iYNroGGTBZ 1016 security-notes\n' + - 'QmciSU8hfpAXKjvK5YLUSwApomGSWN5gFbP4EpDAEzu2Te - tour/\n' + - 'QmYE7xo6NxbHEVEHej1yzxijYaNY51BaeKxjXxn6Ssa6Bs 796 0.0-intro\n' - ) - }) - it('should ls and print CIDs encoded in specified base', async function () { this.timeout(20 * 1000) diff --git a/test/cli/object.js b/test/cli/object.js index 7ccdb856f9..3308577eab 100644 --- a/test/cli/object.js +++ b/test/cli/object.js @@ -2,14 +2,9 @@ /* eslint-env mocha */ 'use strict' -const hat = require('hat') const { expect } = require('interface-ipfs-core/src/utils/mocha') const runOnAndOff = require('../utils/on-and-off') -const UnixFs = require('ipfs-unixfs') const path = require('path') -const fs = require('fs') -const crypto = require('crypto') -const os = require('os') const multibase = require('multibase') describe('object', () => runOnAndOff((thing) => { @@ -19,20 +14,6 @@ describe('object', () => runOnAndOff((thing) => { ipfs = thing.ipfs }) - it('new', async () => { - const out = await ipfs('object new') - expect(out).to.eql( - 'QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n\n' - ) - }) - - it('new unixfs-dir', async () => { - const out = await ipfs('object new unixfs-dir') - expect(out).to.eql( - 'QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn\n' - ) - }) - // TODO: unskip after switch to v1 CIDs by default it.skip('should new and print CID encoded in specified base', async () => { const out = await ipfs('object new --cid-base=base64') @@ -48,17 +29,6 @@ describe('object', () => runOnAndOff((thing) => { expect(result.Data).to.eql('') }) - it('get with data', async function () { - this.timeout(15 * 1000) - - const out = await ipfs('object new') - const out2 = await ipfs(`object patch set-data ${out.trim()} ${path.resolve(path.join(__dirname, '..'))}/fixtures/test-data/hello`) - const res = await ipfs(`object get ${out2.trim()}`) - const result = JSON.parse(res) - - expect(result.Data).to.eql('aGVsbG8gd29ybGQK') - }) - it('get while overriding data-encoding', async function () { this.timeout(15 * 1000) @@ -93,6 +63,8 @@ describe('object', () => runOnAndOff((thing) => { ) }) + // TODO test stdin input + // TODO: unskip after switch to v1 CIDs by default it.skip('should put and print CID encoded in specified base', async () => { const out = await ipfs(`object put ${path.resolve(path.join(__dirname, '..'))}/fixtures/test-data/node.json --cid-base=base64`) @@ -120,23 +92,6 @@ describe('object', () => runOnAndOff((thing) => { expect(out).to.eql('another') }) - it('unaltered data', async function () { - this.timeout(10 * 1000) - - // has to be big enough to span several DAGNodes - const data = crypto.randomBytes(1024 * 300) - const file = path.join(os.tmpdir(), `file-${hat()}.txt`) - - fs.writeFileSync(file, data) - - const out = await ipfs(`add ${file}`) - const out2 = await ipfs.raw(`object data ${out.split(' ')[1]}`) - const meta = UnixFs.unmarshal(out2) - - expect(meta.type).to.equal('file') - expect(meta.fileSize()).to.equal(data.length) - }) - it('links', async () => { const out = await ipfs('object links QmZZmY4KCu9r3e7M2Pcn46Fc5qbn6NpzaAGaYb22kbfTqm') expect(out).to.eql( diff --git a/test/cli/ping.js b/test/cli/ping.js index ef59ce51e7..49cb25539f 100644 --- a/test/cli/ping.js +++ b/test/cli/ping.js @@ -58,37 +58,5 @@ describe('ping', function () { expect(result[11]).to.match(/^Average latency: \d+(.\d+)?ms$/) }) - it('ping host with --n option', async () => { - this.timeout(60 * 1000) - const ping = cli(`ping --n 1 ${ipfsdBId}`) - const result = [] - ping.stdout.on('data', (output) => { - const packets = output.toString().split('\n').slice(0, -1) - result.push(...packets) - }) - - await ping - - expect(result).to.have.lengthOf(3) - expect(result[0]).to.equal(`PING ${ipfsdBId}`) - expect(result[1]).to.match(/^Pong received: time=\d+ ms$/) - expect(result[2]).to.match(/^Average latency: \d+(.\d+)?ms$/) - }) - - it('ping host with --count option', async () => { - this.timeout(60 * 1000) - const ping = cli(`ping --count 1 ${ipfsdBId}`) - const result = [] - ping.stdout.on('data', (output) => { - const packets = output.toString().split('\n').slice(0, -1) - result.push(...packets) - }) - - await ping - - expect(result).to.have.lengthOf(3) - expect(result[0]).to.equal(`PING ${ipfsdBId}`) - expect(result[1]).to.match(/^Pong received: time=\d+ ms$/) - expect(result[2]).to.match(/^Average latency: \d+(.\d+)?ms$/) - }) + // TODO test error }) diff --git a/test/cli/repo.js b/test/cli/repo.js index 4eaf0dea59..32b9c215f7 100644 --- a/test/cli/repo.js +++ b/test/cli/repo.js @@ -2,7 +2,6 @@ 'use strict' const { expect } = require('interface-ipfs-core/src/utils/mocha') -const repoVersion = require('ipfs-repo').repoVersion const runOnAndOff = require('../utils/on-and-off') describe('repo', () => runOnAndOff((thing) => { @@ -12,15 +11,6 @@ describe('repo', () => runOnAndOff((thing) => { ipfs = thing.ipfs }) - it('get repo stats', async () => { - const stats = await ipfs('repo stat') - expect(stats).to.match(/^NumObjects:\s\d+$/m) - expect(stats).to.match(/^RepoSize:\s\d+$/m) - expect(stats).to.match(/^StorageMax:\s\d+$/m) - expect(stats).to.match(/^RepoPath:\s.+$/m) - expect(stats).to.match(/^Version:\s\d+$/m) - }) - it('get human readable repo stats', async () => { const stats = await ipfs('repo stat --human') expect(stats).to.match(/^NumObjects:\s\d+$/m) @@ -29,9 +19,4 @@ describe('repo', () => runOnAndOff((thing) => { expect(stats).to.match(/^RepoPath:\s.+$/m) expect(stats).to.match(/^Version:\s\d+$/m) }) - - it('get the repo version', async () => { - const out = await ipfs('repo version') - expect(out).to.eql(`${repoVersion}\n`) - }) })) diff --git a/test/cli/swarm.js b/test/cli/swarm.js index 9fac1ceadd..f588ab282a 100644 --- a/test/cli/swarm.js +++ b/test/cli/swarm.js @@ -4,11 +4,7 @@ const { expect } = require('interface-ipfs-core/src/utils/mocha') const sinon = require('sinon') -const multiaddr = require('multiaddr') -const PeerInfo = require('peer-info') const ipfsExec = require('../utils/ipfs-exec') -const PeerId = require('peer-id') -const addrsCommand = require('../../src/cli/commands/swarm/addrs') const factory = require('../utils/factory') describe('swarm', () => { @@ -70,50 +66,7 @@ describe('swarm', () => { const out = await ipfsA('swarm peers') expect(out).to.be.empty() }) - }) - - describe('handlers', () => { - let peerInfo - const ipfs = { - swarm: { addrs: () => {} } - } - const argv = { - resolve: () => {}, - getIpfs: () => ipfs - } - - describe('addrs', () => { - before((done) => { - PeerId.create({ bits: 512 }, (err, peerId) => { - if (err) return done(err) - peerInfo = new PeerInfo(peerId) - done() - }) - }) - - it('should return addresses for all peers', (done) => { - sinon.stub(argv, 'resolve').callsFake(promise => { - promise.then(({ data }) => { - expect(data).to.eql([ - `${peerInfo.id.toB58String()} (2)`, - '\t/ip4/127.0.0.1/tcp/4001', - '\t/ip4/127.0.0.1/tcp/4001/ws' - ].join('\n')) - done() - }) - }) - sinon.stub(peerInfo.multiaddrs, '_multiaddrs').value([ - multiaddr('/ip4/127.0.0.1/tcp/4001'), - multiaddr(`/ip4/127.0.0.1/tcp/4001/ws/ipfs/${peerInfo.id.toB58String()}`) - ]) - - sinon.stub(ipfs.swarm, 'addrs').returns( - Promise.resolve([peerInfo]) - ) - - addrsCommand.handler(argv) - }) - }) + // TODO these tests above need to be standalone }) }) diff --git a/test/cli/version.js b/test/cli/version.js index 4aa053ccad..f91d4cc926 100644 --- a/test/cli/version.js +++ b/test/cli/version.js @@ -31,6 +31,7 @@ describe('version', () => runOnAndOff((thing) => { }) describe('handles --all', function () { + // TODO merge all of these it('prints js-ipfs version', async () => { const out = await ipfs('version --all') expect(out).to.include(`js-ipfs version: ${pkgversion}`) diff --git a/test/core/bootstrap.spec.js b/test/core/bootstrap.spec.js index 97ef5f7dfe..d7ce812362 100644 --- a/test/core/bootstrap.spec.js +++ b/test/core/bootstrap.spec.js @@ -47,38 +47,4 @@ describe('bootstrap', () => { expect(list.Peers).to.deep.equal(defaultList) } }) - - it('add a peer to the bootstrap list', async () => { - const peer = '/ip4/111.111.111.111/tcp/1001/ipfs/QmXFX2P5ammdmXQgfqGkfswtEVFsZUJ5KeHRXQYCTdiTAb' - const res = await node.bootstrap.add(peer) - expect(res).to.be.eql({ Peers: [peer] }) - const list = await node.bootstrap.list() - - if (isBrowser || isWebWorker) { - expect(list.Peers).to.deep.equal(browserList.concat([peer])) - } else { - expect(list.Peers).to.deep.equal(defaultList.concat([peer])) - } - }) - - it('remove a peer from the bootstrap list', async () => { - const peer = '/ip4/111.111.111.111/tcp/1001/ipfs/QmXFX2P5ammdmXQgfqGkfswtEVFsZUJ5KeHRXQYCTdiTAb' - const res = await node.bootstrap.rm(peer) - expect(res).to.be.eql({ Peers: [peer] }) - const list = await node.bootstrap.list() - if (isBrowser || isWebWorker) { - expect(list.Peers).to.deep.equal(browserList) - } else { - expect(list.Peers).to.deep.equal(defaultList) - } - }) - - it('fails if passing in a invalid multiaddr', (done) => { - node.bootstrap.add('/funky/invalid/multiaddr', (err, res) => { - expect(err).to.match(/not a valid Multiaddr/) - expect(err).to.match(/funky/) - expect(res).to.not.exist() - done() - }) - }) }) diff --git a/test/core/dht.spec.js b/test/core/dht.spec.js index 751c860228..007efaeaf6 100644 --- a/test/core/dht.spec.js +++ b/test/core/dht.spec.js @@ -38,7 +38,7 @@ describe.skip('dht', () => { const df = factory() let ipfsd, ipfs - before(async function (done) { + before(async function () { this.timeout(30 * 1000) ipfsd = await df.spawn() diff --git a/test/core/files.spec.js b/test/core/files.spec.js index 260995defe..4d8e03142f 100644 --- a/test/core/files.spec.js +++ b/test/core/files.spec.js @@ -62,26 +62,5 @@ describe('files', function () { it('should not error when passed null options', async () => { await ipfs.add(Buffer.from(hat()), null) }) - - it('should add a file with a v1 CID', async () => { - const files = await ipfs.add(Buffer.from([0, 1, 2]), { - cidVersion: 1 - }) - - expect(files.length).to.equal(1) - expect(files[0].hash).to.equal('bafkreifojmzibzlof6xyh5auu3r5vpu5l67brf3fitaf73isdlglqw2t7q') - expect(files[0].size).to.equal(3) - }) - - it('should add a file with a v1 CID and not raw leaves', async () => { - const files = await ipfs.add(Buffer.from([0, 1, 2]), { - cidVersion: 1, - rawLeaves: false - }) - - expect(files.length).to.equal(1) - expect(files[0].hash).to.equal('bafybeide2caf5we5a7izifzwzz5ds2gla67vsfgrzvbzpnyyirnfzgwf5e') - expect(files[0].size).to.equal(11) - }) }) }) diff --git a/test/core/interface.spec.js b/test/core/interface.spec.js index 12bb06f148..f1a07c39ba 100644 --- a/test/core/interface.spec.js +++ b/test/core/interface.spec.js @@ -46,7 +46,12 @@ describe('interface-ipfs-core tests', function () { tests.config(commonFactory) - tests.dag(commonFactory) + tests.dag(commonFactory, { + skip: [{ + name: 'should error when missing DAG resolver for multicodec from requested CID', + reason: 'js-ipfs loads all the ipld formats so there no missing resolvers' + }] + }) tests.dht(commonFactory, { skip: { diff --git a/test/core/ping.spec.js b/test/core/ping.spec.js index 67c5e81159..8fa83eb5cf 100644 --- a/test/core/ping.spec.js +++ b/test/core/ping.spec.js @@ -16,90 +16,6 @@ describe('ping', function () { this.timeout(60 * 1000) const df = factory() - describe('in-process daemon', function () { - let ipfsdA - let ipfsdB - let bMultiaddr - let ipfsdBId - - // Spawn nodes - before(async function () { - ipfsdA = await df.spawn({ type: 'proc' }) - ipfsdB = await df.spawn({ type: 'js' }) - ipfsdBId = ipfsdB.api.peerId.id - bMultiaddr = ipfsdB.api.peerId.addresses[0] - await ipfsdA.api.swarm.connect(bMultiaddr) - }) - - after(() => df.clean()) - - it('can ping via a promise without options', async () => { - const res = await ipfsdA.api.ping(ipfsdBId) - - expect(res.length).to.be.ok() - expect(res[0].success).to.be.true() - }) - }) - - describe('DHT disabled', function () { - // Without DHT nodes need to be previously connected - let ipfsdA - let ipfsdB - let bMultiaddr - let ipfsdBId - - // Spawn nodes - before(async function () { - ipfsdA = await df.spawn({ type: 'proc' }) - ipfsdB = await df.spawn({ type: 'js' }) - ipfsdBId = ipfsdB.api.peerId.id - bMultiaddr = ipfsdB.api.peerId.addresses[0] - await ipfsdA.api.swarm.connect(bMultiaddr) - }) - - after(() => df.clean()) - - it('sends the specified number of packets', (done) => { - let packetNum = 0 - const count = 3 - pull( - ipfsdA.api.pingPullStream(ipfsdBId, { count }), - drain((res) => { - expect(res.success).to.be.true() - // It's a pong - if (isPong(res)) { - packetNum++ - } - }, (err) => { - expect(err).to.not.exist() - expect(packetNum).to.equal(count) - done() - }) - ) - }) - - it('pinging a not available peer will fail accordingly', (done) => { - const unknownPeerId = 'QmUmaEnH1uMmvckMZbh3yShaasvELPW4ZLPWnB4entMTEn' - let messageNum = 0 - // const count = 1 - pull( - ipfsdA.api.pingPullStream(unknownPeerId, {}), - drain(({ success, time, text }) => { - messageNum++ - // Assert that the ping command falls back to the peerRouting - if (messageNum === 1) { - expect(text).to.include('Looking up') - } - }, (err) => { - expect(err).to.exist() - // FIXME when we can have streaming - // expect(messageNum).to.equal(count) - done() - }) - ) - }) - }) - // TODO: unskip when DHT is enabled: https://github.com/ipfs/js-ipfs/pull/1994 describe.skip('DHT enabled', function () { // Our bootstrap process will run 3 IPFS daemons where