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

Commit

Permalink
test: adds test vulnerable to encoding translation
Browse files Browse the repository at this point in the history
  • Loading branch information
achingbrain committed Jul 4, 2018
1 parent 83e410a commit a69b9f0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
21 changes: 21 additions & 0 deletions js/src/object/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ const bs58 = require('bs58')
const series = require('async/series')
const hat = require('hat')
const { getDescribe, getIt, expect } = require('../utils/mocha')
const UnixFs = require('ipfs-unixfs')
const crypto = require('crypto')
const CID = require('cids')

module.exports = (createCommon, options) => {
const describe = getDescribe(options)
Expand Down Expand Up @@ -285,5 +288,23 @@ module.exports = (createCommon, options) => {
}
], done)
})

it('supplies unadulterated data', () => {
// has to be big enough to span several DAGNodes
const data = crypto.randomBytes(1024 * 300)

return ipfs.files.add({
path: '',
content: data
})
.then((result) => {
return ipfs.object.get(result[0].hash)
})
.then((node) => {
const meta = UnixFs.unmarshal(node.data)

expect(meta.fileSize()).to.equal(data.length)
})
})
})
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"dirty-chai": "^2.0.1",
"hat": "0.0.3",
"ipfs-block": "~0.7.1",
"ipfs-unixfs": "~0.1.15",
"ipld-dag-cbor": "~0.12.1",
"ipld-dag-pb": "~0.14.5",
"is-ipfs": "~0.3.2",
Expand Down

0 comments on commit a69b9f0

Please sign in to comment.