diff --git a/package.json b/package.json index f696200..50db4e6 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,8 @@ "url": "https://github.com/ipld/js-ipld-dag-cbor/issues" }, "engines": { - "node": ">=4.0.0" + "node": ">=4.0.0", + "npm": ">=3.0.0" }, "homepage": "https://github.com/ipld/js-ipld-dag-cbor", "dependencies": { @@ -51,7 +52,7 @@ "deep-freeze": "0.0.1", "dirty-chai": "^1.2.2", "garbage": "0.0.0", - "ipfs-block": "~0.5.5", + "ipfs-block": "~0.6.0", "pre-commit": "^1.2.2" }, "contributors": [ diff --git a/src/resolver.js b/src/resolver.js index 1ef36c9..8ac9e39 100644 --- a/src/resolver.js +++ b/src/resolver.js @@ -9,7 +9,7 @@ exports.multicodec = 'dag-cbor' /* * resolve: receives a path and a block and returns the value on path, - * throw if not possible. `block` is an IPFS Block instance (contains data + key) + * throw if not possible. `block` is an IPFS Block instance (contains data + cid) */ exports.resolve = (block, path, callback) => { if (typeof path === 'function') { diff --git a/test/resolver.spec.js b/test/resolver.spec.js index 7376064..b415a88 100644 --- a/test/resolver.spec.js +++ b/test/resolver.spec.js @@ -6,11 +6,16 @@ const chai = require('chai') const dirtyChai = require('dirty-chai') const expect = chai.expect chai.use(dirtyChai) -const dagCBOR = require('../src') -const resolver = dagCBOR.resolver + const Block = require('ipfs-block') -const series = require('async/series') +const map = require('async/map') +const waterfall = require('async/waterfall') +const parallel = require('async/parallel') const CID = require('cids') +const multihashing = require('multihashing-async') + +const dagCBOR = require('../src') +const resolver = dagCBOR.resolver describe('IPLD format resolver (local)', () => { let emptyNodeBlock @@ -32,20 +37,21 @@ describe('IPLD format resolver (local)', () => { ] } - series([ - (cb) => { - dagCBOR.util.serialize(emptyNode, (err, serialized) => { - expect(err).to.not.exist() - emptyNodeBlock = new Block(serialized) - cb() - }) - }, - (cb) => { - dagCBOR.util.serialize(node, (err, serialized) => { + waterfall([ + (cb) => parallel([ + (cb) => dagCBOR.util.serialize(emptyNode, cb), + (cb) => dagCBOR.util.serialize(node, cb) + ], cb), + (res, cb) => map(res, (s, cb) => { + multihashing(s, 'sha2-256', (err, multihash) => { expect(err).to.not.exist() - nodeBlock = new Block(serialized) - cb() + cb(null, new Block(s, new CID(multihash))) }) + }, cb), + (blocks, cb) => { + emptyNodeBlock = blocks[0] + nodeBlock = blocks[1] + cb() } ], done) })