diff --git a/package.json b/package.json index a4f8f2f9ac..808f5c5cbf 100644 --- a/package.json +++ b/package.json @@ -73,7 +73,7 @@ "ipfs-multipart": "^0.3.0", "ipfs-unixfs": "^0.3.0", "ipfs-unixfs-exporter": "^0.40.0", - "ipfs-unixfs-importer": "^0.43.0", + "ipfs-unixfs-importer": "^0.43.1", "ipfs-utils": "^0.4.2", "ipld-dag-pb": "^0.18.0", "it-last": "^1.0.1", diff --git a/src/cli/chmod.js b/src/cli/chmod.js index d8bd0b4a9a..6f0ac6cde9 100644 --- a/src/cli/chmod.js +++ b/src/cli/chmod.js @@ -27,12 +27,6 @@ module.exports = { coerce: asBoolean, describe: 'Whether to change modes recursively' }, - codec: { - alias: 'c', - type: 'string', - default: 'dag-pb', - describe: 'If intermediate directories are created, use this codec to create them (experimental)' - }, 'hash-alg': { alias: 'h', type: 'string', @@ -59,7 +53,6 @@ module.exports = { mode, getIpfs, recursive, - codec, hashAlg, flush, shardSplitThreshold @@ -70,7 +63,6 @@ module.exports = { return ipfs.files.chmod(path, mode, { recursive, - format: codec, hashAlg, flush, shardSplitThreshold diff --git a/src/cli/cp.js b/src/cli/cp.js index 3be124be53..13bc6c785b 100644 --- a/src/cli/cp.js +++ b/src/cli/cp.js @@ -17,12 +17,6 @@ module.exports = { coerce: asBoolean, describe: 'Create any non-existent intermediate directories' }, - codec: { - alias: 'c', - type: 'string', - default: 'dag-pb', - describe: 'If intermediate directories are created, use this codec to create them (experimental)' - }, 'hash-alg': { alias: 'h', type: 'string', @@ -49,7 +43,6 @@ module.exports = { dest, getIpfs, parents, - codec, flush, hashAlg, shardSplitThreshold @@ -59,7 +52,6 @@ module.exports = { const ipfs = await getIpfs() return ipfs.files.cp(source, dest, { parents, - format: codec, flush, hashAlg, shardSplitThreshold diff --git a/src/cli/mkdir.js b/src/cli/mkdir.js index fcdfe0959d..0c9ed623d7 100644 --- a/src/cli/mkdir.js +++ b/src/cli/mkdir.js @@ -25,12 +25,6 @@ module.exports = { default: 0, describe: 'Cid version to use. (experimental).' }, - codec: { - alias: 'c', - type: 'string', - default: 'dag-pb', - describe: 'If intermediate directories are created, use this codec to create them (experimental)' - }, 'hash-alg': { alias: 'h', type: 'string', @@ -67,7 +61,6 @@ module.exports = { getIpfs, parents, cidVersion, - codec, hashAlg, flush, shardSplitThreshold, @@ -81,7 +74,6 @@ module.exports = { return ipfs.files.mkdir(path, { parents, cidVersion, - format: codec, hashAlg, flush, shardSplitThreshold, diff --git a/src/cli/mv.js b/src/cli/mv.js index 764d19ab13..08f145ca36 100644 --- a/src/cli/mv.js +++ b/src/cli/mv.js @@ -30,12 +30,6 @@ module.exports = { default: 0, describe: 'Cid version to use. (experimental).' }, - codec: { - alias: 'c', - type: 'string', - default: 'dag-pb', - describe: 'If intermediate directories are created, use this codec to create them (experimental)' - }, 'hash-alg': { alias: 'h', type: 'string', @@ -64,7 +58,6 @@ module.exports = { parents, recursive, cidVersion, - codec, hashAlg, flush, shardSplitThreshold @@ -77,7 +70,6 @@ module.exports = { parents, recursive, cidVersion, - format: codec, hashAlg, flush, shardSplitThreshold diff --git a/src/cli/touch.js b/src/cli/touch.js index 260a04db73..216a3f2eda 100644 --- a/src/cli/touch.js +++ b/src/cli/touch.js @@ -31,12 +31,6 @@ module.exports = { default: 0, describe: 'Cid version to use. (experimental).' }, - codec: { - alias: 'c', - type: 'string', - default: 'dag-pb', - describe: 'If intermediate directories are created, use this codec to create them (experimental)' - }, 'hash-alg': { alias: 'h', type: 'string', @@ -56,7 +50,6 @@ module.exports = { getIpfs, flush, cidVersion, - codec, hashAlg, shardSplitThreshold, mtime @@ -69,7 +62,6 @@ module.exports = { mtime, flush, cidVersion, - format: codec, hashAlg, shardSplitThreshold }) diff --git a/src/cli/write.js b/src/cli/write.js index 754ef9324f..79ae4f1d22 100644 --- a/src/cli/write.js +++ b/src/cli/write.js @@ -78,11 +78,6 @@ module.exports = { type: 'string', default: 'sha2-256' }, - codec: { - alias: ['c'], - type: 'string', - default: 'dag-pb' - }, 'shard-split-threshold': { type: 'number', default: 1000, @@ -114,7 +109,6 @@ module.exports = { reduceSingleLeafToSelf, cidVersion, hashAlg, - codec, parents, progress, strategy, @@ -136,7 +130,6 @@ module.exports = { reduceSingleLeafToSelf, cidVersion, hashAlg, - format: codec, parents, progress, strategy, diff --git a/src/core/chmod.js b/src/core/chmod.js index 3b32c07526..bdf71e1322 100644 --- a/src/core/chmod.js +++ b/src/core/chmod.js @@ -16,7 +16,6 @@ const mh = require('multihashes') const defaultOptions = { flush: true, shardSplitThreshold: 1000, - format: 'dag-pb', hashAlg: 'sha2-256', cidVersion: 0, recursive: false @@ -174,7 +173,7 @@ module.exports = (context) => { const updatedCid = await context.ipld.put(node, mc.DAG_PB, { cidVersion: cid.version, - hashAlg: mh.names['sha2-256'], + hashAlg: mh.names[options.hashAlg], onlyHash: !options.flush }) @@ -188,8 +187,7 @@ module.exports = (context) => { cid: updatedCid, size: node.serialize().length, flush: options.flush, - format: 'dag-pb', - hashAlg: 'sha2-256', + hashAlg: options.hashAlg, cidVersion: cid.version }) diff --git a/src/core/cp.js b/src/core/cp.js index 8e70d36566..2e127aaeba 100644 --- a/src/core/cp.js +++ b/src/core/cp.js @@ -15,7 +15,6 @@ const toTrail = require('./utils/to-trail') const defaultOptions = { parents: false, flush: true, - format: 'dag-pb', hashAlg: 'sha2-256', cidVersion: 0, shardSplitThreshold: 1000 @@ -150,7 +149,6 @@ const addSourceToParent = async (context, source, childName, parent, options) => size: sourceBlock.data.length, cid: source.cid, name: childName, - format: options.format, hashAlg: options.hashAlg, cidVersion: options.cidVersion, flush: options.flush diff --git a/src/core/mkdir.js b/src/core/mkdir.js index 9b62aca2ba..155f97da14 100644 --- a/src/core/mkdir.js +++ b/src/core/mkdir.js @@ -19,7 +19,6 @@ const defaultOptions = { hashAlg: 'sha2-256', cidVersion: 0, shardSplitThreshold: 1000, - format: 'dag-pb', flush: true, mode: null, mtime: null @@ -116,7 +115,6 @@ const addEmptyDir = async (context, childName, emptyDir, parent, trail, options) size: emptyDir.node.size, cid: emptyDir.cid, name: childName, - format: options.format, hashAlg: options.hashAlg, cidVersion: options.cidVersion, mode: options.mode, diff --git a/src/core/mv.js b/src/core/mv.js index d432fb6ea2..2d257fadbf 100644 --- a/src/core/mv.js +++ b/src/core/mv.js @@ -10,7 +10,6 @@ const defaultOptions = { recursive: false, flush: true, cidVersion: 0, - format: 'dag-pb', hashAlg: 'sha2-256', shardSplitThreshold: 1000 } diff --git a/src/core/rm.js b/src/core/rm.js index f0ff80c3c0..198d7b20de 100644 --- a/src/core/rm.js +++ b/src/core/rm.js @@ -16,7 +16,6 @@ const defaultOptions = { recursive: false, cidVersion: 0, hashAlg: 'sha2-256', - format: 'dag-pb', flush: true } @@ -64,7 +63,6 @@ const removePath = async (context, path, options) => { } = await removeLink(context, { parentCid: parent.cid, name: child.name, - format: options.format, hashAlg: options.hashAlg, cidVersion: options.cidVersion, flush: options.flush diff --git a/src/core/touch.js b/src/core/touch.js index 151777324e..b70a781ab0 100644 --- a/src/core/touch.js +++ b/src/core/touch.js @@ -18,7 +18,6 @@ const defaultOptions = { flush: true, shardSplitThreshold: 1000, cidVersion: 0, - format: 'dag-pb', hashAlg: 'sha2-256' } @@ -85,7 +84,6 @@ module.exports = (context) => { size: node.serialize().length, flush: options.flush, shardSplitThreshold: options.shardSplitThreshold, - format: 'dag-pb', hashAlg: 'sha2-256', cidVersion }) diff --git a/src/core/utils/add-link.js b/src/core/utils/add-link.js index 1e2193a002..431f8659e8 100644 --- a/src/core/utils/add-link.js +++ b/src/core/utils/add-link.js @@ -99,11 +99,10 @@ const addToDirectory = async (context, options) => { node.mtime = new Date() options.parent = new DAGNode(node.marshal(), options.parent.Links) - const format = mc[options.format.toUpperCase().replace(/-/g, '_')] const hashAlg = mh.names[options.hashAlg] // Persist the new parent DAGNode - const cid = await context.ipld.put(options.parent, format, { + const cid = await context.ipld.put(options.parent, mc.DAG_PB, { cidVersion: options.cidVersion, hashAlg, onlyHash: !options.flush diff --git a/src/core/utils/apply-default-options.js b/src/core/utils/apply-default-options.js index ff83e322bd..6c88e5a1f9 100644 --- a/src/core/utils/apply-default-options.js +++ b/src/core/utils/apply-default-options.js @@ -17,13 +17,6 @@ module.exports = (options = {}, defaults) => { } } - const format = output.format || output.codec - - if (format && isNaN(format)) { - output.format = format - delete output.codec - } - // support legacy go arguments if (options.count !== undefined) { output.length = options.count diff --git a/src/core/utils/create-node.js b/src/core/utils/create-node.js index c0982ae0d0..a72f047895 100644 --- a/src/core/utils/create-node.js +++ b/src/core/utils/create-node.js @@ -8,7 +8,6 @@ const mc = require('multicodec') const mh = require('multihashes') const createNode = async (context, type, options) => { - const format = mc[options.format.toUpperCase().replace(/-/g, '_')] const hashAlg = mh.names[options.hashAlg] const metadata = new UnixFS({ type, @@ -17,7 +16,7 @@ const createNode = async (context, type, options) => { }) const node = new DAGNode(metadata.marshal()) - const cid = await context.ipld.put(node, format, { + const cid = await context.ipld.put(node, mc.DAG_PB, { cidVersion: options.cidVersion, hashAlg, onlyHash: !options.flush diff --git a/src/core/utils/hamt-utils.js b/src/core/utils/hamt-utils.js index d63092030e..96312bbc31 100644 --- a/src/core/utils/hamt-utils.js +++ b/src/core/utils/hamt-utils.js @@ -24,11 +24,9 @@ const updateHamtDirectory = async (context, links, bucket, options) => { mtime: node.mtime }) - const format = mc[options.format.toUpperCase().replace(/-/g, '_')] const hashAlg = mh.names[options.hashAlg] - const parent = new DAGNode(dir.marshal(), links) - const cid = await context.ipld.put(parent, format, { + const cid = await context.ipld.put(parent, mc.DAG_PB, { cidVersion: options.cidVersion, hashAlg, onlyHash: !options.flush @@ -184,7 +182,10 @@ const createShard = async (context, contents, options) => { flat: false, mtime: options.mtime, mode: options.mode - }, options) + }, { + ...options, + codec: 'dag-pb' + }) for (let i = 0; i < contents.length; i++) { await shard._bucket.put(contents[i].name, { diff --git a/src/core/utils/remove-link.js b/src/core/utils/remove-link.js index 89009c6322..485558448b 100644 --- a/src/core/utils/remove-link.js +++ b/src/core/utils/remove-link.js @@ -48,11 +48,10 @@ const removeLink = async (context, options) => { } const removeFromDirectory = async (context, options) => { - const format = mc[options.format.toUpperCase().replace(/-/g, '_')] const hashAlg = mh.names[options.hashAlg] options.parent.rmLink(options.name) - const cid = await context.ipld.put(options.parent, format, { + const cid = await context.ipld.put(options.parent, mc.DAG_PB, { cidVersion: options.cidVersion, hashAlg }) @@ -79,7 +78,6 @@ const removeFromShardedDirectory = async (context, options) => { cid: options.cid, size: options.size, hashAlg: options.hashAlg, - format: options.format, cidVersion: options.cidVersion, flush: options.flush }, options) diff --git a/src/core/utils/update-tree.js b/src/core/utils/update-tree.js index a832c6516b..ed80df4edf 100644 --- a/src/core/utils/update-tree.js +++ b/src/core/utils/update-tree.js @@ -39,7 +39,6 @@ const updateTree = async (context, trail, options) => { size: child.size, flush: options.flush, shardSplitThreshold: options.shardSplitThreshold, - format: options.format, hashAlg: options.hashAlg, cidVersion: options.cidVersion }) diff --git a/src/core/write.js b/src/core/write.js index 2b13c4d839..357d898573 100644 --- a/src/core/write.js +++ b/src/core/write.js @@ -28,7 +28,6 @@ const defaultOptions = { reduceSingleLeafToSelf: false, cidVersion: 0, hashAlg: 'sha2-256', - format: 'dag-pb', parents: false, // whether to create intermediate directories if they do not exist progress: () => {}, strategy: 'trickle', @@ -104,7 +103,6 @@ const updateOrImport = async (context, path, source, destination, options) => { size: child.size, flush: options.flush, shardSplitThreshold: options.shardSplitThreshold, - format: options.format, hashAlg: options.hashAlg, cidVersion: options.cidVersion }) diff --git a/src/http/chmod.js b/src/http/chmod.js index 8b6a967df6..11b3511cb8 100644 --- a/src/http/chmod.js +++ b/src/http/chmod.js @@ -13,7 +13,6 @@ const mfsChmod = { arg, mode, recursive, - codec, hashAlg, flush, shardSplitThreshold @@ -21,7 +20,6 @@ const mfsChmod = { await ipfs.files.chmod(arg, mode, { recursive, - format: codec, hashAlg, flush, shardSplitThreshold @@ -40,7 +38,6 @@ const mfsChmod = { mode: Joi.string(), recursive: Joi.boolean().default(false), flush: Joi.boolean().default(true), - codec: Joi.string().default('dag-pb'), hashAlg: Joi.string().default('sha2-256'), shardSplitThreshold: Joi.number().integer().min(0).default(1000) }) diff --git a/src/http/cp.js b/src/http/cp.js index 751fda0b88..c27289857e 100644 --- a/src/http/cp.js +++ b/src/http/cp.js @@ -13,7 +13,6 @@ const mfsCp = { arg, parents, flush, - format, hashAlg, shardSplitThreshold } = request.query @@ -21,7 +20,6 @@ const mfsCp = { const args = arg.concat({ parents, flush, - format, hashAlg, shardSplitThreshold }) @@ -40,14 +38,9 @@ const mfsCp = { arg: Joi.array().items(Joi.string()).min(2), parents: Joi.boolean().default(false), flush: Joi.boolean().default(true), - format: Joi.string().valid([ - 'dag-pb', - 'dag-cbor' - ]).default('dag-pb'), hashAlg: Joi.string().default('sha2-256'), shardSplitThreshold: Joi.number().integer().min(0).default(1000) }) - .rename('codec', 'format') } } } diff --git a/src/http/mkdir.js b/src/http/mkdir.js index b951f96e3d..5c4900fbe0 100644 --- a/src/http/mkdir.js +++ b/src/http/mkdir.js @@ -16,7 +16,6 @@ const mfsMkdir = { mtime, mtimeNsecs, parents, - format, hashAlg, cidVersion, flush, @@ -27,7 +26,6 @@ const mfsMkdir = { mode, mtime: parseMtime(mtime, mtimeNsecs), parents, - format, hashAlg, cidVersion, flush, @@ -48,10 +46,6 @@ const mfsMkdir = { mtime: Joi.number().integer(), mtimeNsecs: Joi.number().integer().min(0), parents: Joi.boolean().default(false), - format: Joi.string().valid([ - 'dag-pb', - 'dag-cbor' - ]).default('dag-pb'), hashAlg: Joi.string().default('sha2-256'), cidVersion: Joi.number().integer().valid([ 0, diff --git a/src/http/mv.js b/src/http/mv.js index 2ba60df3d5..1a6f8e62c6 100644 --- a/src/http/mv.js +++ b/src/http/mv.js @@ -13,7 +13,6 @@ const mfsMv = { arg, recursive, parents, - format, hashAlg, cidVersion, flush, @@ -25,7 +24,6 @@ const mfsMv = { parents, cidVersion, flush, - format, hashAlg, shardSplitThreshold }) @@ -44,10 +42,6 @@ const mfsMv = { arg: Joi.array().items(Joi.string()).min(2), recursive: Joi.boolean().default(false), parents: Joi.boolean().default(false), - format: Joi.string().valid([ - 'dag-pb', - 'dag-cbor' - ]).default('dag-pb'), hashAlg: Joi.string().default('sha2-256'), cidVersion: Joi.number().integer().valid([ 0, diff --git a/src/http/touch.js b/src/http/touch.js index 5c93fe5b20..1154385033 100644 --- a/src/http/touch.js +++ b/src/http/touch.js @@ -15,7 +15,6 @@ const mfsTouch = { flush, shardSplitThreshold, cidVersion, - format, hashAlg, mtime, mtimeNsecs @@ -26,7 +25,6 @@ const mfsTouch = { flush, shardSplitThreshold, cidVersion, - format, hashAlg }) @@ -42,10 +40,6 @@ const mfsTouch = { arg: Joi.string().required(), mtime: Joi.number().integer(), mtimeNsecs: Joi.number().integer().min(0), - format: Joi.string().valid([ - 'dag-pb', - 'dag-cbor' - ]).default('dag-pb'), hashAlg: Joi.string().default('sha2-256'), cidVersion: Joi.number().integer().valid([ 0, diff --git a/src/http/write.js b/src/http/write.js index 64d3a7ed15..542955f19a 100644 --- a/src/http/write.js +++ b/src/http/write.js @@ -21,7 +21,6 @@ const mfsWrite = { reduceSingleLeafToSelf, cidVersion, hashAlg, - format, parents, progress, strategy, @@ -48,7 +47,6 @@ const mfsWrite = { reduceSingleLeafToSelf, cidVersion, hashAlg, - format, parents, progress, strategy, @@ -84,10 +82,6 @@ const mfsWrite = { 1 ]).default(0), hashAlg: Joi.string().default('sha2-256'), - format: Joi.string().valid([ - 'dag-pb', - 'dag-cbor' - ]).default('dag-pb'), parents: Joi.boolean().default(false), progress: Joi.func(), strategy: Joi.string().valid([ diff --git a/test/cli/chmod.js b/test/cli/chmod.js index c7bd8d5f17..b459f3a408 100644 --- a/test/cli/chmod.js +++ b/test/cli/chmod.js @@ -8,7 +8,6 @@ const sinon = require('sinon') function defaultOptions (modification = {}) { const options = { recursive: false, - format: 'dag-pb', hashAlg: 'sha2-256', flush: true, shardSplitThreshold: 1000 @@ -97,32 +96,6 @@ describe('chmod', () => { ]) }) - it('should update the mode with a different codec', async () => { - await cli(`files chmod ${mode} --codec dag-foo ${path}`, { ipfs }) - - expect(ipfs.files.chmod.callCount).to.equal(1) - expect(ipfs.files.chmod.getCall(0).args).to.deep.equal([ - path, - parseInt(mode, 8), - defaultOptions({ - format: 'dag-foo' - }) - ]) - }) - - it('should update the mode with a different codec (short option)', async () => { - await cli(`files chmod ${mode} -c dag-foo ${path}`, { ipfs }) - - expect(ipfs.files.chmod.callCount).to.equal(1) - expect(ipfs.files.chmod.getCall(0).args).to.deep.equal([ - path, - parseInt(mode, 8), - defaultOptions({ - format: 'dag-foo' - }) - ]) - }) - it('should update the mode a with different hash algorithm', async () => { await cli(`files chmod ${mode} --hash-alg sha3-256 ${path}`, { ipfs }) diff --git a/test/cli/cp.js b/test/cli/cp.js index 953fc16f85..a86910eeda 100644 --- a/test/cli/cp.js +++ b/test/cli/cp.js @@ -8,7 +8,6 @@ const sinon = require('sinon') function defaultOptions (modification = {}) { const options = { parents: false, - format: 'dag-pb', hashAlg: 'sha2-256', flush: true, shardSplitThreshold: 1000 @@ -71,32 +70,6 @@ describe('cp', () => { ]) }) - it('should copy files with a different codec', async () => { - await cli(`files cp --codec dag-foo ${source} ${dest}`, { ipfs }) - - expect(ipfs.files.cp.callCount).to.equal(1) - expect(ipfs.files.cp.getCall(0).args).to.deep.equal([ - source, - dest, - defaultOptions({ - format: 'dag-foo' - }) - ]) - }) - - it('should copy files with a different codec (short option)', async () => { - await cli(`files cp -c dag-foo ${source} ${dest}`, { ipfs }) - - expect(ipfs.files.cp.callCount).to.equal(1) - expect(ipfs.files.cp.getCall(0).args).to.deep.equal([ - source, - dest, - defaultOptions({ - format: 'dag-foo' - }) - ]) - }) - it('should copy files with a different hash algorithm', async () => { await cli(`files cp --hash-alg sha3-256 ${source} ${dest}`, { ipfs }) diff --git a/test/cli/mkdir.js b/test/cli/mkdir.js index ea3a0f2a74..af041b97f0 100644 --- a/test/cli/mkdir.js +++ b/test/cli/mkdir.js @@ -10,7 +10,6 @@ function defaultOptions (modification = {}) { const options = { parents: false, cidVersion: 0, - format: 'dag-pb', hashAlg: 'sha2-256', flush: true, shardSplitThreshold: 1000, @@ -99,30 +98,6 @@ describe('mkdir', () => { ]) }) - it('should make a directory with a different codec', async () => { - await cli(`files mkdir --codec dag-foo ${path}`, { ipfs }) - - expect(ipfs.files.mkdir.callCount).to.equal(1) - expect(ipfs.files.mkdir.getCall(0).args).to.deep.equal([ - path, - defaultOptions({ - format: 'dag-foo' - }) - ]) - }) - - it('should make a directory with a different codec (short option)', async () => { - await cli(`files mkdir -c dag-foo ${path}`, { ipfs }) - - expect(ipfs.files.mkdir.callCount).to.equal(1) - expect(ipfs.files.mkdir.getCall(0).args).to.deep.equal([ - path, - defaultOptions({ - format: 'dag-foo' - }) - ]) - }) - it('should make a directory with a different hash algorithm', async () => { await cli(`files mkdir --hash-alg sha3-256 ${path}`, { ipfs }) diff --git a/test/cli/mv.js b/test/cli/mv.js index ca4700536a..860405556d 100644 --- a/test/cli/mv.js +++ b/test/cli/mv.js @@ -11,7 +11,6 @@ function defaultOptions (modification = {}) { parents: false, recursive: false, cidVersion: 0, - format: 'dag-pb', hashAlg: 'sha2-256', flush: true, shardSplitThreshold: 1000 @@ -130,32 +129,6 @@ describe('mv', () => { ]) }) - it('should make a directory with a different codec', async () => { - await cli(`files mv --codec dag-foo ${source} ${dest}`, { ipfs }) - - expect(ipfs.files.mv.callCount).to.equal(1) - expect(ipfs.files.mv.getCall(0).args).to.deep.equal([ - source, - dest, - defaultOptions({ - format: 'dag-foo' - }) - ]) - }) - - it('should make a directory with a different codec (short option)', async () => { - await cli(`files mv -c dag-foo ${source} ${dest}`, { ipfs }) - - expect(ipfs.files.mv.callCount).to.equal(1) - expect(ipfs.files.mv.getCall(0).args).to.deep.equal([ - source, - dest, - defaultOptions({ - format: 'dag-foo' - }) - ]) - }) - it('should make a directory with a different hash algorithm', async () => { await cli(`files mv --hash-alg sha3-256 ${source} ${dest}`, { ipfs }) diff --git a/test/cli/touch.js b/test/cli/touch.js index 56febabd6b..8f9d29439e 100644 --- a/test/cli/touch.js +++ b/test/cli/touch.js @@ -10,7 +10,6 @@ function defaultOptions (modification = {}) { const options = { mtime: null, cidVersion: 0, - format: 'dag-pb', hashAlg: 'sha2-256', flush: true, shardSplitThreshold: 1000 @@ -78,32 +77,6 @@ describe('touch', () => { ]) }) - it('should update the mtime with a different codec', async () => { - await cli(`files touch -m ${mtime.getTime() / 1000} --codec dag-foo ${path}`, { ipfs }) - - expect(ipfs.files.touch.callCount).to.equal(1) - expect(ipfs.files.touch.getCall(0).args).to.deep.equal([ - path, - defaultOptions({ - mtime, - format: 'dag-foo' - }) - ]) - }) - - it('should update the mtime with a different codec (short option)', async () => { - await cli(`files touch -m ${mtime.getTime() / 1000} -c dag-foo ${path}`, { ipfs }) - - expect(ipfs.files.touch.callCount).to.equal(1) - expect(ipfs.files.touch.getCall(0).args).to.deep.equal([ - path, - defaultOptions({ - mtime, - format: 'dag-foo' - }) - ]) - }) - it('should update the mtime with a different hash algorithm', async () => { await cli(`files touch -m ${mtime.getTime() / 1000} --hash-alg sha3-256 ${path}`, { ipfs }) diff --git a/test/cli/write.js b/test/cli/write.js index ce65a9aea3..935d7c8197 100644 --- a/test/cli/write.js +++ b/test/cli/write.js @@ -16,7 +16,6 @@ function defaultOptions (modification = {}) { reduceSingleLeafToSelf: false, cidVersion: 0, hashAlg: 'sha2-256', - format: 'dag-pb', parents: false, progress: undefined, strategy: 'balanced', @@ -348,36 +347,6 @@ describe('write', () => { ]) }) - it('should write to a file with a specified codec', async () => { - const path = '/foo' - - await cli(`files write --codec dag-foo ${path}`, { ipfs, getStdin }) - - expect(ipfs.files.write.callCount).to.equal(1) - expect(ipfs.files.write.getCall(0).args).to.deep.equal([ - path, - stdin, - defaultOptions({ - format: 'dag-foo' - }) - ]) - }) - - it('should write to a file with a specified codec (short option)', async () => { - const path = '/foo' - - await cli(`files write -c dag-foo ${path}`, { ipfs, getStdin }) - - expect(ipfs.files.write.callCount).to.equal(1) - expect(ipfs.files.write.getCall(0).args).to.deep.equal([ - path, - stdin, - defaultOptions({ - format: 'dag-foo' - }) - ]) - }) - it('should write to a file with a specified hash algorithm', async () => { const path = '/foo' diff --git a/test/helpers/http.js b/test/helpers/http.js index e8f58fdb85..4d474fd5ef 100644 --- a/test/helpers/http.js +++ b/test/helpers/http.js @@ -8,7 +8,9 @@ module.exports = (request, { ipfs }) => { server.app.ipfs = ipfs for (const key in routes) { - server.route(routes[key]) + if (Object.prototype.hasOwnProperty.call(routes, key)) { + server.route(routes[key]) + } } return server.inject(request) diff --git a/test/http/chmod.js b/test/http/chmod.js index 19ef1cf1f8..d9f44dbd5b 100644 --- a/test/http/chmod.js +++ b/test/http/chmod.js @@ -8,7 +8,6 @@ const sinon = require('sinon') function defaultOptions (modification = {}) { const options = { recursive: false, - format: 'dag-pb', hashAlg: 'sha2-256', flush: true, shardSplitThreshold: 1000 @@ -80,22 +79,6 @@ describe('chmod', () => { ]) }) - it('should update the mode a different codec', async () => { - await http({ - method: 'POST', - url: `/api/v0/files/chmod?arg=${path}&mode=${mode}&codec=dag-foo` - }, { ipfs }) - - expect(ipfs.files.chmod.callCount).to.equal(1) - expect(ipfs.files.chmod.getCall(0).args).to.deep.equal([ - path, - mode, - defaultOptions({ - format: 'dag-foo' - }) - ]) - }) - it('should update the mode a different hash algorithm', async () => { await http({ method: 'POST', diff --git a/test/http/cp.js b/test/http/cp.js index 4b2a69c2a3..271ce7f0db 100644 --- a/test/http/cp.js +++ b/test/http/cp.js @@ -8,7 +8,6 @@ const sinon = require('sinon') function defaultOptions (modification = {}) { const options = { parents: false, - format: 'dag-pb', hashAlg: 'sha2-256', flush: true, shardSplitThreshold: 1000 @@ -64,22 +63,6 @@ describe('cp', () => () => { ]) }) - it('should copy files with a different codec', async () => { - await http({ - method: 'POST', - url: `/api/v0/files/cp?arg=${source}&arg=${dest}&codec=dag-cbor` - }, { ipfs }) - - expect(ipfs.files.cp.callCount).to.equal(1) - expect(ipfs.files.cp.getCall(0).args).to.deep.equal([ - source, - dest, - defaultOptions({ - format: 'dag-cbor' - }) - ]) - }) - it('should copy files with a different hash algorithm', async () => { await http({ method: 'POST', diff --git a/test/http/mkdir.js b/test/http/mkdir.js index 0e97a7bb5b..586b358651 100644 --- a/test/http/mkdir.js +++ b/test/http/mkdir.js @@ -9,7 +9,6 @@ function defaultOptions (modification = {}) { const options = { parents: false, cidVersion: 0, - format: 'dag-pb', hashAlg: 'sha2-256', flush: true, shardSplitThreshold: 1000, @@ -79,21 +78,6 @@ describe('mkdir', () => { ]) }) - it('should make a directory with a different codec', async () => { - await http({ - method: 'POST', - url: `/api/v0/files/mkdir?arg=${path}&format=dag-cbor` - }, { ipfs }) - - expect(ipfs.files.mkdir.callCount).to.equal(1) - expect(ipfs.files.mkdir.getCall(0).args).to.deep.equal([ - path, - defaultOptions({ - format: 'dag-cbor' - }) - ]) - }) - it('should make a directory with a different hash algorithm', async () => { await http({ method: 'POST', diff --git a/test/http/mv.js b/test/http/mv.js index ae1e8b3cf8..22fd5f243e 100644 --- a/test/http/mv.js +++ b/test/http/mv.js @@ -10,7 +10,6 @@ function defaultOptions (modification = {}) { parents: false, recursive: false, cidVersion: 0, - format: 'dag-pb', hashAlg: 'sha2-256', flush: true, shardSplitThreshold: 1000 @@ -98,22 +97,6 @@ describe('mv', () => { ]) }) - it('should make a directory with a different codec', async () => { - await http({ - method: 'POST', - url: `/api/v0/files/mv?arg=${source}&arg=${dest}&format=dag-cbor` - }, { ipfs }) - - expect(ipfs.files.mv.callCount).to.equal(1) - expect(ipfs.files.mv.getCall(0).args).to.deep.equal([ - source, - dest, - defaultOptions({ - format: 'dag-cbor' - }) - ]) - }) - it('should make a directory with a different hash algorithm', async () => { await http({ method: 'POST', diff --git a/test/http/touch.js b/test/http/touch.js index 9aceceff8c..5f30c66d2d 100644 --- a/test/http/touch.js +++ b/test/http/touch.js @@ -9,7 +9,6 @@ function defaultOptions (modification = {}) { const options = { mtime: null, cidVersion: 0, - format: 'dag-pb', hashAlg: 'sha2-256', flush: true, shardSplitThreshold: 1000 @@ -70,24 +69,6 @@ describe('touch', () => { ]) }) - it('should update the mtime with a different codec', async () => { - await http({ - method: 'POST', - url: `/api/v0/files/touch?arg=${path}&mtime=${mtime.getTime() / 1000}&format=dag-pb` - }, { ipfs }) - - expect(ipfs.files.touch.callCount).to.equal(1) - expect(ipfs.files.touch.getCall(0).args).to.deep.equal([ - path, - defaultOptions({ - mtime: { - secs: 1000 - }, - format: 'dag-pb' - }) - ]) - }) - it('should update the mtime with a different hash algorithm', async () => { await http({ method: 'POST', diff --git a/test/http/write.js b/test/http/write.js index 19f5ac8c92..6d7cc2e635 100644 --- a/test/http/write.js +++ b/test/http/write.js @@ -17,7 +17,6 @@ function defaultOptions (modification = {}) { reduceSingleLeafToSelf: false, cidVersion: 0, hashAlg: 'sha2-256', - format: 'dag-pb', parents: false, progress: undefined, strategy: 'trickle', @@ -230,21 +229,6 @@ describe('write', () => { expect(content).to.equal('hello world') }) - it('should write to a file with a specified codec', async () => { - await http({ - method: 'POST', - url: `/api/v0/files/write?arg=${path}&format=dag-cbor`, - ...await send('hello world') - }, { ipfs }) - - expect(ipfs.files.write.callCount).to.equal(1) - expect(ipfs.files.write.getCall(0)).to.have.nested.property('args[0]', path) - expect(ipfs.files.write.getCall(0)).to.have.nested.deep.property('args[2]', defaultOptions({ - format: 'dag-cbor' - })) - expect(content).to.equal('hello world') - }) - it('should write to a file with a specified hash algorithm', async () => { await http({ method: 'POST',