From 40c43aaa7d99efcf60b17662267bb090e4db9fcf Mon Sep 17 00:00:00 2001 From: David Dias Date: Thu, 9 Mar 2017 07:33:32 +0000 Subject: [PATCH 1/8] feat: update dag.put spec --- API/dag/README.md | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/API/dag/README.md b/API/dag/README.md index 4d0dfe20..82ca237a 100644 --- a/API/dag/README.md +++ b/API/dag/README.md @@ -13,14 +13,20 @@ dag API - `dagNode` - a DAG node that follows one of the supported IPLD formats. - `options` - a object that might contain the follwing values: - - `format` - The IPLD format multicodec. - - `hashAlg` - The hash algorithm to be used over the serialized dagNode. - - `cid` - the CID of the node passed. + - `format` - The IPLD format multicodec. + - `hashAlg` - The hash algorithm to be used over the serialized dagNode. + - or + - `cid` - the CID of the node passed. - **Note** - You should only pass the CID or the format + hashAlg pair and not both -- `callback` must follow `function (err) {}` signature, where `err` is an error if the operation was not successful. +- `callback` must follow `function (err, cid) {}` signature, where `err` is an error if the operation was not successful and CID is the CID generated through the process or the one that was passed If no `callback` is passed, a [promise][] is returned. +**Example:** + +```JavaScript +``` + #### `dag.get` > Retrieve an IPLD format node @@ -38,3 +44,10 @@ If no `callback` is passed, a [promise][] is returned. - `value` - the value or node that was fetched during the get operation. - `remainderPath` - The remainder of the Path that the node was unable to resolve or what was left in a localResolve scenario. + +If no `callback` is passed, a [promise][] is returned. + +**Example:** + +```JavaScript +``` From eb20f315e7bbc85004fdd1007fead8095a73307b Mon Sep 17 00:00:00 2001 From: David Dias Date: Thu, 9 Mar 2017 07:58:44 +0000 Subject: [PATCH 2/8] feat: update dag.get spec --- API/dag/README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/API/dag/README.md b/API/dag/README.md index 82ca237a..f15d43e5 100644 --- a/API/dag/README.md +++ b/API/dag/README.md @@ -35,7 +35,10 @@ If no `callback` is passed, a [promise][] is returned. ##### `JavaScript` - ipfs.dag.get(cid [, path, options], callback) -- `cid` - a [CID][https://github.com/ipfs/js-cid] instance. +- `cid` - can be one of the following: + - a [CID](https://github.com/ipfs/js-cid) instance. + - a CID in its String format (i.e: zdpuAkxd9KzGwJFGhymCZRkPCXtBmBW7mB2tTuEH11HLbES9Y) + - a CID in its String format concatenated with the path to be resolved - `path` - the path to be resolved. Optional. - `options` - a object that might contain the following values: - `localResolve` - bool - if set to true, it will avoid resolving through different objects. From 3f4e81fcf3a41e82c4a10a96d5dbff3651f51650 Mon Sep 17 00:00:00 2001 From: David Dias Date: Thu, 9 Mar 2017 10:32:07 +0000 Subject: [PATCH 3/8] feat: tests for all permutations of dag.get --- API/dag/README.md | 6 ++++ package.json | 3 +- src/dag.js | 78 ++++++++++++++++++++++++++++++++++++----------- 3 files changed, 69 insertions(+), 18 deletions(-) diff --git a/API/dag/README.md b/API/dag/README.md index f15d43e5..3ace5c54 100644 --- a/API/dag/README.md +++ b/API/dag/README.md @@ -27,6 +27,8 @@ If no `callback` is passed, a [promise][] is returned. ```JavaScript ``` +[A great source of examples can be found in the tests for this API.][examples] + #### `dag.get` > Retrieve an IPLD format node @@ -54,3 +56,7 @@ If no `callback` is passed, a [promise][] is returned. ```JavaScript ``` + +[A great source of examples can be found in the tests for this API.][examples] + +[examples](../../src/dag.js) diff --git a/package.json b/package.json index 341ede9e..73119ec2 100644 --- a/package.json +++ b/package.json @@ -30,6 +30,7 @@ "bl": "^1.2.0", "bs58": "^4.0.0", "chai": "^3.5.0", + "cids": "^0.4.1", "concat-stream": "^1.6.0", "detect-node": "^2.0.3", "ipfs-block": "^0.5.4", @@ -54,4 +55,4 @@ "haad ", "nginnever " ] -} \ No newline at end of file +} diff --git a/src/dag.js b/src/dag.js index 3fb3bdeb..96d821bb 100644 --- a/src/dag.js +++ b/src/dag.js @@ -9,9 +9,10 @@ const pull = require('pull-stream') const dagPB = require('ipld-dag-pb') const DAGNode = dagPB.DAGNode const dagCBOR = require('ipld-dag-cbor') +const CID = require('cids') module.exports = (common) => { - describe('.dag', () => { + describe.only('.dag', () => { let ipfs before(function (done) { @@ -100,6 +101,24 @@ module.exports = (common) => { done() }) }) + + it('returns the cid', (done) => { + ipfs.dag.put(cborNode, { + format: 'dag-cbor', + hashAlg: 'sha3-512' + }, (err, cid) => { + expect(err).to.not.exist + expect(cid).to.exist + expect(CID.isCID(cid)).to.be.true + dagCBOR.util.cid(cborNode, (err, _cid) => { + expect(err).to.not.exist + expect(cid.buffer).to.eql(_cid.buffer) + done() + }) + }) + }) + + it.skip('pass the cid instead of format and hashAlg', (done) => {}) }) describe('.get', () => { @@ -175,16 +194,13 @@ module.exports = (common) => { ipfs.dag.put(pbNode, { format: 'dag-pb', hashAlg: 'sha2-256' - }, (err) => { + }, (err, cid) => { expect(err).to.not.exist - dagPB.util.cid(pbNode, (err, cid) => { + ipfs.dag.get(cid, (err, result) => { expect(err).to.not.exist - ipfs.dag.get(cid, (err, result) => { - expect(err).to.not.exist - const node = result.value - expect(pbNode.toJSON()).to.eql(node.toJSON()) - done() - }) + const node = result.value + expect(pbNode.toJSON()).to.eql(node.toJSON()) + done() }) }) }) @@ -193,17 +209,14 @@ module.exports = (common) => { ipfs.dag.put(cborNode, { format: 'dag-cbor', hashAlg: 'sha2-256' - }, (err) => { + }, (err, cid) => { expect(err).to.not.exist - dagCBOR.util.cid(cborNode, (err, cid) => { + ipfs.dag.get(cid, (err, result) => { expect(err).to.not.exist - ipfs.dag.get(cid, (err, result) => { - expect(err).to.not.exist - const node = result.value - expect(cborNode).to.eql(node) - done() - }) + const node = result.value + expect(cborNode).to.eql(node) + done() }) }) }) @@ -267,13 +280,44 @@ module.exports = (common) => { done() }) }) + + it('CID String', (done) => { + const cidCborStr = cidCbor.toBaseEncodedString() + + ipfs.dag.get(cidCborStr, (err, result) => { + expect(err).to.not.exist + + const node = result.value + + dagCBOR.util.cid(node, (err, cid) => { + expect(err).to.not.exist + expect(cid).to.eql(cidCbor) + done() + }) + }) + }) + + it('CID String + path', (done) => { + const cidCborStr = cidCbor.toBaseEncodedString() + + ipfs.dag.get(cidCborStr + '/pb/data', (err, result) => { + expect(err).to.not.exist + expect(result.value).to.eql(new Buffer('I am inside a Protobuf')) + done() + }) + }) }) }) + + describe('.tree', () => {}) + describe('.ls', () => {}) }) describe('promise API', () => { describe('.put', () => {}) describe('.get', () => {}) + describe('.tree', () => {}) + describe('.ls', () => {}) }) }) } From b6d33d142e3095bc038dfb3d92cd8a1c61e90dfa Mon Sep 17 00:00:00 2001 From: David Dias Date: Thu, 9 Mar 2017 10:52:56 +0000 Subject: [PATCH 4/8] feat: add dag.ls and dag.tree spec --- API/dag/README.md | 57 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/API/dag/README.md b/API/dag/README.md index 3ace5c54..957d2210 100644 --- a/API/dag/README.md +++ b/API/dag/README.md @@ -59,4 +59,61 @@ If no `callback` is passed, a [promise][] is returned. [A great source of examples can be found in the tests for this API.][examples] +#### `dag.ls` + +> Enumerate all the first level link names + +##### `Go` **WIP** + +##### `JavaScript` - ipfs.dag.ls(cid [, options], callback) + +- `cid` - can be one of the following: + - a [CID](https://github.com/ipfs/js-cid) instance. + - a CID in its String format (i.e: zdpuAkxd9KzGwJFGhymCZRkPCXtBmBW7mB2tTuEH11HLbES9Y) + - a CID in its String format concatenated with the path to be resolved +- `options` - a object that might contain the following values: + - `stream` - bool - if set to true, it will return a Node.js Readable Stream. + - `pull` - bool - if set to true, it will return a pull-stream. + +`callback` must follow `function (err, result) {}` signature, where `err` is an error if the operation was not successful and `result` is an Array or a Node.js Stream or a pull-stream, depending on the option passed. + +If no `callback` is passed, a [promise][] is returned. + +**Example:** + +```JavaScript +``` + +[A great source of examples can be found in the tests for this API.][examples] + +#### `dag.tree` + +> Enumerate all the entries in a graph + +##### `Go` **WIP** + +##### `JavaScript` - ipfs.dag.tree(cid[, options], callback) + +- `cid` - can be one of the following: + - a [CID](https://github.com/ipfs/js-cid) instance. + - a CID in its String format (i.e: zdpuAkxd9KzGwJFGhymCZRkPCXtBmBW7mB2tTuEH11HLbES9Y) + - a CID in its String format concatenated with the path to be resolved +- `options` - a object that might contain the following values: + - `stream` - bool - if set to true, it will return a Node.js Readable Stream. + - `pull` - bool - if set to true, it will return a pull-stream. + - `localResolve` - bool - if set to true, it will avoid resolving through different objects. + +`callback` must follow `function (err, result) {}` signature, where `err` is an error if the operation was not successful and `result` is an Array or a Node.js Stream or a pull-stream, depending on the option passed. + +If no `callback` is passed, a [promise][] is returned. + +**Example:** + +```JavaScript +``` + +[A great source of examples can be found in the tests for this API.][examples] + + + [examples](../../src/dag.js) From e5565f1523f8aa5e4074cca89bad540e50001d8d Mon Sep 17 00:00:00 2001 From: David Dias Date: Sat, 11 Mar 2017 23:19:51 +0000 Subject: [PATCH 5/8] feat: update tree spec --- API/dag/README.md | 11 +++++------ src/dag.js | 11 ++++++++--- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/API/dag/README.md b/API/dag/README.md index 957d2210..8dc27aa3 100644 --- a/API/dag/README.md +++ b/API/dag/README.md @@ -92,18 +92,18 @@ If no `callback` is passed, a [promise][] is returned. ##### `Go` **WIP** -##### `JavaScript` - ipfs.dag.tree(cid[, options], callback) +##### `JavaScript` - ipfs.dag.tree(cid [, path, options], callback) - `cid` - can be one of the following: - a [CID](https://github.com/ipfs/js-cid) instance. - a CID in its String format (i.e: zdpuAkxd9KzGwJFGhymCZRkPCXtBmBW7mB2tTuEH11HLbES9Y) - a CID in its String format concatenated with the path to be resolved +- `path` - the path to be resolved. Optional. - `options` - a object that might contain the following values: - - `stream` - bool - if set to true, it will return a Node.js Readable Stream. - - `pull` - bool - if set to true, it will return a pull-stream. - - `localResolve` - bool - if set to true, it will avoid resolving through different objects. + - `recursive` - bool - if set to true, it will follow the links and continuously run tree on them, returning all the paths in the graph. + - `level`- Number - the level of nestness we want to fetch paths. A level is an hop from one node to another node. -`callback` must follow `function (err, result) {}` signature, where `err` is an error if the operation was not successful and `result` is an Array or a Node.js Stream or a pull-stream, depending on the option passed. +`callback` must follow `function (err, result) {}` signature, where `err` is an error if the operation was not successful and `result` is an Array with the paths passed. If no `callback` is passed, a [promise][] is returned. @@ -115,5 +115,4 @@ If no `callback` is passed, a [promise][] is returned. [A great source of examples can be found in the tests for this API.][examples] - [examples](../../src/dag.js) diff --git a/src/dag.js b/src/dag.js index 96d821bb..a4a5df7c 100644 --- a/src/dag.js +++ b/src/dag.js @@ -51,7 +51,7 @@ module.exports = (common) => { } }) - describe('.put', () => { + describe.only('.put', () => { it('dag-pb with default hash func (sha2-256)', (done) => { ipfs.dag.put(pbNode, { format: 'dag-pb', @@ -309,8 +309,13 @@ module.exports = (common) => { }) }) - describe('.tree', () => {}) - describe('.ls', () => {}) + describe('.tree', () => { + it.skip('.tree with CID', (done) => {}) + it.skip('.tree with CID and path', (done) => {}) + it.skip('.tree with CID and path as String', (done) => {}) + it.skip('.tree with CID recursive', (done) => {}) + it.skip('.tree with CID and path recursive', (done) => {}) + }) }) describe('promise API', () => { From 4505bdddf95d67c3be5ce5220529ed63bcf559bc Mon Sep 17 00:00:00 2001 From: David Dias Date: Sat, 11 Mar 2017 23:39:18 +0000 Subject: [PATCH 6/8] docs: add examples to put and get --- API/dag/README.md | 76 +++++++++++++++++++++++++++++------------------ src/dag.js | 6 ++-- 2 files changed, 49 insertions(+), 33 deletions(-) diff --git a/API/dag/README.md b/API/dag/README.md index 8dc27aa3..136ffeac 100644 --- a/API/dag/README.md +++ b/API/dag/README.md @@ -25,6 +25,12 @@ If no `callback` is passed, a [promise][] is returned. **Example:** ```JavaScript +const obj = { simple: 'object' } + +ipfs.dag.put(obj, { format: 'dag-cbor', hashAlg: 'sha3-512' }, (err, cid) => { + console.log(cid.toBaseEncodedString()) + // zdpuAzE1oAAMpsfdoexcJv6PmL9UhE8nddUYGU32R98tzV5fv +}) ``` [A great source of examples can be found in the tests for this API.][examples] @@ -55,33 +61,47 @@ If no `callback` is passed, a [promise][] is returned. **Example:** ```JavaScript -``` - -[A great source of examples can be found in the tests for this API.][examples] - -#### `dag.ls` - -> Enumerate all the first level link names - -##### `Go` **WIP** - -##### `JavaScript` - ipfs.dag.ls(cid [, options], callback) - -- `cid` - can be one of the following: - - a [CID](https://github.com/ipfs/js-cid) instance. - - a CID in its String format (i.e: zdpuAkxd9KzGwJFGhymCZRkPCXtBmBW7mB2tTuEH11HLbES9Y) - - a CID in its String format concatenated with the path to be resolved -- `options` - a object that might contain the following values: - - `stream` - bool - if set to true, it will return a Node.js Readable Stream. - - `pull` - bool - if set to true, it will return a pull-stream. - -`callback` must follow `function (err, result) {}` signature, where `err` is an error if the operation was not successful and `result` is an Array or a Node.js Stream or a pull-stream, depending on the option passed. - -If no `callback` is passed, a [promise][] is returned. - -**Example:** - -```JavaScript +// example obj +const obj = { + a: 1, + b: [1, 2, 3], + c: { + ca: [5, 6, 7], + cb: 'foo"' + } +} + +ipfs.dag.put(obj, { format: 'dag-cbor', hashAlg: 'sha2-256' }, (err, cid) => { + console.log(cid.toBaseEncodedString()) + // zdpuAmtur968yprkhG9N5Zxn6MFVoqAWBbhUAkNLJs2UtkTq5 +}) + +function errOrLog(err, result) { + if (err) { + console.error('error: ' + err) + } else { + console.log(result.value) + } +} + +ipfs.dag.get('zdpuAmtur968yprkhG9N5Zxn6MFVoqAWBbhUAkNLJs2UtkTq5/a', errOrLog) +// Returns: +// 1 + +ipfs.dag.get('zdpuAmtur968yprkhG9N5Zxn6MFVoqAWBbhUAkNLJs2UtkTq5/b', errOrLog) +// Returns: +// [1, 2, 3] + +ipfs.dag.get('zdpuAmtur968yprkhG9N5Zxn6MFVoqAWBbhUAkNLJs2UtkTq5/c', errOrLog) +// Returns: +// { +// ca: [5, 6, 7], +// cb: 'foo' +// } + +ipfs.dag.get('zdpuAmtur968yprkhG9N5Zxn6MFVoqAWBbhUAkNLJs2UtkTq5/c/ca/1', errOrLog) +// Returns: +// 6 ``` [A great source of examples can be found in the tests for this API.][examples] @@ -101,7 +121,6 @@ If no `callback` is passed, a [promise][] is returned. - `path` - the path to be resolved. Optional. - `options` - a object that might contain the following values: - `recursive` - bool - if set to true, it will follow the links and continuously run tree on them, returning all the paths in the graph. - - `level`- Number - the level of nestness we want to fetch paths. A level is an hop from one node to another node. `callback` must follow `function (err, result) {}` signature, where `err` is an error if the operation was not successful and `result` is an Array with the paths passed. @@ -114,5 +133,4 @@ If no `callback` is passed, a [promise][] is returned. [A great source of examples can be found in the tests for this API.][examples] - [examples](../../src/dag.js) diff --git a/src/dag.js b/src/dag.js index a4a5df7c..d24316b5 100644 --- a/src/dag.js +++ b/src/dag.js @@ -29,9 +29,7 @@ module.exports = (common) => { }) }) - after((done) => { - common.teardown(done) - }) + after((done) => common.teardown(done)) describe('callback API', () => { let pbNode @@ -51,7 +49,7 @@ module.exports = (common) => { } }) - describe.only('.put', () => { + describe('.put', () => { it('dag-pb with default hash func (sha2-256)', (done) => { ipfs.dag.put(pbNode, { format: 'dag-pb', From f89a30272f8ee4917d0c951e041ba6a378dbb835 Mon Sep 17 00:00:00 2001 From: David Dias Date: Sat, 11 Mar 2017 23:46:56 +0000 Subject: [PATCH 7/8] fix: examples links --- API/dag/README.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/API/dag/README.md b/API/dag/README.md index 136ffeac..8568f634 100644 --- a/API/dag/README.md +++ b/API/dag/README.md @@ -33,7 +33,7 @@ ipfs.dag.put(obj, { format: 'dag-cbor', hashAlg: 'sha3-512' }, (err, cid) => { }) ``` -[A great source of examples can be found in the tests for this API.][examples] +A great source of [examples][] can be found in the tests for this API. #### `dag.get` @@ -104,7 +104,7 @@ ipfs.dag.get('zdpuAmtur968yprkhG9N5Zxn6MFVoqAWBbhUAkNLJs2UtkTq5/c/ca/1', errOrLo // 6 ``` -[A great source of examples can be found in the tests for this API.][examples] +A great source of [examples][] can be found in the tests for this API. #### `dag.tree` @@ -131,6 +131,7 @@ If no `callback` is passed, a [promise][] is returned. ```JavaScript ``` -[A great source of examples can be found in the tests for this API.][examples] +A great source of [examples][] can be found in the tests for this API. -[examples](../../src/dag.js) + +[examples]: https://github.com/ipfs/interface-ipfs-core/blob/master/src/dag.js From 2797e24b8fb33fc37d5e352d4cb7310f29479aeb Mon Sep 17 00:00:00 2001 From: David Dias Date: Sun, 12 Mar 2017 04:53:54 +0000 Subject: [PATCH 8/8] test: .tree tests everywhere --- package.json | 14 +++---- src/dag.js | 115 +++++++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 114 insertions(+), 15 deletions(-) diff --git a/package.json b/package.json index 73119ec2..f7a575a4 100644 --- a/package.json +++ b/package.json @@ -26,20 +26,20 @@ }, "homepage": "https://github.com/ipfs/interface-ipfs-core#readme", "dependencies": { - "async": "^2.1.4", + "async": "^2.1.5", "bl": "^1.2.0", "bs58": "^4.0.0", "chai": "^3.5.0", "cids": "^0.4.1", "concat-stream": "^1.6.0", "detect-node": "^2.0.3", - "ipfs-block": "^0.5.4", - "ipld-dag-cbor": "^0.9.0", - "ipld-dag-pb": "^0.9.4", - "multiaddr": "^2.2.0", - "multihashes": "^0.3.2", + "ipfs-block": "^0.5.5", + "ipld-dag-cbor": "^0.9.1", + "ipld-dag-pb": "^0.9.5", + "multiaddr": "^2.2.1", + "multihashes": "^0.4.3", "pull-stream": "^3.5.0", - "readable-stream": "2.2.2" + "readable-stream": "1.1.14" }, "devDependencies": { "aegir": "^10.0.0" diff --git a/src/dag.js b/src/dag.js index d24316b5..a431567b 100644 --- a/src/dag.js +++ b/src/dag.js @@ -235,7 +235,7 @@ module.exports = (common) => { }) it('dag-pb local scope', (done) => { - ipfs.dag.get(cidPb, 'data', (err, result) => { + ipfs.dag.get(cidPb, 'Data', (err, result) => { expect(err).to.not.exist expect(result.value).to.eql(new Buffer('I am inside a Protobuf')) done() @@ -272,7 +272,7 @@ module.exports = (common) => { it.skip('from dag-pb to dag-cbor', (done) => {}) it('from dag-cbor to dag-pb', (done) => { - ipfs.dag.get(cidCbor, 'pb/data', (err, result) => { + ipfs.dag.get(cidCbor, 'pb/Data', (err, result) => { expect(err).to.not.exist expect(result.value).to.eql(new Buffer('I am inside a Protobuf')) done() @@ -298,7 +298,7 @@ module.exports = (common) => { it('CID String + path', (done) => { const cidCborStr = cidCbor.toBaseEncodedString() - ipfs.dag.get(cidCborStr + '/pb/data', (err, result) => { + ipfs.dag.get(cidCborStr + '/pb/Data', (err, result) => { expect(err).to.not.exist expect(result.value).to.eql(new Buffer('I am inside a Protobuf')) done() @@ -308,11 +308,110 @@ module.exports = (common) => { }) describe('.tree', () => { - it.skip('.tree with CID', (done) => {}) - it.skip('.tree with CID and path', (done) => {}) - it.skip('.tree with CID and path as String', (done) => {}) - it.skip('.tree with CID recursive', (done) => {}) - it.skip('.tree with CID and path recursive', (done) => {}) + let nodePb + let nodeCbor + let cidPb + let cidCbor + + before((done) => { + series([ + (cb) => { + dagPB.DAGNode.create(new Buffer('I am inside a Protobuf'), (err, node) => { + expect(err).to.not.exist + nodePb = node + cb() + }) + }, + (cb) => { + dagPB.util.cid(nodePb, (err, cid) => { + expect(err).to.not.exist + cidPb = cid + cb() + }) + }, + (cb) => { + nodeCbor = { + someData: 'I am inside a Cbor object', + pb: { '/': cidPb.toBaseEncodedString() } + } + + dagCBOR.util.cid(nodeCbor, (err, cid) => { + expect(err).to.not.exist + cidCbor = cid + cb() + }) + } + ], store) + + function store () { + pull( + pull.values([ + { node: nodePb, multicodec: 'dag-pb', hashAlg: 'sha2-256' }, + { node: nodeCbor, multicodec: 'dag-cbor', hashAlg: 'sha2-256' } + ]), + pull.asyncMap((el, cb) => { + ipfs.dag.put(el.node, { + format: el.multicodec, + hashAlg: el.hashAlg + }, cb) + }), + pull.onEnd(done) + ) + } + }) + + it('.tree with CID', (done) => { + ipfs.dag.tree(cidCbor, (err, paths) => { + expect(err).to.not.exist + expect(paths).to.eql([ + 'pb', + 'someData' + ]) + done() + }) + }) + + it('.tree with CID and path', (done) => { + ipfs.dag.tree(cidCbor, 'someData', (err, paths) => { + expect(err).to.not.exist + expect(paths).to.eql([]) + done() + }) + }) + + it('.tree with CID and path as String', (done) => { + const cidCborStr = cidCbor.toBaseEncodedString() + + ipfs.dag.tree(cidCborStr + '/someData', (err, paths) => { + expect(err).to.not.exist + expect(paths).to.eql([]) + done() + }) + }) + + it('.tree with CID recursive (accross different formats)', (done) => { + ipfs.dag.tree(cidCbor, { recursive: true }, (err, paths) => { + expect(err).to.not.exist + expect(paths).to.eql([ + 'pb', + 'pb/Data', + 'pb/Links', + 'someData' + ]) + done() + }) + }) + + it('.tree with CID and path recursive', (done) => { + ipfs.dag.tree(cidCbor, 'pb', { recursive: true }, (err, paths) => { + expect(err).to.not.exist + expect(paths).to.eql([ + 'Data', + 'Links' + ]) + done() + }) + }) }) })