From b27658c4619f80d0f9b90e01d7f7c369f9deccb3 Mon Sep 17 00:00:00 2001 From: Alan Shaw Date: Tue, 5 Jun 2018 14:12:58 +0100 Subject: [PATCH 01/20] feat: uses modular interface tests Reduces code repetition, allows test skipping and running only some tests. License: MIT Signed-off-by: Alan Shaw --- test/interface.spec.js | 114 +++++++++++++++++++++++++ test/interface/block.spec.js | 32 ------- test/interface/bootstrap.spec.js | 32 ------- test/interface/config.spec.js | 32 ------- test/interface/dag.spec.js | 34 -------- test/interface/dht.spec.js | 31 ------- test/interface/files-mfs.spec.js | 32 ------- test/interface/files.spec.js | 32 ------- test/interface/key.spec.js | 32 ------- test/interface/miscellaneous.spec.js | 33 ------- test/interface/object.spec.js | 32 ------- test/interface/pin.spec.js | 32 ------- test/interface/ping.spec.js | 32 ------- test/interface/pubsub.spec.js | 37 -------- test/interface/repo.spec.js | 32 ------- test/interface/stats.spec.js | 32 ------- test/interface/swarm.spec.js | 42 --------- test/utils/interface-common-factory.js | 49 +++++++++++ 18 files changed, 163 insertions(+), 529 deletions(-) create mode 100644 test/interface.spec.js delete mode 100644 test/interface/block.spec.js delete mode 100644 test/interface/bootstrap.spec.js delete mode 100644 test/interface/config.spec.js delete mode 100644 test/interface/dag.spec.js delete mode 100644 test/interface/dht.spec.js delete mode 100644 test/interface/files-mfs.spec.js delete mode 100644 test/interface/files.spec.js delete mode 100644 test/interface/key.spec.js delete mode 100644 test/interface/miscellaneous.spec.js delete mode 100644 test/interface/object.spec.js delete mode 100644 test/interface/pin.spec.js delete mode 100644 test/interface/ping.spec.js delete mode 100644 test/interface/pubsub.spec.js delete mode 100644 test/interface/repo.spec.js delete mode 100644 test/interface/stats.spec.js delete mode 100644 test/interface/swarm.spec.js create mode 100644 test/utils/interface-common-factory.js diff --git a/test/interface.spec.js b/test/interface.spec.js new file mode 100644 index 000000000..8e2b16023 --- /dev/null +++ b/test/interface.spec.js @@ -0,0 +1,114 @@ +/* eslint-env mocha */ +'use strict' + +const tests = require('interface-ipfs-core') +const CommonFactory = require('./utils/interface-common-factory') +const IPFSApi = require('../src') + +describe('interface-ipfs-core tests', () => { + const defaultCommonFactory = CommonFactory.create() + + tests.block(defaultCommonFactory) + + tests.bootstrap(defaultCommonFactory) + + tests.config(defaultCommonFactory) + + tests.dag(defaultCommonFactory, { + skip: [ + // dag.tree + // + // FIXME vmx 2018-02-22: Currently the tree API is not exposed in go-ipfs + 'tree', + // dag.get: + // + // FIXME vmx 2018-02-22: Currently not supported in go-ipfs, it might + // be possible once https://github.com/ipfs/go-ipfs/issues/4728 is + // done + 'should get a dag-pb node local value', + 'should get dag-pb value via dag-cbor node', + 'should get by CID string + path', + // dag.put + // + // FIXME This works in go-ipfs because dag-pb will serialize any object. If + // the object has neither a `data` nor `links` field it's serialized + // as an empty object + 'should not put dag-cbor node with wrong multicodec' + ] + }) + + tests.dht(defaultCommonFactory, { + skip: [ + // dht.findpeer + // + // FIXME checking what is exactly go-ipfs returning + // https://github.com/ipfs/go-ipfs/issues/3862#issuecomment-294168090 + 'should fail to find other peer if peer does not exist', + // dht.findprovs + // + // FIXME go-ipfs endpoint doesn't conform with the others + // https://github.com/ipfs/go-ipfs/issues/5047 + 'should provide from one node and find it through another node', + // dht.get + // + // FIXME go-ipfs errors with Error: key was not found (type 6) + // https://github.com/ipfs/go-ipfs/issues/3862 + 'should get a value after it was put on another node' + ] + }) + + tests.files(defaultCommonFactory) + + tests.generic(CommonFactory.create({ + // No need to stop, because the test suite does a 'stop' test. + createTeardown: cb => cb() + })) + + tests.key(defaultCommonFactory) + + tests.object(defaultCommonFactory) + + tests.ping(defaultCommonFactory) + + tests.pubsub(CommonFactory.create({ + spawnOptions: { + args: ['--enable-pubsub-experiment'], + initOptions: { bits: 1024 } + } + })) + + tests.repo(defaultCommonFactory) + + tests.stats(defaultCommonFactory) + + tests.swarm(CommonFactory.create({ + createSetup ({ ipfsFactory, nodes }) { + return callback => { + callback(null, { + spawnNode (repoPath, config, cb) { + if (typeof repoPath === 'function') { + cb = repoPath + repoPath = undefined + } + + if (typeof config === 'function') { + cb = config + config = undefined + } + + const spawnOptions = { repoPath, config, initOptions: { bits: 1024 } } + + ipfsFactory.spawn(spawnOptions, (err, _ipfsd) => { + if (err) { + return cb(err) + } + + nodes.push(_ipfsd) + cb(null, IPFSApi(_ipfsd.apiAddr)) + }) + } + }) + } + } + })) +}) diff --git a/test/interface/block.spec.js b/test/interface/block.spec.js deleted file mode 100644 index 180f17a04..000000000 --- a/test/interface/block.spec.js +++ /dev/null @@ -1,32 +0,0 @@ -/* eslint-env mocha */ - -'use strict' - -const test = require('interface-ipfs-core') -const parallel = require('async/parallel') - -const IPFSApi = require('../../src') -const f = require('../utils/factory') - -const nodes = [] -const common = { - setup: function (callback) { - callback(null, { - spawnNode: (cb) => { - f.spawn({ initOptions: { bits: 1024 } }, (err, _ipfsd) => { - if (err) { - return cb(err) - } - - nodes.push(_ipfsd) - cb(null, IPFSApi(_ipfsd.apiAddr)) - }) - } - }) - }, - teardown: function (callback) { - parallel(nodes.map((node) => (cb) => node.stop(cb)), callback) - } -} - -test.block(common) diff --git a/test/interface/bootstrap.spec.js b/test/interface/bootstrap.spec.js deleted file mode 100644 index caea5856e..000000000 --- a/test/interface/bootstrap.spec.js +++ /dev/null @@ -1,32 +0,0 @@ -/* eslint-env mocha */ - -'use strict' - -const test = require('interface-ipfs-core') -const parallel = require('async/parallel') - -const IPFSApi = require('../../src') -const f = require('../utils/factory') - -const nodes = [] -const common = { - setup: function (callback) { - callback(null, { - spawnNode: (cb) => { - f.spawn({ initOptions: { bits: 1024 } }, (err, _ipfsd) => { - if (err) { - return cb(err) - } - - nodes.push(_ipfsd) - cb(null, IPFSApi(_ipfsd.apiAddr)) - }) - } - }) - }, - teardown: function (callback) { - parallel(nodes.map((node) => (cb) => node.stop(cb)), callback) - } -} - -test.bootstrap(common) diff --git a/test/interface/config.spec.js b/test/interface/config.spec.js deleted file mode 100644 index aeb4a6a9a..000000000 --- a/test/interface/config.spec.js +++ /dev/null @@ -1,32 +0,0 @@ -/* eslint-env mocha */ -/* eslint max-nested-callbacks: ["error", 8] */ -'use strict' - -const test = require('interface-ipfs-core') -const parallel = require('async/parallel') - -const IPFSApi = require('../../src') -const f = require('../utils/factory') - -const nodes = [] -const common = { - setup: function (callback) { - callback(null, { - spawnNode: (cb) => { - f.spawn({ initOptions: { bits: 1024 } }, (err, _ipfsd) => { - if (err) { - return cb(err) - } - - nodes.push(_ipfsd) - cb(null, IPFSApi(_ipfsd.apiAddr)) - }) - } - }) - }, - teardown: function (callback) { - parallel(nodes.map((node) => (cb) => node.stop(cb)), callback) - } -} - -test.config(common) diff --git a/test/interface/dag.spec.js b/test/interface/dag.spec.js deleted file mode 100644 index 6c68680e7..000000000 --- a/test/interface/dag.spec.js +++ /dev/null @@ -1,34 +0,0 @@ -/* eslint-env mocha */ - -'use strict' - -const test = require('interface-ipfs-core') -const parallel = require('async/parallel') - -const IPFSApi = require('../../src') - -const DaemonFactory = require('ipfsd-ctl') -const df = DaemonFactory.create() - -const nodes = [] -const common = { - setup: function (callback) { - callback(null, { - spawnNode: (cb) => { - df.spawn((err, _ipfsd) => { - if (err) { - return cb(err) - } - - nodes.push(_ipfsd) - cb(null, IPFSApi(_ipfsd.apiAddr)) - }) - } - }) - }, - teardown: function (callback) { - parallel(nodes.map((node) => (cb) => node.stop(cb)), callback) - } -} - -test.dag(common) diff --git a/test/interface/dht.spec.js b/test/interface/dht.spec.js deleted file mode 100644 index 2b324cb99..000000000 --- a/test/interface/dht.spec.js +++ /dev/null @@ -1,31 +0,0 @@ -/* eslint-env mocha */ -'use strict' - -const test = require('interface-ipfs-core') -const parallel = require('async/parallel') - -const IPFSApi = require('../../src') -const f = require('../utils/factory') - -const nodes = [] -const common = { - setup: function (callback) { - callback(null, { - spawnNode: (cb) => { - f.spawn({ initOptions: { bits: 1024 } }, (err, _ipfsd) => { - if (err) { - return cb(err) - } - - nodes.push(_ipfsd) - cb(null, IPFSApi(_ipfsd.apiAddr)) - }) - } - }) - }, - teardown: function (callback) { - parallel(nodes.map((node) => (cb) => node.stop(cb)), callback) - } -} - -test.dht(common) diff --git a/test/interface/files-mfs.spec.js b/test/interface/files-mfs.spec.js deleted file mode 100644 index 6de81af4e..000000000 --- a/test/interface/files-mfs.spec.js +++ /dev/null @@ -1,32 +0,0 @@ -/* eslint-env mocha */ -/* eslint max-nested-callbacks: ["error", 8] */ -'use strict' - -const test = require('interface-ipfs-core') -const parallel = require('async/parallel') - -const IPFSApi = require('../../src') -const f = require('../utils/factory') - -const nodes = [] -const common = { - setup: function (callback) { - callback(null, { - spawnNode: (cb) => { - f.spawn({ initOptions: { bits: 1024 } }, (err, _ipfsd) => { - if (err) { - return cb(err) - } - - nodes.push(_ipfsd) - cb(null, IPFSApi(_ipfsd.apiAddr)) - }) - } - }) - }, - teardown: function (callback) { - parallel(nodes.map((node) => (cb) => node.stop(cb)), callback) - } -} - -test.filesMFS(common) diff --git a/test/interface/files.spec.js b/test/interface/files.spec.js deleted file mode 100644 index c99f768a6..000000000 --- a/test/interface/files.spec.js +++ /dev/null @@ -1,32 +0,0 @@ -/* eslint-env mocha */ -/* eslint max-nested-callbacks: ["error", 8] */ -'use strict' - -const test = require('interface-ipfs-core') -const parallel = require('async/parallel') - -const IPFSApi = require('../../src') -const f = require('../utils/factory') - -const nodes = [] -const common = { - setup: function (callback) { - callback(null, { - spawnNode: (cb) => { - f.spawn({ initOptions: { bits: 1024 } }, (err, _ipfsd) => { - if (err) { - return cb(err) - } - - nodes.push(_ipfsd) - cb(null, IPFSApi(_ipfsd.apiAddr)) - }) - } - }) - }, - teardown: function (callback) { - parallel(nodes.map((node) => (cb) => node.stop(cb)), callback) - } -} - -test.files(common) diff --git a/test/interface/key.spec.js b/test/interface/key.spec.js deleted file mode 100644 index 56f6e6893..000000000 --- a/test/interface/key.spec.js +++ /dev/null @@ -1,32 +0,0 @@ -/* eslint-env mocha */ - -'use strict' - -const test = require('interface-ipfs-core') -const parallel = require('async/parallel') - -const IPFSApi = require('../../src') -const f = require('../utils/factory') - -const nodes = [] -const common = { - setup: function (callback) { - callback(null, { - spawnNode: (cb) => { - f.spawn({ initOptions: { bits: 1024 } }, (err, _ipfsd) => { - if (err) { - return cb(err) - } - - nodes.push(_ipfsd) - cb(null, IPFSApi(_ipfsd.apiAddr)) - }) - } - }) - }, - teardown: function (callback) { - parallel(nodes.map((node) => (cb) => node.stop(cb)), callback) - } -} - -test.key(common) diff --git a/test/interface/miscellaneous.spec.js b/test/interface/miscellaneous.spec.js deleted file mode 100644 index c890a2fa3..000000000 --- a/test/interface/miscellaneous.spec.js +++ /dev/null @@ -1,33 +0,0 @@ -/* eslint-env mocha */ - -'use strict' - -const test = require('interface-ipfs-core') - -const IPFSApi = require('../../src') -const f = require('../utils/factory') - -const nodes = [] -const common = { - setup: function (callback) { - callback(null, { - spawnNode: (cb) => { - f.spawn({ initOptions: { bits: 1024 } }, (err, _ipfsd) => { - if (err) { - return cb(err) - } - - nodes.push(_ipfsd) - cb(null, IPFSApi(_ipfsd.apiAddr)) - }) - } - }) - }, - teardown: function (callback) { - // No need to stop, because the test suite does a 'stop' test. - // parallel(nodes.map((node) => (cb) => node.stop(cb)), callback) - callback() - } -} - -test.generic(common) diff --git a/test/interface/object.spec.js b/test/interface/object.spec.js deleted file mode 100644 index e76c45673..000000000 --- a/test/interface/object.spec.js +++ /dev/null @@ -1,32 +0,0 @@ -/* eslint-env mocha */ - -'use strict' - -const test = require('interface-ipfs-core') -const parallel = require('async/parallel') - -const IPFSApi = require('../../src') -const f = require('../utils/factory') - -const nodes = [] -const common = { - setup: function (callback) { - callback(null, { - spawnNode: (cb) => { - f.spawn({ initOptions: { bits: 1024 } }, (err, _ipfsd) => { - if (err) { - return cb(err) - } - - nodes.push(_ipfsd) - cb(null, IPFSApi(_ipfsd.apiAddr)) - }) - } - }) - }, - teardown: function (callback) { - parallel(nodes.map((node) => (cb) => node.stop(cb)), callback) - } -} - -test.object(common) diff --git a/test/interface/pin.spec.js b/test/interface/pin.spec.js deleted file mode 100644 index e56bc413d..000000000 --- a/test/interface/pin.spec.js +++ /dev/null @@ -1,32 +0,0 @@ -/* eslint-env mocha */ -/* eslint max-nested-callbacks: ["error", 8] */ -'use strict' - -const test = require('interface-ipfs-core') -const parallel = require('async/parallel') - -const IPFSApi = require('../../src') -const f = require('../utils/factory') - -const nodes = [] -const common = { - setup: function (callback) { - callback(null, { - spawnNode: (cb) => { - f.spawn({ initOptions: { bits: 1024 } }, (err, _ipfsd) => { - if (err) { - return cb(err) - } - - nodes.push(_ipfsd) - cb(null, IPFSApi(_ipfsd.apiAddr)) - }) - } - }) - }, - teardown: function (callback) { - parallel(nodes.map((node) => (cb) => node.stop(cb)), callback) - } -} - -test.pin(common) diff --git a/test/interface/ping.spec.js b/test/interface/ping.spec.js deleted file mode 100644 index 910bf3820..000000000 --- a/test/interface/ping.spec.js +++ /dev/null @@ -1,32 +0,0 @@ -/* eslint-env mocha */ -/* eslint max-nested-callbacks: ["error", 8] */ -'use strict' - -const test = require('interface-ipfs-core') -const parallel = require('async/parallel') - -const IPFSApi = require('../../src') -const f = require('../utils/factory') - -const nodes = [] -const common = { - setup: function (callback) { - callback(null, { - spawnNode: (cb) => { - f.spawn({ initOptions: { bits: 1024 } }, (err, _ipfsd) => { - if (err) { - return cb(err) - } - - nodes.push(_ipfsd) - cb(null, IPFSApi(_ipfsd.apiAddr)) - }) - } - }) - }, - teardown: function (callback) { - parallel(nodes.map((node) => (cb) => node.stop(cb)), callback) - } -} - -test.ping(common) diff --git a/test/interface/pubsub.spec.js b/test/interface/pubsub.spec.js deleted file mode 100644 index 154fec2f4..000000000 --- a/test/interface/pubsub.spec.js +++ /dev/null @@ -1,37 +0,0 @@ -/* eslint-env mocha */ - -'use strict' - -const test = require('interface-ipfs-core') -const isNode = require('detect-node') - -const parallel = require('async/parallel') - -const IPFSApi = require('../../src') -const f = require('../utils/factory') - -if (isNode) { - const nodes = [] - const common = { - setup: function (callback) { - callback(null, { - spawnNode: (cb) => { - f.spawn({ initOptions: { bits: 1024 }, args: ['--enable-pubsub-experiment'] }, - (err, _ipfsd) => { - if (err) { - return cb(err) - } - - nodes.push(_ipfsd) - cb(null, IPFSApi(_ipfsd.apiAddr)) - }) - } - }) - }, - teardown: function (callback) { - parallel(nodes.map((node) => (cb) => node.stop(cb)), callback) - } - } - - test.pubsub(common) -} diff --git a/test/interface/repo.spec.js b/test/interface/repo.spec.js deleted file mode 100644 index c6966772d..000000000 --- a/test/interface/repo.spec.js +++ /dev/null @@ -1,32 +0,0 @@ -/* eslint-env mocha */ -/* eslint max-nested-callbacks: ["error", 8] */ -'use strict' - -const test = require('interface-ipfs-core') -const parallel = require('async/parallel') - -const IPFSApi = require('../../src') -const f = require('../utils/factory') - -const nodes = [] -const common = { - setup: function (callback) { - callback(null, { - spawnNode: (cb) => { - f.spawn({ initOptions: { bits: 1024 } }, (err, _ipfsd) => { - if (err) { - return cb(err) - } - - nodes.push(_ipfsd) - cb(null, IPFSApi(_ipfsd.apiAddr)) - }) - } - }) - }, - teardown: function (callback) { - parallel(nodes.map((node) => (cb) => node.stop(cb)), callback) - } -} - -test.repo(common) diff --git a/test/interface/stats.spec.js b/test/interface/stats.spec.js deleted file mode 100644 index eee30ad98..000000000 --- a/test/interface/stats.spec.js +++ /dev/null @@ -1,32 +0,0 @@ -/* eslint-env mocha */ - -'use strict' - -const test = require('interface-ipfs-core') -const parallel = require('async/parallel') - -const IPFSApi = require('../../src') -const f = require('../utils/factory') - -const nodes = [] -const common = { - setup: function (callback) { - callback(null, { - spawnNode: (cb) => { - f.spawn({ initOptions: { bits: 1024 } }, (err, _ipfsd) => { - if (err) { - return cb(err) - } - - nodes.push(_ipfsd) - cb(null, IPFSApi(_ipfsd.apiAddr)) - }) - } - }) - }, - teardown: function (callback) { - parallel(nodes.map((node) => (cb) => node.stop(cb)), callback) - } -} - -test.stats(common) diff --git a/test/interface/swarm.spec.js b/test/interface/swarm.spec.js deleted file mode 100644 index 56b9cbe41..000000000 --- a/test/interface/swarm.spec.js +++ /dev/null @@ -1,42 +0,0 @@ -/* eslint-env mocha */ -/* eslint max-nested-callbacks: ["error", 8] */ -'use strict' - -const test = require('interface-ipfs-core') -const parallel = require('async/parallel') - -const IPFSApi = require('../../src') -const f = require('../utils/factory') - -const nodes = [] -const common = { - setup: function (callback) { - callback(null, { - spawnNode: (repoPath, config, cb) => { - if (typeof repoPath === 'function') { - cb = repoPath - repoPath = undefined - } - - if (typeof config === 'function') { - cb = config - config = undefined - } - - f.spawn({ repoPath, config, initOptions: { bits: 1024 } }, (err, _ipfsd) => { - if (err) { - return cb(err) - } - - nodes.push(_ipfsd) - cb(null, IPFSApi(_ipfsd.apiAddr)) - }) - } - }) - }, - teardown: function (callback) { - parallel(nodes.map((node) => (cb) => node.stop(cb)), callback) - } -} - -test.swarm(common) diff --git a/test/utils/interface-common-factory.js b/test/utils/interface-common-factory.js new file mode 100644 index 000000000..dbbf3eb18 --- /dev/null +++ b/test/utils/interface-common-factory.js @@ -0,0 +1,49 @@ +/* eslint-env mocha */ +'use strict' + +const each = require('async/each') +const IPFSFactory = require('ipfsd-ctl') +const IPFSApi = require('../../src') + +function createFactory (options) { + options = options || {} + + options.factoryOptions = options.factoryOptions || {} + options.spawnOptions = options.spawnOptions || { initOptions: { bits: 1024 } } + + const ipfsFactory = IPFSFactory.create(options.factoryOptions) + + return function createCommon () { + const nodes = [] + let setup, teardown + + if (options.createSetup) { + setup = options.createSetup({ ipfsFactory, nodes }, options) + } else { + setup = (callback) => { + callback(null, { + spawnNode (cb) { + ipfsFactory.spawn(options.spawnOptions, (err, _ipfsd) => { + if (err) { + return cb(err) + } + + nodes.push(_ipfsd) + cb(null, IPFSApi(_ipfsd.apiAddr)) + }) + } + }) + } + } + + if (options.createTeardown) { + teardown = options.createTeardown({ ipfsFactory, nodes }, options) + } else { + teardown = callback => each(nodes, (node, cb) => node.stop(cb), callback) + } + + return { setup, teardown } + } +} + +exports.create = createFactory From c2e4af4db7fc18c404e5d35276bd9e2e68dab542 Mon Sep 17 00:00:00 2001 From: Alan Shaw Date: Wed, 6 Jun 2018 11:55:09 +0100 Subject: [PATCH 02/20] feat: skip unimplemented files tests and add ls* tests License: MIT Signed-off-by: Alan Shaw --- test/interface.spec.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/test/interface.spec.js b/test/interface.spec.js index 8e2b16023..47f404500 100644 --- a/test/interface.spec.js +++ b/test/interface.spec.js @@ -57,7 +57,17 @@ describe('interface-ipfs-core tests', () => { ] }) - tests.files(defaultCommonFactory) + tests.files(defaultCommonFactory, { + skip: [ + // files.catPullStream + // + // FIXME not implemented in go-ipfs yet + 'should export a chunk of a file', + 'should export a chunk of a file in a Pull Stream', + 'should export a chunk of a file in a Readable Stream' + ], + only: true + }) tests.generic(CommonFactory.create({ // No need to stop, because the test suite does a 'stop' test. @@ -66,6 +76,8 @@ describe('interface-ipfs-core tests', () => { tests.key(defaultCommonFactory) + tests.ls(defaultCommonFactory) + tests.object(defaultCommonFactory) tests.ping(defaultCommonFactory) From f325e50f10e1190a6b042195a373aeef759af549 Mon Sep 17 00:00:00 2001 From: Alan Shaw Date: Wed, 6 Jun 2018 15:58:51 +0100 Subject: [PATCH 03/20] fix: adds skips for #339 License: MIT Signed-off-by: Alan Shaw --- package.json | 2 +- test/interface.spec.js | 41 +++++++++++++++++++++++++++++++---------- 2 files changed, 32 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index 53abbe1fe..d5f3036ef 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,6 @@ "bs58": "^4.0.1", "cids": "~0.5.3", "concat-stream": "^1.6.2", - "detect-node": "^2.0.3", "flatmap": "0.0.3", "glob": "^7.1.2", "ipfs-block": "~0.7.1", @@ -75,6 +74,7 @@ "browser-process-platform": "~0.1.1", "chai": "^4.1.2", "cross-env": "^5.1.6", + "detect-node": "^2.0.3", "dirty-chai": "^2.0.1", "eslint-plugin-react": "^7.9.1", "go-ipfs-dep": "~0.4.15", diff --git a/test/interface.spec.js b/test/interface.spec.js index 47f404500..0055bce45 100644 --- a/test/interface.spec.js +++ b/test/interface.spec.js @@ -2,6 +2,7 @@ 'use strict' const tests = require('interface-ipfs-core') +const isNode = require('detect-node') const CommonFactory = require('./utils/interface-common-factory') const IPFSApi = require('../src') @@ -18,7 +19,7 @@ describe('interface-ipfs-core tests', () => { skip: [ // dag.tree // - // FIXME vmx 2018-02-22: Currently the tree API is not exposed in go-ipfs + // TODO vmx 2018-02-22: Currently the tree API is not exposed in go-ipfs 'tree', // dag.get: // @@ -40,17 +41,14 @@ describe('interface-ipfs-core tests', () => { tests.dht(defaultCommonFactory, { skip: [ // dht.findpeer - // // FIXME checking what is exactly go-ipfs returning // https://github.com/ipfs/go-ipfs/issues/3862#issuecomment-294168090 'should fail to find other peer if peer does not exist', // dht.findprovs - // // FIXME go-ipfs endpoint doesn't conform with the others // https://github.com/ipfs/go-ipfs/issues/5047 'should provide from one node and find it through another node', // dht.get - // // FIXME go-ipfs errors with Error: key was not found (type 6) // https://github.com/ipfs/go-ipfs/issues/3862 'should get a value after it was put on another node' @@ -59,14 +57,25 @@ describe('interface-ipfs-core tests', () => { tests.files(defaultCommonFactory, { skip: [ + // files.add + // FIXME https://github.com/ipfs/js-ipfs-api/issues/339 + isNode ? null : 'should add a nested directory as array of tupples', + isNode ? null : 'should add a nested directory as array of tupples with progress', + // files.addPullStream + // FIXME https://github.com/ipfs/js-ipfs-api/issues/339 + isNode ? null : 'should add pull stream of valid files and dirs', + // files.addReadableStream + // FIXME https://github.com/ipfs/js-ipfs-api/issues/339 + isNode ? null : 'should add readable stream of valid files and dirs', // files.catPullStream - // - // FIXME not implemented in go-ipfs yet + // TODO not implemented in go-ipfs yet 'should export a chunk of a file', 'should export a chunk of a file in a Pull Stream', - 'should export a chunk of a file in a Readable Stream' - ], - only: true + 'should export a chunk of a file in a Readable Stream', + // files.get + // FIXME https://github.com/ipfs/js-ipfs-api/issues/339 + isNode ? null : 'should get a directory' + ] }) tests.generic(CommonFactory.create({ @@ -76,7 +85,19 @@ describe('interface-ipfs-core tests', () => { tests.key(defaultCommonFactory) - tests.ls(defaultCommonFactory) + tests.ls(defaultCommonFactory, { + skip: [ + // lsPullStream + // FIXME https://github.com/ipfs/js-ipfs-api/issues/339 + isNode ? null : 'should pull stream ls with a base58 encoded CID', + // lsReadableStream + // FIXME https://github.com/ipfs/js-ipfs-api/issues/339 + isNode ? null : 'should readable stream ls with a base58 encoded CID', + // ls + // FIXME https://github.com/ipfs/js-ipfs-api/issues/339 + isNode ? null : 'should ls with a base58 encoded CID' + ] + }) tests.object(defaultCommonFactory) From 6f711b98ec644d651027cc4c650a3d8b1dabeb24 Mon Sep 17 00:00:00 2001 From: Alan Shaw Date: Wed, 6 Jun 2018 17:03:01 +0100 Subject: [PATCH 04/20] fix: adds skips for key and miscellaneous License: MIT Signed-off-by: Alan Shaw --- test/interface.spec.js | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/test/interface.spec.js b/test/interface.spec.js index 0055bce45..dede8ee4f 100644 --- a/test/interface.spec.js +++ b/test/interface.spec.js @@ -18,11 +18,9 @@ describe('interface-ipfs-core tests', () => { tests.dag(defaultCommonFactory, { skip: [ // dag.tree - // // TODO vmx 2018-02-22: Currently the tree API is not exposed in go-ipfs 'tree', // dag.get: - // // FIXME vmx 2018-02-22: Currently not supported in go-ipfs, it might // be possible once https://github.com/ipfs/go-ipfs/issues/4728 is // done @@ -30,7 +28,6 @@ describe('interface-ipfs-core tests', () => { 'should get dag-pb value via dag-cbor node', 'should get by CID string + path', // dag.put - // // FIXME This works in go-ipfs because dag-pb will serialize any object. If // the object has neither a `data` nor `links` field it's serialized // as an empty object @@ -78,12 +75,16 @@ describe('interface-ipfs-core tests', () => { ] }) - tests.generic(CommonFactory.create({ - // No need to stop, because the test suite does a 'stop' test. - createTeardown: cb => cb() - })) - - tests.key(defaultCommonFactory) + tests.key(defaultCommonFactory, { + skip: [ + // key.export + // TODO not implemented in go-ipfs yet + 'export', + // key.import + // TODO not implemented in go-ipfs yet + 'import' + ] + }) tests.ls(defaultCommonFactory, { skip: [ @@ -99,6 +100,14 @@ describe('interface-ipfs-core tests', () => { ] }) + tests.miscellaneous(defaultCommonFactory, { + skip: [ + // stop + // FIXME go-ipfs returns an error https://github.com/ipfs/go-ipfs/issues/4078 + 'should stop the node' + ] + }) + tests.object(defaultCommonFactory) tests.ping(defaultCommonFactory) From 84f1122f2344f47943ab2c2372ed40ae7ea3696e Mon Sep 17 00:00:00 2001 From: Alan Shaw Date: Thu, 7 Jun 2018 16:10:20 +0100 Subject: [PATCH 05/20] feat: add types and util tests (skipped as currently failing) License: MIT Signed-off-by: Alan Shaw --- test/interface.spec.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/interface.spec.js b/test/interface.spec.js index dede8ee4f..bdd991248 100644 --- a/test/interface.spec.js +++ b/test/interface.spec.js @@ -153,4 +153,8 @@ describe('interface-ipfs-core tests', () => { } } })) + + tests.types(defaultCommonFactory, { skip: true }) + + tests.util(defaultCommonFactory, { skip: true }) }) From 2f6d041852ce2ac89e7cfddbd5faf954f7159054 Mon Sep 17 00:00:00 2001 From: Alan Shaw Date: Fri, 8 Jun 2018 00:15:23 +0100 Subject: [PATCH 06/20] feat: add pin tests License: MIT Signed-off-by: Alan Shaw --- test/interface.spec.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/interface.spec.js b/test/interface.spec.js index bdd991248..7441f4b24 100644 --- a/test/interface.spec.js +++ b/test/interface.spec.js @@ -110,6 +110,8 @@ describe('interface-ipfs-core tests', () => { tests.object(defaultCommonFactory) + tests.pin(defaultCommonFactory) + tests.ping(defaultCommonFactory) tests.pubsub(CommonFactory.create({ From dec9d50bbbd4f50f63e2778f4c0b7d8cf1aa8106 Mon Sep 17 00:00:00 2001 From: Alan Shaw Date: Fri, 8 Jun 2018 11:18:30 +0100 Subject: [PATCH 07/20] fix(pubsub): adds skips for tests on windows License: MIT Signed-off-by: Alan Shaw --- test/interface.spec.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/test/interface.spec.js b/test/interface.spec.js index 7441f4b24..2e4cc37d1 100644 --- a/test/interface.spec.js +++ b/test/interface.spec.js @@ -5,6 +5,7 @@ const tests = require('interface-ipfs-core') const isNode = require('detect-node') const CommonFactory = require('./utils/interface-common-factory') const IPFSApi = require('../src') +const isWindows = process.platform && process.platform === 'win32' describe('interface-ipfs-core tests', () => { const defaultCommonFactory = CommonFactory.create() @@ -119,7 +120,15 @@ describe('interface-ipfs-core tests', () => { args: ['--enable-pubsub-experiment'], initOptions: { bits: 1024 } } - })) + }), { + skip: isNode ? [ + // pubsub.subscribe + // FIXME https://github.com/ipfs/interface-ipfs-core/pull/188#issuecomment-354673246 + // and https://github.com/ipfs/go-ipfs/issues/4778 + isWindows ? 'should send/receive 100 messages' : null, + isWindows ? 'should receive multiple messages' : null + ] : true + }) tests.repo(defaultCommonFactory) From a3a064b4f55653e9622baf84c3ee8f303e77e5df Mon Sep 17 00:00:00 2001 From: Alan Shaw Date: Fri, 8 Jun 2018 13:03:53 +0100 Subject: [PATCH 08/20] fix(config): adds skip for config.replace License: MIT Signed-off-by: Alan Shaw --- test/interface.spec.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/test/interface.spec.js b/test/interface.spec.js index 2e4cc37d1..7bdc616f8 100644 --- a/test/interface.spec.js +++ b/test/interface.spec.js @@ -14,7 +14,15 @@ describe('interface-ipfs-core tests', () => { tests.bootstrap(defaultCommonFactory) - tests.config(defaultCommonFactory) + tests.config(defaultCommonFactory, { + skip: [ + // config.replace + // FIXME Waiting for fix on go-ipfs + // - https://github.com/ipfs/js-ipfs-api/pull/307#discussion_r69281789 + // - https://github.com/ipfs/go-ipfs/issues/2927 + 'replace' + ] + }) tests.dag(defaultCommonFactory, { skip: [ From 4da4309858921bb68a797b02f0ad7ba0bdb04539 Mon Sep 17 00:00:00 2001 From: Alan Shaw Date: Mon, 25 Jun 2018 10:37:21 +0100 Subject: [PATCH 09/20] chore: re-adds bitswap tests License: MIT Signed-off-by: Alan Shaw --- test/interface.spec.js | 10 ++++++++++ test/interface/bitswap.spec.js | 32 -------------------------------- 2 files changed, 10 insertions(+), 32 deletions(-) delete mode 100644 test/interface/bitswap.spec.js diff --git a/test/interface.spec.js b/test/interface.spec.js index 7bdc616f8..f97377c6b 100644 --- a/test/interface.spec.js +++ b/test/interface.spec.js @@ -10,6 +10,14 @@ const isWindows = process.platform && process.platform === 'win32' describe('interface-ipfs-core tests', () => { const defaultCommonFactory = CommonFactory.create() + tests.bitswap(defaultCommonFactory, { + skip: [ + // bitswap.unwant + // FIXME why is this skipped? + 'should remove a key from the wantlist' + ] + }) + tests.block(defaultCommonFactory) tests.bootstrap(defaultCommonFactory) @@ -173,7 +181,9 @@ describe('interface-ipfs-core tests', () => { } })) + // FIXME currently failing tests.types(defaultCommonFactory, { skip: true }) + // FIXME currently failing tests.util(defaultCommonFactory, { skip: true }) }) diff --git a/test/interface/bitswap.spec.js b/test/interface/bitswap.spec.js deleted file mode 100644 index 82eaacb6d..000000000 --- a/test/interface/bitswap.spec.js +++ /dev/null @@ -1,32 +0,0 @@ -/* eslint-env mocha */ - -'use strict' - -const test = require('interface-ipfs-core') -const parallel = require('async/parallel') - -const IPFSApi = require('../../src') -const f = require('../utils/factory') - -const nodes = [] -const common = { - setup: function (callback) { - callback(null, { - spawnNode: (cb) => { - f.spawn({ initOptions: { bits: 1024 } }, (err, _ipfsd) => { - if (err) { - return cb(err) - } - - nodes.push(_ipfsd) - cb(null, IPFSApi(_ipfsd.apiAddr)) - }) - } - }) - }, - teardown: function (callback) { - parallel(nodes.map((node) => (cb) => node.stop(cb)), callback) - } -} - -test.bitswap(common) From 0ef67103b3445f60eedcee06c7a8f57ed6304335 Mon Sep 17 00:00:00 2001 From: Alan Shaw Date: Mon, 25 Jun 2018 10:54:08 +0100 Subject: [PATCH 10/20] chore: move detect-node back to dependencies License: MIT Signed-off-by: Alan Shaw --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d5f3036ef..53abbe1fe 100644 --- a/package.json +++ b/package.json @@ -31,6 +31,7 @@ "bs58": "^4.0.1", "cids": "~0.5.3", "concat-stream": "^1.6.2", + "detect-node": "^2.0.3", "flatmap": "0.0.3", "glob": "^7.1.2", "ipfs-block": "~0.7.1", @@ -74,7 +75,6 @@ "browser-process-platform": "~0.1.1", "chai": "^4.1.2", "cross-env": "^5.1.6", - "detect-node": "^2.0.3", "dirty-chai": "^2.0.1", "eslint-plugin-react": "^7.9.1", "go-ipfs-dep": "~0.4.15", From e81e4e5107ac661b6f7b6e5409d8884dd31cd79c Mon Sep 17 00:00:00 2001 From: Alan Shaw Date: Tue, 26 Jun 2018 23:02:37 +0100 Subject: [PATCH 11/20] chore: add skip reasons License: MIT Signed-off-by: Alan Shaw --- test/interface.spec.js | 166 ++++++++++++++++++++++++++--------------- 1 file changed, 106 insertions(+), 60 deletions(-) diff --git a/test/interface.spec.js b/test/interface.spec.js index f97377c6b..5bcba85dc 100644 --- a/test/interface.spec.js +++ b/test/interface.spec.js @@ -13,8 +13,10 @@ describe('interface-ipfs-core tests', () => { tests.bitswap(defaultCommonFactory, { skip: [ // bitswap.unwant - // FIXME why is this skipped? - 'should remove a key from the wantlist' + { + name: 'should remove a key from the wantlist', + reason: 'FIXME why is this skipped?' + } ] }) @@ -25,103 +27,145 @@ describe('interface-ipfs-core tests', () => { tests.config(defaultCommonFactory, { skip: [ // config.replace - // FIXME Waiting for fix on go-ipfs - // - https://github.com/ipfs/js-ipfs-api/pull/307#discussion_r69281789 - // - https://github.com/ipfs/go-ipfs/issues/2927 - 'replace' + { + name: 'replace', + reason: 'FIXME Waiting for fix on go-ipfs https://github.com/ipfs/js-ipfs-api/pull/307#discussion_r69281789 and https://github.com/ipfs/go-ipfs/issues/2927' + } ] }) tests.dag(defaultCommonFactory, { skip: [ // dag.tree - // TODO vmx 2018-02-22: Currently the tree API is not exposed in go-ipfs - 'tree', + { + name: 'tree', + reason: 'TODO vmx 2018-02-22: Currently the tree API is not exposed in go-ipfs' + }, // dag.get: - // FIXME vmx 2018-02-22: Currently not supported in go-ipfs, it might - // be possible once https://github.com/ipfs/go-ipfs/issues/4728 is - // done - 'should get a dag-pb node local value', - 'should get dag-pb value via dag-cbor node', - 'should get by CID string + path', + { + name: 'should get a dag-pb node local value', + reason: 'FIXME vmx 2018-02-22: Currently not supported in go-ipfs, it might be possible once https://github.com/ipfs/go-ipfs/issues/4728 is done' + }, + { + name: 'should get dag-pb value via dag-cbor node', + reason: 'FIXME vmx 2018-02-22: Currently not supported in go-ipfs, it might be possible once https://github.com/ipfs/go-ipfs/issues/4728 is done' + }, + { + name: 'should get by CID string + path', + reason: 'FIXME vmx 2018-02-22: Currently not supported in go-ipfs, it might be possible once https://github.com/ipfs/go-ipfs/issues/4728 is done' + }, // dag.put - // FIXME This works in go-ipfs because dag-pb will serialize any object. If - // the object has neither a `data` nor `links` field it's serialized - // as an empty object - 'should not put dag-cbor node with wrong multicodec' + { + name: 'should not put dag-cbor node with wrong multicodec', + reason: 'FIXME This works in go-ipfs because dag-pb will serialize any object. If the object has neither a `data` nor `links` field it\'s serialized as an empty object' + } ] }) tests.dht(defaultCommonFactory, { skip: [ // dht.findpeer - // FIXME checking what is exactly go-ipfs returning - // https://github.com/ipfs/go-ipfs/issues/3862#issuecomment-294168090 - 'should fail to find other peer if peer does not exist', + { + name: 'should fail to find other peer if peer does not exist', + reason: 'FIXME checking what is exactly go-ipfs returning https://github.com/ipfs/go-ipfs/issues/3862#issuecomment-294168090' + }, // dht.findprovs - // FIXME go-ipfs endpoint doesn't conform with the others - // https://github.com/ipfs/go-ipfs/issues/5047 - 'should provide from one node and find it through another node', + { + name: 'should provide from one node and find it through another node', + reason: 'FIXME go-ipfs endpoint doesn\'t conform with the others https://github.com/ipfs/go-ipfs/issues/5047' + }, // dht.get - // FIXME go-ipfs errors with Error: key was not found (type 6) - // https://github.com/ipfs/go-ipfs/issues/3862 - 'should get a value after it was put on another node' + { + name: 'should get a value after it was put on another node', + reason: 'FIXME go-ipfs errors with Error: key was not found (type 6) https://github.com/ipfs/go-ipfs/issues/3862' + } ] }) tests.files(defaultCommonFactory, { skip: [ // files.add - // FIXME https://github.com/ipfs/js-ipfs-api/issues/339 - isNode ? null : 'should add a nested directory as array of tupples', - isNode ? null : 'should add a nested directory as array of tupples with progress', + isNode ? null : { + name: 'should add a nested directory as array of tupples', + reason: 'FIXME https://github.com/ipfs/js-ipfs-api/issues/339' + }, + isNode ? null : { + name: 'should add a nested directory as array of tupples with progress', + reason: 'FIXME https://github.com/ipfs/js-ipfs-api/issues/339' + }, // files.addPullStream - // FIXME https://github.com/ipfs/js-ipfs-api/issues/339 - isNode ? null : 'should add pull stream of valid files and dirs', + isNode ? null : { + name: 'should add pull stream of valid files and dirs', + reason: 'FIXME https://github.com/ipfs/js-ipfs-api/issues/339' + }, // files.addReadableStream - // FIXME https://github.com/ipfs/js-ipfs-api/issues/339 - isNode ? null : 'should add readable stream of valid files and dirs', + isNode ? null : { + name: 'should add readable stream of valid files and dirs', + reason: 'FIXME https://github.com/ipfs/js-ipfs-api/issues/339' + }, // files.catPullStream - // TODO not implemented in go-ipfs yet - 'should export a chunk of a file', - 'should export a chunk of a file in a Pull Stream', - 'should export a chunk of a file in a Readable Stream', + { + name: 'should export a chunk of a file', + reason: 'TODO not implemented in go-ipfs yet' + }, + { + name: 'should export a chunk of a file in a Pull Stream', + reason: 'TODO not implemented in go-ipfs yet' + }, + { + name: 'should export a chunk of a file in a Readable Stream', + reason: 'TODO not implemented in go-ipfs yet' + }, // files.get - // FIXME https://github.com/ipfs/js-ipfs-api/issues/339 - isNode ? null : 'should get a directory' + isNode ? null : { + name: 'should get a directory', + reason: 'FIXME https://github.com/ipfs/js-ipfs-api/issues/339' + } ] }) tests.key(defaultCommonFactory, { skip: [ // key.export - // TODO not implemented in go-ipfs yet - 'export', + { + name: 'export', + reason: 'TODO not implemented in go-ipfs yet' + }, // key.import - // TODO not implemented in go-ipfs yet - 'import' + { + name: 'import', + reason: 'TODO not implemented in go-ipfs yet' + } ] }) tests.ls(defaultCommonFactory, { skip: [ // lsPullStream - // FIXME https://github.com/ipfs/js-ipfs-api/issues/339 - isNode ? null : 'should pull stream ls with a base58 encoded CID', + isNode ? null : { + name: 'should pull stream ls with a base58 encoded CID', + reason: 'FIXME https://github.com/ipfs/js-ipfs-api/issues/339' + }, // lsReadableStream - // FIXME https://github.com/ipfs/js-ipfs-api/issues/339 - isNode ? null : 'should readable stream ls with a base58 encoded CID', + isNode ? null : { + name: 'should readable stream ls with a base58 encoded CID', + reason: 'FIXME https://github.com/ipfs/js-ipfs-api/issues/339' + }, // ls - // FIXME https://github.com/ipfs/js-ipfs-api/issues/339 - isNode ? null : 'should ls with a base58 encoded CID' + isNode ? null : { + name: 'should ls with a base58 encoded CID', + reason: 'FIXME https://github.com/ipfs/js-ipfs-api/issues/339' + } ] }) tests.miscellaneous(defaultCommonFactory, { skip: [ // stop - // FIXME go-ipfs returns an error https://github.com/ipfs/go-ipfs/issues/4078 - 'should stop the node' + { + name: 'should stop the node', + reason: 'FIXME go-ipfs returns an error https://github.com/ipfs/go-ipfs/issues/4078' + } ] }) @@ -139,10 +183,14 @@ describe('interface-ipfs-core tests', () => { }), { skip: isNode ? [ // pubsub.subscribe - // FIXME https://github.com/ipfs/interface-ipfs-core/pull/188#issuecomment-354673246 - // and https://github.com/ipfs/go-ipfs/issues/4778 - isWindows ? 'should send/receive 100 messages' : null, - isWindows ? 'should receive multiple messages' : null + isWindows ? { + name: 'should send/receive 100 messages', + reason: 'FIXME https://github.com/ipfs/interface-ipfs-core/pull/188#issuecomment-354673246 and https://github.com/ipfs/go-ipfs/issues/4778' + } : null, + isWindows ? { + name: 'should receive multiple messages', + reason: 'FIXME https://github.com/ipfs/interface-ipfs-core/pull/188#issuecomment-354673246 and https://github.com/ipfs/go-ipfs/issues/4778' + } : null ] : true }) @@ -181,9 +229,7 @@ describe('interface-ipfs-core tests', () => { } })) - // FIXME currently failing - tests.types(defaultCommonFactory, { skip: true }) + tests.types(defaultCommonFactory, { skip: { reason: 'FIXME currently failing' } }) - // FIXME currently failing - tests.util(defaultCommonFactory, { skip: true }) + tests.util(defaultCommonFactory, { skip: { reason: 'FIXME currently failing' } }) }) From 8cf8aaa8d811cc135b0a4c68cbc7e6dae3e08e82 Mon Sep 17 00:00:00 2001 From: Alan Shaw Date: Wed, 27 Jun 2018 22:22:57 +0100 Subject: [PATCH 12/20] chore: update interface-ipfs-core dependency License: MIT Signed-off-by: Alan Shaw --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 53abbe1fe..7dc757ad4 100644 --- a/package.json +++ b/package.json @@ -79,7 +79,7 @@ "eslint-plugin-react": "^7.9.1", "go-ipfs-dep": "~0.4.15", "gulp": "^3.9.1", - "interface-ipfs-core": "~0.69.1", + "interface-ipfs-core": "~0.70.0", "ipfsd-ctl": "~0.37.3", "pull-stream": "^3.6.8", "socket.io": "^2.1.1", From 6d344811053ebd8e72d56cb09416218b79c42044 Mon Sep 17 00:00:00 2001 From: Alan Shaw Date: Thu, 28 Jun 2018 09:33:25 +0100 Subject: [PATCH 13/20] chore: add reason for pubsub in browser skips License: MIT Signed-off-by: Alan Shaw --- test/interface.spec.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/interface.spec.js b/test/interface.spec.js index 5bcba85dc..aefb8b2ad 100644 --- a/test/interface.spec.js +++ b/test/interface.spec.js @@ -191,7 +191,9 @@ describe('interface-ipfs-core tests', () => { name: 'should receive multiple messages', reason: 'FIXME https://github.com/ipfs/interface-ipfs-core/pull/188#issuecomment-354673246 and https://github.com/ipfs/go-ipfs/issues/4778' } : null - ] : true + ] : { + reason: 'FIXME pubsub is not supported in the browser https://github.com/ipfs/js-ipfs-api/issues/518' + } }) tests.repo(defaultCommonFactory) From ba69bd8a8ee32c435ff863dfeb0f9fd1242fafa0 Mon Sep 17 00:00:00 2001 From: Alan Shaw Date: Thu, 28 Jun 2018 13:52:58 +0100 Subject: [PATCH 14/20] chore: add bitswap skips for offline errors License: MIT Signed-off-by: Alan Shaw --- test/interface.spec.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/test/interface.spec.js b/test/interface.spec.js index aefb8b2ad..27dad8e71 100644 --- a/test/interface.spec.js +++ b/test/interface.spec.js @@ -12,11 +12,25 @@ describe('interface-ipfs-core tests', () => { tests.bitswap(defaultCommonFactory, { skip: [ + // bitswap.stat + isWindows ? { + name: 'should not get bitswap stats when offline', + reason: 'FIXME go-ipfs returns an error https://github.com/ipfs/go-ipfs/issues/4078' + } : null, + // bitswap.wantlist + isWindows ? { + name: 'should not get the wantlist when offline', + reason: 'FIXME go-ipfs returns an error https://github.com/ipfs/go-ipfs/issues/4078' + } : null, // bitswap.unwant { name: 'should remove a key from the wantlist', reason: 'FIXME why is this skipped?' - } + }, + isWindows ? { + name: 'should not remove a key from the wantlist when offline', + reason: 'FIXME go-ipfs returns an error https://github.com/ipfs/go-ipfs/issues/4078' + } : null ] }) From b02e95b6e4acb781edfb34ddf218ebcab3440182 Mon Sep 17 00:00:00 2001 From: Alan Shaw Date: Fri, 29 Jun 2018 16:26:53 +0100 Subject: [PATCH 15/20] fix: remove skip for test that was removed License: MIT Signed-off-by: Alan Shaw --- test/interface.spec.js | 5 ----- 1 file changed, 5 deletions(-) diff --git a/test/interface.spec.js b/test/interface.spec.js index 27dad8e71..ebdb0d96b 100644 --- a/test/interface.spec.js +++ b/test/interface.spec.js @@ -67,11 +67,6 @@ describe('interface-ipfs-core tests', () => { { name: 'should get by CID string + path', reason: 'FIXME vmx 2018-02-22: Currently not supported in go-ipfs, it might be possible once https://github.com/ipfs/go-ipfs/issues/4728 is done' - }, - // dag.put - { - name: 'should not put dag-cbor node with wrong multicodec', - reason: 'FIXME This works in go-ipfs because dag-pb will serialize any object. If the object has neither a `data` nor `links` field it\'s serialized as an empty object' } ] }) From 6413fa1da61575756ae3bdf1acfdf8c354c168fa Mon Sep 17 00:00:00 2001 From: Alan Shaw Date: Fri, 29 Jun 2018 16:33:01 +0100 Subject: [PATCH 16/20] chore: update interface-ipfs-core version License: MIT Signed-off-by: Alan Shaw --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7dc757ad4..b6fbee7f5 100644 --- a/package.json +++ b/package.json @@ -79,7 +79,7 @@ "eslint-plugin-react": "^7.9.1", "go-ipfs-dep": "~0.4.15", "gulp": "^3.9.1", - "interface-ipfs-core": "~0.70.0", + "interface-ipfs-core": "~0.70.2", "ipfsd-ctl": "~0.37.3", "pull-stream": "^3.6.8", "socket.io": "^2.1.1", From 694989d7ce8cd64f82596133224123e9576beb33 Mon Sep 17 00:00:00 2001 From: David Dias Date: Tue, 3 Jul 2018 16:32:49 +0200 Subject: [PATCH 17/20] chore: update deps and test on CI (#802) --- package.json | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index b6fbee7f5..7d75a409b 100644 --- a/package.json +++ b/package.json @@ -36,8 +36,8 @@ "glob": "^7.1.2", "ipfs-block": "~0.7.1", "ipfs-unixfs": "~0.1.15", - "ipld-dag-cbor": "~0.12.0", - "ipld-dag-pb": "~0.14.4", + "ipld-dag-cbor": "~0.12.1", + "ipld-dag-pb": "~0.14.5", "is-ipfs": "~0.3.2", "is-pull-stream": "0.0.0", "is-stream": "^1.1.0", @@ -48,7 +48,7 @@ "multihashes": "~0.4.13", "ndjson": "^1.5.0", "once": "^1.4.0", - "peer-id": "~0.10.7", + "peer-id": "~0.11.0", "peer-info": "~0.14.1", "promisify-es6": "^1.0.3", "pull-defer": "~0.2.2", @@ -74,13 +74,13 @@ "aegir": "^14.0.0", "browser-process-platform": "~0.1.1", "chai": "^4.1.2", - "cross-env": "^5.1.6", + "cross-env": "^5.2.0", "dirty-chai": "^2.0.1", - "eslint-plugin-react": "^7.9.1", + "eslint-plugin-react": "^7.10.0", "go-ipfs-dep": "~0.4.15", "gulp": "^3.9.1", - "interface-ipfs-core": "~0.70.2", - "ipfsd-ctl": "~0.37.3", + "interface-ipfs-core": "~0.70.3", + "ipfsd-ctl": "~0.37.5", "pull-stream": "^3.6.8", "socket.io": "^2.1.1", "socket.io-client": "^2.1.1", From dc1cb7268b234d80c51c9a9a51e8ee7696dc5b2a Mon Sep 17 00:00:00 2001 From: David Dias Date: Tue, 3 Jul 2018 17:05:08 +0200 Subject: [PATCH 18/20] chore: update interface-ipfs-core --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7d75a409b..8dc0ea739 100644 --- a/package.json +++ b/package.json @@ -79,7 +79,7 @@ "eslint-plugin-react": "^7.10.0", "go-ipfs-dep": "~0.4.15", "gulp": "^3.9.1", - "interface-ipfs-core": "~0.70.3", + "interface-ipfs-core": "~0.71.0", "ipfsd-ctl": "~0.37.5", "pull-stream": "^3.6.8", "socket.io": "^2.1.1", From c53d3cdd19a688698deeb6e298d5a77e58c3331a Mon Sep 17 00:00:00 2001 From: Pascal Precht Date: Wed, 4 Jul 2018 12:11:22 +0200 Subject: [PATCH 19/20] fix(dag): `dag.put()` allows for optional options (#801) * fix(dag): ensure `dag.put()` allows for optional options This is to align with API changes made in https://github.com/ipfs/interface-ipfs-core/commit/011c417b97e58aceafaa4e98fce8f32217bc5cf7 and https://github.com/ipfs/js-ipfs/pull/1415 License: MIT Signed-off-by: Pascal Precht * fix(dag): fixes to allow options to be optional License: MIT Signed-off-by: Alan Shaw * chore: update interface-ipfs-core dependency License: MIT Signed-off-by: Alan Shaw * chore: update ipfsd-ctl dependency License: MIT Signed-off-by: Alan Shaw * fix: increase timeout for addFromURL with wrap-with-directory Sadly we can't guarantee ipfs.io will respond within 5s License: MIT Signed-off-by: Alan Shaw --- src/dag/put.js | 67 ++++++++++++++++++++++++++++------------------- test/util.spec.js | 4 ++- 2 files changed, 43 insertions(+), 28 deletions(-) diff --git a/src/dag/put.js b/src/dag/put.js index c0c2f211a..636d39ae4 100644 --- a/src/dag/put.js +++ b/src/dag/put.js @@ -5,54 +5,67 @@ const dagCBOR = require('ipld-dag-cbor') const promisify = require('promisify-es6') const CID = require('cids') const multihash = require('multihashes') -const setImmediate = require('async/setImmediate') const SendOneFile = require('../utils/send-one-file') -function noop () {} - module.exports = (send) => { const sendOneFile = SendOneFile(send, 'dag/put') return promisify((dagNode, options, callback) => { if (typeof options === 'function') { - return setImmediate(() => callback(new Error('no options were passed'))) + callback = options } - callback = callback || noop + options = options || {} - let hashAlg = options.hash || 'sha2-256' - let format - let inputEnc + if (options.hash) { + options.hashAlg = options.hash + delete options.hash + } - if (options.cid && CID.isCID(options.cid)) { - format = options.cid.codec - hashAlg = multihash.decode(options.cid.multihash).name - prepare() - } else if (options.format) { - format = options.format - prepare() - } else { - callback(new Error('Invalid arguments')) + if (options.cid && (options.format || options.hashAlg)) { + return callback(new Error('Can\'t put dag node. Please provide either `cid` OR `format` and `hash` options.')) + } else if ((options.format && !options.hashAlg) || (!options.format && options.hashAlg)) { + return callback(new Error('Can\'t put dag node. Please provide `format` AND `hash` options.')) } - function prepare () { - inputEnc = 'raw' + if (options.cid) { + let cid - if (format === 'dag-cbor') { - dagCBOR.util.serialize(dagNode, finalize) - } - if (format === 'dag-pb') { - dagPB.util.serialize(dagNode, finalize) + try { + cid = new CID(options.cid) + } catch (err) { + return callback(err) } + + options.format = cid.codec + options.hashAlg = multihash.decode(cid.multihash).name + delete options.cid + } + + const optionDefaults = { + format: 'dag-cbor', + hashAlg: 'sha2-256', + inputEnc: 'raw' + } + + options = Object.assign(optionDefaults, options) + + if (options.format === 'dag-cbor') { + dagCBOR.util.serialize(dagNode, finalize) + } else if (options.format === 'dag-pb') { + dagPB.util.serialize(dagNode, finalize) + } else { + // FIXME Hopefully already serialized...can we use IPLD to serialise instead? + finalize(null, dagNode) } function finalize (err, serialized) { if (err) { return callback(err) } const sendOptions = { qs: { - hash: hashAlg, - format: format, - 'input-enc': inputEnc + hash: options.hashAlg, + format: options.format, + 'input-enc': options.inputEnc } } sendOneFile(serialized, sendOptions, (err, result) => { diff --git a/test/util.spec.js b/test/util.spec.js index 83e67e8de..52ce9ebd7 100644 --- a/test/util.spec.js +++ b/test/util.spec.js @@ -160,7 +160,9 @@ describe('.util', () => { .then(out => expectTimeout(ipfs.object.get(out[0].hash), 4000)) }) - it('with wrap-with-directory=true', (done) => { + it('with wrap-with-directory=true', function (done) { + this.timeout(20 * 1000) + ipfs.util.addFromURL('http://ipfs.io/ipfs/QmWjppACLcFLQ2qL38unKQvJBhXH3RUtcGLPk7zmrTwV61/969165.jpg?foo=bar#buzz', { wrapWithDirectory: true }, (err, result) => { From 1781f2af81c8973810f5974178cea1a91d1964a3 Mon Sep 17 00:00:00 2001 From: Alan Shaw Date: Wed, 4 Jul 2018 14:53:30 +0100 Subject: [PATCH 20/20] fix: skip bitswap offline tests on all platforms The offline tests create and stop a node. https://github.com/ipfs/go-ipfs/issues/4078 seems to not only be restricted to windows. License: MIT Signed-off-by: Alan Shaw --- test/interface.spec.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/interface.spec.js b/test/interface.spec.js index ebdb0d96b..5f169433f 100644 --- a/test/interface.spec.js +++ b/test/interface.spec.js @@ -13,24 +13,24 @@ describe('interface-ipfs-core tests', () => { tests.bitswap(defaultCommonFactory, { skip: [ // bitswap.stat - isWindows ? { + { name: 'should not get bitswap stats when offline', reason: 'FIXME go-ipfs returns an error https://github.com/ipfs/go-ipfs/issues/4078' - } : null, + }, // bitswap.wantlist - isWindows ? { + { name: 'should not get the wantlist when offline', reason: 'FIXME go-ipfs returns an error https://github.com/ipfs/go-ipfs/issues/4078' - } : null, + }, // bitswap.unwant { name: 'should remove a key from the wantlist', reason: 'FIXME why is this skipped?' }, - isWindows ? { + { name: 'should not remove a key from the wantlist when offline', reason: 'FIXME go-ipfs returns an error https://github.com/ipfs/go-ipfs/issues/4078' - } : null + } ] })