Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Commit

Permalink
fix: add interface test for ignoring raw leaves when file is small
Browse files Browse the repository at this point in the history
  • Loading branch information
achingbrain committed Mar 1, 2020
1 parent b318872 commit 2f0c205
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
12 changes: 12 additions & 0 deletions packages/interface-ipfs-core/src/add.js
Original file line number Diff line number Diff line change
Expand Up @@ -532,5 +532,17 @@ module.exports = (common, options) => {
it('should not add from an invalid url', () => {
return expect(all(ipfs.add(urlSource('123http://invalid')))).to.eventually.be.rejected()
})

it('should override raw leaves when file is smaller than one block', async () => {
const files = await all(ipfs.add(Buffer.from([0, 1, 2]), {
cidVersion: 1,
rawLeaves: true
}))

expect(files.length).to.equal(1)
expect(files[0].cid.toString()).to.equal('bafybeide2caf5we5a7izifzwzz5ds2gla67vsfgrzvbzpnyyirnfzgwf5e')
expect(files[0].cid.codec).to.equal('dag-pb')
expect(files[0].size).to.equal(11)
})
})
}
4 changes: 4 additions & 0 deletions packages/ipfs-http-client/test/interface.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ describe('interface-ipfs-core tests', () => {
{
name: 'should ls with metadata',
reason: 'TODO not implemented in go-ipfs yet'
},
{
name: 'should override raw leaves when file is smaller than one block',
reason: 'TODO not implemented in go-ipfs yet https://github.com/ipfs/js-ipfs-unixfs-importer/issues/44#issuecomment-573745942'
}
]
})
Expand Down
11 changes: 0 additions & 11 deletions packages/ipfs/test/core/files.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,6 @@ describe('files', function () {
cidVersion: 1
}))

expect(files.length).to.equal(1)
expect(files[0].cid.toString()).to.equal('bafkreifojmzibzlof6xyh5auu3r5vpu5l67brf3fitaf73isdlglqw2t7q')
expect(files[0].size).to.equal(3)
})

it('should add a file with a v1 CID and not raw leaves', async () => {
const files = await all(ipfs.add(Buffer.from([0, 1, 2]), {
cidVersion: 1,
rawLeaves: false
}))

expect(files.length).to.equal(1)
expect(files[0].cid.toString()).to.equal('bafybeide2caf5we5a7izifzwzz5ds2gla67vsfgrzvbzpnyyirnfzgwf5e')
expect(files[0].size).to.equal(11)
Expand Down

0 comments on commit 2f0c205

Please sign in to comment.