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 Jun 14, 2018
1 parent 1f0b72f commit 0e10483
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.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ const dagPB = require('ipld-dag-pb')
const DAGNode = dagPB.DAGNode
const bs58 = require('bs58')
const series = require('async/series')
const UnixFs = require('ipfs-unixfs')
const crypto = require('crypto')
const CID = require('cids')

module.exports = (common) => {
describe('.object', function () {
Expand Down Expand Up @@ -451,6 +454,24 @@ module.exports = (common) => {
})
})
})

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)
})
})
})

describe('.links', () => {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,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.0",
"ipld-dag-pb": "~0.14.4",
"is-ipfs": "~0.3.2",
Expand Down

0 comments on commit 0e10483

Please sign in to comment.