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

feat(files.add): conform with latest interface-ipfs-core spec #345

Merged
merged 2 commits into from
Aug 12, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ language: node_js
node_js:
- 4
- 5
- "stable"

# Make sure we have new NPM.
before_install:
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"chai": "^3.5.0",
"gulp": "^3.9.1",
"hapi": "^14.1.0",
"interface-ipfs-core": "^0.7.2",
"interface-ipfs-core": "^0.8.0",
"ipfsd-ctl": "^0.14.0",
"passthrough-counter": "^1.0.0",
"pre-commit": "^1.1.3",
Expand Down
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()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No longer checking # links?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because we don't return the full dag node anymore

})
})
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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No longer checking # links?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

expect(res[0].hash).to.equal(expectedMultihash)
done()
})
})
Expand Down