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

Commit

Permalink
chore: update unixfs deps (#2809)
Browse files Browse the repository at this point in the history
* chore: update unixfs deps

* fix: fix up tests

* fix: update cid, verified with go

* fix: linting

* fix: fix tests
  • Loading branch information
achingbrain committed Mar 3, 2020
1 parent 6376cec commit e9eca18
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 12 deletions.
25 changes: 22 additions & 3 deletions packages/interface-ipfs-core/src/add.js
Original file line number Diff line number Diff line change
Expand Up @@ -533,16 +533,35 @@ module.exports = (common, options) => {
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 () => {
it('should respect raw leaves when file is smaller than one block and no metadata is present', 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.toString()).to.equal('bafkreifojmzibzlof6xyh5auu3r5vpu5l67brf3fitaf73isdlglqw2t7q')
expect(files[0].cid.codec).to.equal('raw')
expect(files[0].size).to.equal(3)
})

it('should override raw leaves when file is smaller than one block and metadata is present', async () => {
const files = await all(ipfs.add({
content: Buffer.from([0, 1, 2]),
mode: 0o123,
mtime: {
secs: 1000,
nsecs: 0
}
}, {
cidVersion: 1,
rawLeaves: true
}))

expect(files.length).to.equal(1)
expect(files[0].cid.toString()).to.equal('bafybeifmayxiu375ftlgydntjtffy5cssptjvxqw6vyuvtymntm37mpvua')
expect(files[0].cid.codec).to.equal('dag-pb')
expect(files[0].size).to.equal(11)
expect(files[0].size).to.equal(18)
})
})
}
4 changes: 2 additions & 2 deletions packages/ipfs-http-client/test/interface.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ describe('interface-ipfs-core tests', () => {
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/go-ipfs/issues/6940'
name: 'should override raw leaves when file is smaller than one block and metadata is present',
reason: 'TODO not implemented in go-ipfs yet'
}
]
})
Expand Down
4 changes: 2 additions & 2 deletions packages/ipfs-mfs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@
"interface-datastore": "^0.8.0",
"ipfs-multipart": "^0.3.0",
"ipfs-unixfs": "^1.0.0",
"ipfs-unixfs-exporter": "^1.0.0",
"ipfs-unixfs-importer": "^1.0.0",
"ipfs-unixfs-exporter": "^1.0.1",
"ipfs-unixfs-importer": "^1.0.1",
"ipfs-utils": "^0.7.0",
"ipld-dag-pb": "^0.18.2",
"it-all": "^1.0.1",
Expand Down
6 changes: 3 additions & 3 deletions packages/ipfs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@
"ipfs-multipart": "^0.3.0",
"ipfs-repo": "^0.30.1",
"ipfs-unixfs": "^1.0.0",
"ipfs-unixfs-exporter": "^1.0.0",
"ipfs-unixfs-importer": "^1.0.0",
"ipfs-unixfs-exporter": "^1.0.1",
"ipfs-unixfs-importer": "^1.0.1",
"ipfs-utils": "^0.7.2",
"ipld": "^0.25.0",
"ipld-bitcoin": "^0.3.0",
Expand Down Expand Up @@ -182,7 +182,7 @@
"go-ipfs-dep": "0.4.23-3",
"hat": "0.0.3",
"interface-ipfs-core": "^0.132.0",
"ipfs-interop": "github:ipfs/interop#disable-small-file-with-raw-leaves-test",
"ipfs-interop": "^1.0.0",
"ipfsd-ctl": "^3.0.0",
"it-first": "^1.0.1",
"ncp": "^2.0.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/ipfs/test/core/files.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ describe('files', function () {
}))

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

0 comments on commit e9eca18

Please sign in to comment.