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

Commit

Permalink
feat(files.add): conform with latest interface-ipfs-core spec
Browse files Browse the repository at this point in the history
  • Loading branch information
daviddias committed Aug 12, 2016
1 parent 7dcb3c4 commit 9940742
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
3 changes: 2 additions & 1 deletion src/add-to-dagnode-transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ module.exports = function (err, res, send, done) {
}
var obj = {
path: entry.Name,
node: node
hash: entry.Hash,
size: node.size()
}
next(null, obj)
})
Expand Down
9 changes: 4 additions & 5 deletions test/interface-ipfs-core/files.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ const expect = require('chai').expect
const isNode = require('detect-node')
const path = require('path')
const test = require('interface-ipfs-core')
const bs58 = require('bs58')
const fs = require('fs')
const FactoryClient = require('../factory/factory-client')
const testfile = fs.readFileSync(path.join(__dirname, '/../data/testfile.txt'))
Expand All @@ -30,14 +29,14 @@ test.files(common)
// mfs tests
describe('.files (pseudo mfs)', () => {
it('add file for testing', (done) => {
const expectedMultihash = 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP'

apiClients.a.files.add(testfile, (err, res) => {
expect(err).to.not.exist

expect(res).to.have.length(1)
const mh = bs58.encode(res[0].node.multihash()).toString()
expect(mh).to.equal('Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP')
expect(res[0].path).to.equal(mh)
expect(res[0].node.links).to.have.length(0)
expect(res[0].hash).to.equal(expectedMultihash)
expect(res[0].path).to.equal(expectedMultihash)
done()
})
})
Expand Down
8 changes: 3 additions & 5 deletions test/interface-ipfs-core/get.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ const expect = require('chai').expect
const isNode = require('detect-node')
const fs = require('fs')
const concat = require('concat-stream')
const bs58 = require('bs58')
const through = require('through2')
const streamEqual = require('stream-equal')
const path = require('path')
Expand Down Expand Up @@ -92,15 +91,14 @@ describe('.get', () => {
}

const bigFile = fs.readFileSync(tfbPath)
const expectedMultihash = 'Qme79tX2bViL26vNjPsF3DP1R9rMKMvnPYJiKTTKPrXJjq'

apiClients.a.files.add(bigFile, (err, res) => {
expect(err).to.not.exist

expect(res).to.have.length(1)
expect(res[0].node.links).to.have.length(58)
const mh = bs58.encode(res[0].node.multihash()).toString()
expect(res[0].path).to.equal(mh)
expect(mh).to.equal('Qme79tX2bViL26vNjPsF3DP1R9rMKMvnPYJiKTTKPrXJjq')
expect(res[0].path).to.equal(expectedMultihash)
expect(res[0].hash).to.equal(expectedMultihash)
done()
})
})
Expand Down

0 comments on commit 9940742

Please sign in to comment.