diff --git a/package.json b/package.json index 9efc8f6..a25a7d6 100644 --- a/package.json +++ b/package.json @@ -45,8 +45,8 @@ "detect-node": "^2.0.4", "dirty-chai": "^2.0.1", "ipfs-unixfs-exporter": "~0.37.0", - "ipld": "~0.24.0", - "ipld-in-memory": "^2.0.0", + "ipld": "^0.25.0", + "ipld-in-memory": "^3.0.0", "multihashes": "~0.4.14", "nyc": "^14.0.0", "sinon": "^7.1.0" @@ -60,11 +60,11 @@ "err-code": "^1.1.2", "hamt-sharding": "~0.0.2", "ipfs-unixfs": "~0.1.16", - "ipld-dag-pb": "~0.17.2", + "ipld-dag-pb": "^0.18.0", "multicodec": "~0.5.1", "multihashing-async": "~0.7.0", - "superstruct": "~0.6.1", - "rabin-wasm": "~0.0.4" + "rabin-wasm": "~0.0.8", + "superstruct": "~0.6.1" }, "contributors": [ "Alan Shaw ", diff --git a/src/dag-builder/dir.js b/src/dag-builder/dir.js index db73d6d..54a0399 100644 --- a/src/dag-builder/dir.js +++ b/src/dag-builder/dir.js @@ -8,7 +8,7 @@ const { const dirBuilder = async (item, ipld, options) => { const unixfs = new UnixFS('directory') - const node = DAGNode.create(unixfs.marshal(), []) + const node = new DAGNode(unixfs.marshal(), []) const cid = await persist(node, ipld, options) let path = item.path diff --git a/src/dag-builder/file/index.js b/src/dag-builder/file/index.js index 528f869..7d2be22 100644 --- a/src/dag-builder/file/index.js +++ b/src/dag-builder/file/index.js @@ -36,7 +36,7 @@ async function * buildFile (source, ipld, options) { opts.cidVersion = 1 } else { unixfs = new UnixFS(options.leafType, buffer) - node = DAGNode.create(unixfs.marshal(), []) + node = new DAGNode(unixfs.marshal()) } const cid = await persist(node, ipld, opts) @@ -112,7 +112,7 @@ const reduce = (file, ipld, options) => { return new DAGLink(leaf.name, leaf.node.size, leaf.cid) }) - const node = DAGNode.create(f.marshal(), links) + const node = new DAGNode(f.marshal(), links) const cid = await persist(node, ipld, options) return { diff --git a/src/dir-flat.js b/src/dir-flat.js index c46670c..d2433be 100644 --- a/src/dir-flat.js +++ b/src/dir-flat.js @@ -68,7 +68,7 @@ class DirFlat extends Dir { } const unixfs = new UnixFS('directory') - let node = DAGNode.create(unixfs.marshal(), links) + const node = new DAGNode(unixfs.marshal(), links) const cid = await persist(node, ipld, this.options) this.cid = cid diff --git a/src/dir-sharded.js b/src/dir-sharded.js index fe3d913..f27074f 100644 --- a/src/dir-sharded.js +++ b/src/dir-sharded.js @@ -103,7 +103,7 @@ async function * flush (path, bucket, ipld, options) { shard = subShard } - links.push(await new DAGLink(labelPrefix, shard.node.size, shard.cid)) + links.push(new DAGLink(labelPrefix, shard.node.size, shard.cid)) } else if (typeof child.value.flush === 'function') { const dir = child.value let flushedDir @@ -130,7 +130,7 @@ async function * flush (path, bucket, ipld, options) { const label = labelPrefix + child.key const size = value.node.length || value.node.size || value.node.Size - links.push(await new DAGLink(label, size, value.cid)) + links.push(new DAGLink(label, size, value.cid)) } } @@ -141,7 +141,7 @@ async function * flush (path, bucket, ipld, options) { dir.fanout = bucket.tableSize() dir.hashType = options.hashFn.code - const node = DAGNode.create(dir.marshal(), links) + const node = new DAGNode(dir.marshal(), links) const cid = await persist(node, ipld, options) yield { diff --git a/test/benchmark.spec.js b/test/benchmark.spec.js index 81f5b5f..1c96013 100644 --- a/test/benchmark.spec.js +++ b/test/benchmark.spec.js @@ -3,9 +3,6 @@ const importer = require('../src') -const chai = require('chai') -chai.use(require('dirty-chai')) -const expect = chai.expect const IPLD = require('ipld') const inMemory = require('ipld-in-memory') const bufferStream = require('async-iterator-buffer-stream') @@ -20,14 +17,8 @@ describe.skip('benchmark', function () { let ipld - before((done) => { - inMemory(IPLD, (err, resolver) => { - expect(err).to.not.exist() - - ipld = resolver - - done() - }) + before(async () => { + ipld = await inMemory(IPLD) }) const times = [] diff --git a/test/builder-dir-sharding.spec.js b/test/builder-dir-sharding.spec.js index fb941f5..057eb2e 100644 --- a/test/builder-dir-sharding.spec.js +++ b/test/builder-dir-sharding.spec.js @@ -15,14 +15,8 @@ const last = require('async-iterator-last') describe('builder: directory sharding', () => { let ipld - before((done) => { - inMemory(IPLD, (err, resolver) => { - expect(err).to.not.exist() - - ipld = resolver - - done() - }) + before(async () => { + ipld = await inMemory(IPLD) }) describe('basic dirbuilder', () => { diff --git a/test/builder-only-hash.spec.js b/test/builder-only-hash.spec.js index 6514483..45ac5dd 100644 --- a/test/builder-only-hash.spec.js +++ b/test/builder-only-hash.spec.js @@ -12,14 +12,8 @@ const all = require('async-iterator-all') describe('builder: onlyHash', () => { let ipld - before((done) => { - inMemory(IPLD, (err, resolver) => { - expect(err).to.not.exist() - - ipld = resolver - - done() - }) + before(async () => { + ipld = await inMemory(IPLD) }) it('will only chunk and hash if passed an "onlyHash" option', async () => { diff --git a/test/builder.spec.js b/test/builder.spec.js index 0b9f694..1eea492 100644 --- a/test/builder.spec.js +++ b/test/builder.spec.js @@ -14,14 +14,8 @@ const first = require('async-iterator-first') describe('builder', () => { let ipld - before((done) => { - inMemory(IPLD, (err, resolver) => { - expect(err).to.not.exist() - - ipld = resolver - - done() - }) + before(async () => { + ipld = await inMemory(IPLD) }) const testMultihashes = Object.keys(mh.names).slice(1, 40) diff --git a/test/hash-parity-with-go-ipfs.spec.js b/test/hash-parity-with-go-ipfs.spec.js index eb413a8..ce936be 100644 --- a/test/hash-parity-with-go-ipfs.spec.js +++ b/test/hash-parity-with-go-ipfs.spec.js @@ -31,14 +31,8 @@ strategies.forEach(strategy => { describe('go-ipfs interop using importer:' + strategy, () => { let ipld - before((done) => { - inMemory(IPLD, (err, resolver) => { - expect(err).to.not.exist() - - ipld = resolver - - done() - }) + before(async () => { + ipld = await inMemory(IPLD) }) it('yields the same tree as go-ipfs', async function () { diff --git a/test/import-export-nested-dir.spec.js b/test/import-export-nested-dir.spec.js index 5f86375..8d58080 100644 --- a/test/import-export-nested-dir.spec.js +++ b/test/import-export-nested-dir.spec.js @@ -14,14 +14,8 @@ describe('import and export: directory', () => { const rootHash = 'QmdCrquDwd7RfZ6GCZFEVADwe8uyyw1YmF9mtAB7etDgmK' let ipld - before((done) => { - inMemory(IPLD, (err, resolver) => { - expect(err).to.not.exist() - - ipld = resolver - - done() - }) + before(async () => { + ipld = await inMemory(IPLD) }) it('imports', async function () { diff --git a/test/import-export.spec.js b/test/import-export.spec.js index 86f4435..16a91ea 100644 --- a/test/import-export.spec.js +++ b/test/import-export.spec.js @@ -29,14 +29,8 @@ describe('import and export', function () { describe('using builder: ' + strategy, () => { let ipld - before((done) => { - inMemory(IPLD, (err, resolver) => { - expect(err).to.not.exist() - - ipld = resolver - - done() - }) + before(async () => { + ipld = await inMemory(IPLD) }) it('imports and exports', async () => { diff --git a/test/importer.spec.js b/test/importer.spec.js index b08931c..ed618df 100644 --- a/test/importer.spec.js +++ b/test/importer.spec.js @@ -285,14 +285,8 @@ strategies.forEach((strategy) => { strategy: strategy } - before((done) => { - inMemory(IPLD, (err, resolver) => { - expect(err).to.not.exist() - - ipld = resolver - - done() - }) + before(async () => { + ipld = await inMemory(IPLD) }) it('fails on bad content', async () => {