Skip to content

test: adds a test for getting the same multihash from different CID versions #89

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 3, 2020
Merged
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
23 changes: 23 additions & 0 deletions packages/ipfs-unixfs-importer/test/importer.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const blockApi = require('./helpers/block')
const uint8ArrayConcat = require('uint8arrays/concat')
const uint8ArrayFromString = require('uint8arrays/from-string')
const uint8ArrayToString = require('uint8arrays/to-string')
const last = require('it-last')

function stringifyMh (files) {
return files.map((file) => {
Expand Down Expand Up @@ -1059,4 +1060,26 @@ describe('configuration', () => {
expect(validated).to.be.true()
expect(chunked).to.be.true()
})

it('imports the same data with different CID versions and gets the same multihash', async () => {
const ipld = await inMemory(IPLD)
const block = blockApi(ipld)
const buf = uint8ArrayFromString('content')

const { cid: cidV0 } = await last(importer([{
content: buf
}], block, {
cidVersion: 0,
rawLeaves: false
}))

const { cid: cidV1 } = await last(importer([{
content: buf
}], block, {
cidVersion: 1,
rawLeaves: false
}))

expect(cidV0.multihash).to.deep.equal(cidV1.multihash)
})
})