Skip to content
This repository was archived by the owner on Mar 10, 2020. It is now read-only.

Commit dd3396b

Browse files
committed
feat: dag API basics (get, put, rm)
1 parent eab222e commit dd3396b

File tree

3 files changed

+9
-33
lines changed

3 files changed

+9
-33
lines changed

API/dag/README.md

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,21 +32,6 @@ If no `callback` is passed, a [promise][] is returned.
3232

3333
If no `callback` is passed, a [promise][] is returned.
3434

35-
#### `dag.resolve`
36-
37-
> Resolves an IPLD path
38-
39-
##### `Go` **WIP**
40-
41-
##### `JavaScript` - ipfs.dag.resolve(cid, path, callback)
42-
43-
- `cid` is a [CID][https://github.com/ipfs/js-cid] instance.
44-
- `path` is a String that represents a valid path to be resolved
45-
46-
`callback` must follow `function (err, value) {}` signature, where `err` is an error if the operation was not successful and `value` is the value it was retrieved.
47-
48-
If no `callback` is passed, a [promise][] is returned.
49-
5035
#### `dag.remove`
5136

5237
> Deletes an IPLD node

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
"concat-stream": "^1.6.0",
3434
"detect-node": "^2.0.3",
3535
"ipfs-block": "^0.5.4",
36+
"ipld-dag-cbor": "^0.8.5",
3637
"ipld-dag-pb": "^0.9.3",
3738
"multiaddr": "^2.1.1",
3839
"multihashes": "^0.3.1",
@@ -52,4 +53,4 @@
5253
5354
"nginnever <[email protected]>"
5455
]
55-
}
56+
}

src/dag.js

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,10 @@
66
const expect = require('chai').expect
77
const dagPB = require('ipld-dag-pb')
88
const DAGNode = dagPB.DAGNode
9-
const dagCBOR = require('ipld-dag-pb')
10-
// const series = require('async/series')
9+
const dagCBOR = require('ipld-dag-cbor')
1110

1211
module.exports = (common) => {
13-
describe.skip('.dag', () => {
12+
describe.only('.dag (basics)', () => {
1413
let ipfs
1514

1615
before(function (done) {
@@ -54,10 +53,12 @@ module.exports = (common) => {
5453
ipfs.dag.put(pbNode, 'dag-pb', 'sha2-256', done)
5554
})
5655

57-
it.skip('dag-pb with custom hash func (sha3-512)', (done) => {
56+
it('dag-pb with custom hash func (sha3-512)', (done) => {
5857
ipfs.dag.put(pbNode, 'dag-pb', 'sha3-512', done)
5958
})
6059

60+
/*
61+
* This works because dag-cbor will just treat pbNode as a regular object
6162
it.skip('dag-pb node with wrong multicodec', (done) => {
6263
// This works because dag-cbor will just treat pbNode as a
6364
// regular object
@@ -66,6 +67,7 @@ module.exports = (common) => {
6667
done()
6768
})
6869
})
70+
*/
6971

7072
it('dag-cbor with default hash func (sha2-256)', (done) => {
7173
ipfs.dag.put(cborNode, 'dag-cbor', 'sha2-256', done)
@@ -130,17 +132,6 @@ module.exports = (common) => {
130132
})
131133
})
132134

133-
describe('.resolve', () => {
134-
it.skip('dag-pb local scope', (done) => {})
135-
it.skip('dag-pb one level', (done) => {})
136-
it.skip('dag-pb two levels', (done) => {})
137-
it.skip('dag-cbor local scope', (done) => {})
138-
it.skip('dag-cbor one level', (done) => {})
139-
it.skip('dag-cbor two levels', (done) => {})
140-
it.skip('from dag-pb to dag-cbor', (done) => {})
141-
it.skip('from dag-cbor to dag-pb', (done) => {})
142-
})
143-
144135
describe('.rm', () => {
145136
let pbNode
146137

@@ -163,7 +154,7 @@ module.exports = (common) => {
163154
expect(err).to.not.exist
164155
ipfs.dag.rm(cid, done)
165156
// TODO When we get timeouts in js-ipfs, try to fetch again
166-
// and observe it timesout without the node
157+
// and observe it timeout without the node
167158
})
168159
})
169160
})
@@ -174,7 +165,6 @@ module.exports = (common) => {
174165
describe('promise API', () => {
175166
describe('.put', () => {})
176167
describe('.get', () => {})
177-
describe('.resolve', () => {})
178168
describe('.rm', () => {})
179169
})
180170
})

0 commit comments

Comments
 (0)