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

fix: update to newest IPLD libraries #37

Merged
merged 1 commit into from
Aug 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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 <[email protected]>",
Expand Down
2 changes: 1 addition & 1 deletion src/dag-builder/dir.js
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions src/dag-builder/file/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/dir-flat.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/dir-sharded.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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))
}
}

Expand All @@ -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 {
Expand Down
13 changes: 2 additions & 11 deletions test/benchmark.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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 = []
Expand Down
10 changes: 2 additions & 8 deletions test/builder-dir-sharding.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
10 changes: 2 additions & 8 deletions test/builder-only-hash.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down
10 changes: 2 additions & 8 deletions test/builder.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 2 additions & 8 deletions test/hash-parity-with-go-ipfs.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down
10 changes: 2 additions & 8 deletions test/import-export-nested-dir.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down
10 changes: 2 additions & 8 deletions test/import-export.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down
10 changes: 2 additions & 8 deletions test/importer.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down