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

Commit 03f4069

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

File tree

4 files changed

+18
-36
lines changed

4 files changed

+18
-36
lines changed

package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@
4444
"chai": "^4.2.0",
4545
"detect-node": "^2.0.4",
4646
"dirty-chai": "^2.0.1",
47-
"ipld": "~0.24.0",
48-
"ipld-dag-pb": "~0.17.1",
49-
"ipld-in-memory": "^2.0.0",
47+
"ipld": "^0.25.0",
48+
"ipld-dag-pb": "^0.18.0",
49+
"ipld-in-memory": "^3.0.0",
5050
"multicodec": "~0.5.1",
5151
"multihashes": "~0.4.14",
5252
"nyc": "^14.0.0",

test/exporter-sharded.spec.js

+4-10
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,8 @@ describe('exporter sharded', function () {
4646
}))).cid
4747
}
4848

49-
before((done) => {
50-
inMemory(IPLD, (err, resolver) => {
51-
expect(err).to.not.exist()
52-
53-
ipld = resolver
54-
55-
done()
56-
})
49+
before(async () => {
50+
ipld = await inMemory(IPLD)
5751
})
5852

5953
it('exports a sharded directory', async () => {
@@ -190,15 +184,15 @@ describe('exporter sharded', function () {
190184
it('exports a file from a sharded directory inside a regular directory inside a sharded directory', async () => {
191185
const dirCid = await createShard(15)
192186

193-
const node = await DAGNode.create(new UnixFS('directory').marshal(), [
187+
const node = new DAGNode(new UnixFS('directory').marshal(), [
194188
new DAGLink('shard', 5, dirCid)
195189
])
196190
const nodeCid = await ipld.put(node, mc.DAG_PB, {
197191
cidVersion: 0,
198192
hashAlg: mh.names['sha2-256']
199193
})
200194

201-
const shardNode = await DAGNode.create(new UnixFS('hamt-sharded-directory').marshal(), [
195+
const shardNode = new DAGNode(new UnixFS('hamt-sharded-directory').marshal(), [
202196
new DAGLink('75normal-dir', 5, nodeCid)
203197
])
204198
const shardNodeCid = await ipld.put(shardNode, mc.DAG_PB, {

test/exporter-subtree.spec.js

+2-8
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,8 @@ const exporter = require('./../src')
1919
describe('exporter subtree', () => {
2020
let ipld
2121

22-
before((done) => {
23-
inMemory(IPLD, (err, resolver) => {
24-
expect(err).to.not.exist()
25-
26-
ipld = resolver
27-
28-
done()
29-
})
22+
before(async () => {
23+
ipld = await inMemory(IPLD)
3024
})
3125

3226
it('exports a file 2 levels down', async () => {

test/exporter.spec.js

+9-15
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ describe('exporter', () => {
4040

4141
const file = new UnixFS(options.type, options.content)
4242

43-
const node = await DAGNode.create(file.marshal(), options.links)
43+
const node = new DAGNode(file.marshal(), options.links)
4444
const cid = await ipld.put(node, mc.DAG_PB, {
4545
cidVersion: 0,
4646
hashAlg: mh.names['sha2-256']
@@ -104,7 +104,7 @@ describe('exporter', () => {
104104
links.push(new DAGLink('', child.node.size, child.cid))
105105
}
106106

107-
const node = await DAGNode.create(file.marshal(), links)
107+
const node = new DAGNode(file.marshal(), links)
108108
const cid = await ipld.put(node, mc.DAG_PB, {
109109
cidVersion: 1,
110110
hashAlg: mh.names['sha2-256']
@@ -116,14 +116,8 @@ describe('exporter', () => {
116116
}
117117
}
118118

119-
before((done) => {
120-
inMemory(IPLD, (err, resolver) => {
121-
expect(err).to.not.exist()
122-
123-
ipld = resolver
124-
125-
done()
126-
})
119+
before(async () => {
120+
ipld = await inMemory(IPLD)
127121
})
128122

129123
it('ensure hash inputs are sanitized', async () => {
@@ -197,14 +191,14 @@ describe('exporter', () => {
197191
it('exports a small file with links', async () => {
198192
const content = Buffer.from([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
199193
const chunk1 = new UnixFS('raw', content.slice(0, 5))
200-
const chunkNode1 = await DAGNode.create(chunk1.marshal())
194+
const chunkNode1 = new DAGNode(chunk1.marshal())
201195
const chunkCid1 = await ipld.put(chunkNode1, mc.DAG_PB, {
202196
cidVersion: 0,
203197
hashAlg: mh.names['sha2-256']
204198
})
205199

206200
const chunk2 = new UnixFS('raw', content.slice(5))
207-
const chunkNode2 = await DAGNode.create(chunk2.marshal())
201+
const chunkNode2 = new DAGNode(chunk2.marshal())
208202
const chunkCid2 = await ipld.put(chunkNode2, mc.DAG_PB, {
209203
cidVersion: 0,
210204
hashAlg: mh.names['sha2-256']
@@ -214,7 +208,7 @@ describe('exporter', () => {
214208
file.addBlockSize(5)
215209
file.addBlockSize(5)
216210

217-
const fileNode = await DAGNode.create(file.marshal(), [
211+
const fileNode = new DAGNode(file.marshal(), [
218212
new DAGLink('', chunkNode1.size, chunkCid1),
219213
new DAGLink('', chunkNode2.size, chunkCid2)
220214
])
@@ -822,7 +816,7 @@ describe('exporter', () => {
822816
})
823817

824818
it('errors we export a non-unixfs dag-pb node', async () => {
825-
const cid = await ipld.put(await DAGNode.create(Buffer.from([0, 1, 2, 3, 4])), mc.DAG_PB)
819+
const cid = await ipld.put(new DAGNode(Buffer.from([0, 1, 2, 3, 4])), mc.DAG_PB)
826820

827821
try {
828822
await exporter(cid, ipld)
@@ -839,7 +833,7 @@ describe('exporter', () => {
839833
const file = new UnixFS('file')
840834
file.addBlockSize(100)
841835

842-
const cid = await ipld.put(await DAGNode.create(file.marshal(), [
836+
const cid = await ipld.put(new DAGNode(file.marshal(), [
843837
new DAGLink('', 100, cborNodeCid)
844838
]), mc.DAG_PB)
845839

0 commit comments

Comments
 (0)