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

Commit 2f0c205

Browse files
committed
fix: add interface test for ignoring raw leaves when file is small
1 parent b318872 commit 2f0c205

File tree

3 files changed

+16
-11
lines changed

3 files changed

+16
-11
lines changed

packages/interface-ipfs-core/src/add.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,5 +532,17 @@ module.exports = (common, options) => {
532532
it('should not add from an invalid url', () => {
533533
return expect(all(ipfs.add(urlSource('123http://invalid')))).to.eventually.be.rejected()
534534
})
535+
536+
it('should override raw leaves when file is smaller than one block', async () => {
537+
const files = await all(ipfs.add(Buffer.from([0, 1, 2]), {
538+
cidVersion: 1,
539+
rawLeaves: true
540+
}))
541+
542+
expect(files.length).to.equal(1)
543+
expect(files[0].cid.toString()).to.equal('bafybeide2caf5we5a7izifzwzz5ds2gla67vsfgrzvbzpnyyirnfzgwf5e')
544+
expect(files[0].cid.codec).to.equal('dag-pb')
545+
expect(files[0].size).to.equal(11)
546+
})
535547
})
536548
}

packages/ipfs-http-client/test/interface.spec.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ describe('interface-ipfs-core tests', () => {
4343
{
4444
name: 'should ls with metadata',
4545
reason: 'TODO not implemented in go-ipfs yet'
46+
},
47+
{
48+
name: 'should override raw leaves when file is smaller than one block',
49+
reason: 'TODO not implemented in go-ipfs yet https://github.com/ipfs/js-ipfs-unixfs-importer/issues/44#issuecomment-573745942'
4650
}
4751
]
4852
})

packages/ipfs/test/core/files.spec.js

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,6 @@ describe('files', function () {
3838
cidVersion: 1
3939
}))
4040

41-
expect(files.length).to.equal(1)
42-
expect(files[0].cid.toString()).to.equal('bafkreifojmzibzlof6xyh5auu3r5vpu5l67brf3fitaf73isdlglqw2t7q')
43-
expect(files[0].size).to.equal(3)
44-
})
45-
46-
it('should add a file with a v1 CID and not raw leaves', async () => {
47-
const files = await all(ipfs.add(Buffer.from([0, 1, 2]), {
48-
cidVersion: 1,
49-
rawLeaves: false
50-
}))
51-
5241
expect(files.length).to.equal(1)
5342
expect(files[0].cid.toString()).to.equal('bafybeide2caf5we5a7izifzwzz5ds2gla67vsfgrzvbzpnyyirnfzgwf5e')
5443
expect(files[0].size).to.equal(11)

0 commit comments

Comments
 (0)