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

Commit f79355f

Browse files
vmxachingbrain
authored andcommitted
fix: update to newest IPLD libraries (#37)
ipld-dag-pb got a new release with breaking changes, update to that release.
1 parent 4822121 commit f79355f

13 files changed

+28
-79
lines changed

package.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@
4545
"detect-node": "^2.0.4",
4646
"dirty-chai": "^2.0.1",
4747
"ipfs-unixfs-exporter": "~0.37.0",
48-
"ipld": "~0.24.0",
49-
"ipld-in-memory": "^2.0.0",
48+
"ipld": "^0.25.0",
49+
"ipld-in-memory": "^3.0.0",
5050
"multihashes": "~0.4.14",
5151
"nyc": "^14.0.0",
5252
"sinon": "^7.1.0"
@@ -60,11 +60,11 @@
6060
"err-code": "^1.1.2",
6161
"hamt-sharding": "~0.0.2",
6262
"ipfs-unixfs": "~0.1.16",
63-
"ipld-dag-pb": "~0.17.2",
63+
"ipld-dag-pb": "^0.18.0",
6464
"multicodec": "~0.5.1",
6565
"multihashing-async": "~0.7.0",
66-
"superstruct": "~0.6.1",
67-
"rabin-wasm": "~0.0.4"
66+
"rabin-wasm": "~0.0.8",
67+
"superstruct": "~0.6.1"
6868
},
6969
"contributors": [
7070
"Alan Shaw <[email protected]>",

src/dag-builder/dir.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const {
88

99
const dirBuilder = async (item, ipld, options) => {
1010
const unixfs = new UnixFS('directory')
11-
const node = DAGNode.create(unixfs.marshal(), [])
11+
const node = new DAGNode(unixfs.marshal(), [])
1212
const cid = await persist(node, ipld, options)
1313
let path = item.path
1414

src/dag-builder/file/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ async function * buildFile (source, ipld, options) {
3636
opts.cidVersion = 1
3737
} else {
3838
unixfs = new UnixFS(options.leafType, buffer)
39-
node = DAGNode.create(unixfs.marshal(), [])
39+
node = new DAGNode(unixfs.marshal())
4040
}
4141

4242
const cid = await persist(node, ipld, opts)
@@ -112,7 +112,7 @@ const reduce = (file, ipld, options) => {
112112
return new DAGLink(leaf.name, leaf.node.size, leaf.cid)
113113
})
114114

115-
const node = DAGNode.create(f.marshal(), links)
115+
const node = new DAGNode(f.marshal(), links)
116116
const cid = await persist(node, ipld, options)
117117

118118
return {

src/dir-flat.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class DirFlat extends Dir {
6868
}
6969

7070
const unixfs = new UnixFS('directory')
71-
let node = DAGNode.create(unixfs.marshal(), links)
71+
const node = new DAGNode(unixfs.marshal(), links)
7272
const cid = await persist(node, ipld, this.options)
7373

7474
this.cid = cid

src/dir-sharded.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ async function * flush (path, bucket, ipld, options) {
103103
shard = subShard
104104
}
105105

106-
links.push(await new DAGLink(labelPrefix, shard.node.size, shard.cid))
106+
links.push(new DAGLink(labelPrefix, shard.node.size, shard.cid))
107107
} else if (typeof child.value.flush === 'function') {
108108
const dir = child.value
109109
let flushedDir
@@ -130,7 +130,7 @@ async function * flush (path, bucket, ipld, options) {
130130
const label = labelPrefix + child.key
131131
const size = value.node.length || value.node.size || value.node.Size
132132

133-
links.push(await new DAGLink(label, size, value.cid))
133+
links.push(new DAGLink(label, size, value.cid))
134134
}
135135
}
136136

@@ -141,7 +141,7 @@ async function * flush (path, bucket, ipld, options) {
141141
dir.fanout = bucket.tableSize()
142142
dir.hashType = options.hashFn.code
143143

144-
const node = DAGNode.create(dir.marshal(), links)
144+
const node = new DAGNode(dir.marshal(), links)
145145
const cid = await persist(node, ipld, options)
146146

147147
yield {

test/benchmark.spec.js

+2-11
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33

44
const importer = require('../src')
55

6-
const chai = require('chai')
7-
chai.use(require('dirty-chai'))
8-
const expect = chai.expect
96
const IPLD = require('ipld')
107
const inMemory = require('ipld-in-memory')
118
const bufferStream = require('async-iterator-buffer-stream')
@@ -20,14 +17,8 @@ describe.skip('benchmark', function () {
2017

2118
let ipld
2219

23-
before((done) => {
24-
inMemory(IPLD, (err, resolver) => {
25-
expect(err).to.not.exist()
26-
27-
ipld = resolver
28-
29-
done()
30-
})
20+
before(async () => {
21+
ipld = await inMemory(IPLD)
3122
})
3223

3324
const times = []

test/builder-dir-sharding.spec.js

+2-8
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,8 @@ const last = require('async-iterator-last')
1515
describe('builder: directory sharding', () => {
1616
let ipld
1717

18-
before((done) => {
19-
inMemory(IPLD, (err, resolver) => {
20-
expect(err).to.not.exist()
21-
22-
ipld = resolver
23-
24-
done()
25-
})
18+
before(async () => {
19+
ipld = await inMemory(IPLD)
2620
})
2721

2822
describe('basic dirbuilder', () => {

test/builder-only-hash.spec.js

+2-8
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,8 @@ const all = require('async-iterator-all')
1212
describe('builder: onlyHash', () => {
1313
let ipld
1414

15-
before((done) => {
16-
inMemory(IPLD, (err, resolver) => {
17-
expect(err).to.not.exist()
18-
19-
ipld = resolver
20-
21-
done()
22-
})
15+
before(async () => {
16+
ipld = await inMemory(IPLD)
2317
})
2418

2519
it('will only chunk and hash if passed an "onlyHash" option', async () => {

test/builder.spec.js

+2-8
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,8 @@ const first = require('async-iterator-first')
1414
describe('builder', () => {
1515
let ipld
1616

17-
before((done) => {
18-
inMemory(IPLD, (err, resolver) => {
19-
expect(err).to.not.exist()
20-
21-
ipld = resolver
22-
23-
done()
24-
})
17+
before(async () => {
18+
ipld = await inMemory(IPLD)
2519
})
2620

2721
const testMultihashes = Object.keys(mh.names).slice(1, 40)

test/hash-parity-with-go-ipfs.spec.js

+2-8
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,8 @@ strategies.forEach(strategy => {
3131
describe('go-ipfs interop using importer:' + strategy, () => {
3232
let ipld
3333

34-
before((done) => {
35-
inMemory(IPLD, (err, resolver) => {
36-
expect(err).to.not.exist()
37-
38-
ipld = resolver
39-
40-
done()
41-
})
34+
before(async () => {
35+
ipld = await inMemory(IPLD)
4236
})
4337

4438
it('yields the same tree as go-ipfs', async function () {

test/import-export-nested-dir.spec.js

+2-8
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,8 @@ describe('import and export: directory', () => {
1414
const rootHash = 'QmdCrquDwd7RfZ6GCZFEVADwe8uyyw1YmF9mtAB7etDgmK'
1515
let ipld
1616

17-
before((done) => {
18-
inMemory(IPLD, (err, resolver) => {
19-
expect(err).to.not.exist()
20-
21-
ipld = resolver
22-
23-
done()
24-
})
17+
before(async () => {
18+
ipld = await inMemory(IPLD)
2519
})
2620

2721
it('imports', async function () {

test/import-export.spec.js

+2-8
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,8 @@ describe('import and export', function () {
2929
describe('using builder: ' + strategy, () => {
3030
let ipld
3131

32-
before((done) => {
33-
inMemory(IPLD, (err, resolver) => {
34-
expect(err).to.not.exist()
35-
36-
ipld = resolver
37-
38-
done()
39-
})
32+
before(async () => {
33+
ipld = await inMemory(IPLD)
4034
})
4135

4236
it('imports and exports', async () => {

test/importer.spec.js

+2-8
Original file line numberDiff line numberDiff line change
@@ -285,14 +285,8 @@ strategies.forEach((strategy) => {
285285
strategy: strategy
286286
}
287287

288-
before((done) => {
289-
inMemory(IPLD, (err, resolver) => {
290-
expect(err).to.not.exist()
291-
292-
ipld = resolver
293-
294-
done()
295-
})
288+
before(async () => {
289+
ipld = await inMemory(IPLD)
296290
})
297291

298292
it('fails on bad content', async () => {

0 commit comments

Comments
 (0)