Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Commit

Permalink
feat: dag API basics (get, put, rm)
Browse files Browse the repository at this point in the history
  • Loading branch information
daviddias committed Jan 31, 2017
1 parent eab222e commit dd3396b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 33 deletions.
15 changes: 0 additions & 15 deletions API/dag/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,6 @@ If no `callback` is passed, a [promise][] is returned.

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

#### `dag.resolve`

> Resolves an IPLD path
##### `Go` **WIP**

##### `JavaScript` - ipfs.dag.resolve(cid, path, callback)

- `cid` is a [CID][https://github.com/ipfs/js-cid] instance.
- `path` is a String that represents a valid path to be resolved

`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.

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

#### `dag.remove`

> Deletes an IPLD node
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"concat-stream": "^1.6.0",
"detect-node": "^2.0.3",
"ipfs-block": "^0.5.4",
"ipld-dag-cbor": "^0.8.5",
"ipld-dag-pb": "^0.9.3",
"multiaddr": "^2.1.1",
"multihashes": "^0.3.1",
Expand All @@ -52,4 +53,4 @@
"haad <haad@headbanggames.com>",
"nginnever <ginneversource@gmail.com>"
]
}
}
24 changes: 7 additions & 17 deletions src/dag.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@
const expect = require('chai').expect
const dagPB = require('ipld-dag-pb')
const DAGNode = dagPB.DAGNode
const dagCBOR = require('ipld-dag-pb')
// const series = require('async/series')
const dagCBOR = require('ipld-dag-cbor')

module.exports = (common) => {
describe.skip('.dag', () => {
describe.only('.dag (basics)', () => {
let ipfs

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

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

/*
* This works because dag-cbor will just treat pbNode as a regular object
it.skip('dag-pb node with wrong multicodec', (done) => {
// This works because dag-cbor will just treat pbNode as a
// regular object
Expand All @@ -66,6 +67,7 @@ module.exports = (common) => {
done()
})
})
*/

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

describe('.resolve', () => {
it.skip('dag-pb local scope', (done) => {})
it.skip('dag-pb one level', (done) => {})
it.skip('dag-pb two levels', (done) => {})
it.skip('dag-cbor local scope', (done) => {})
it.skip('dag-cbor one level', (done) => {})
it.skip('dag-cbor two levels', (done) => {})
it.skip('from dag-pb to dag-cbor', (done) => {})
it.skip('from dag-cbor to dag-pb', (done) => {})
})

describe('.rm', () => {
let pbNode

Expand All @@ -163,7 +154,7 @@ module.exports = (common) => {
expect(err).to.not.exist
ipfs.dag.rm(cid, done)
// TODO When we get timeouts in js-ipfs, try to fetch again
// and observe it timesout without the node
// and observe it timeout without the node
})
})
})
Expand All @@ -174,7 +165,6 @@ module.exports = (common) => {
describe('promise API', () => {
describe('.put', () => {})
describe('.get', () => {})
describe('.resolve', () => {})
describe('.rm', () => {})
})
})
Expand Down

0 comments on commit dd3396b

Please sign in to comment.