diff --git a/js/src/object/get.js b/js/src/object/get.js index 8a960aaa..c5f4e227 100644 --- a/js/src/object/get.js +++ b/js/src/object/get.js @@ -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) @@ -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) + }) + }) }) } diff --git a/package.json b/package.json index 34ba8ce6..333125c8 100644 --- a/package.json +++ b/package.json @@ -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",