Skip to content
This repository was archived by the owner on Feb 12, 2024. It is now read-only.

Commit 9940742

Browse files
committed
feat(files.add): conform with latest interface-ipfs-core spec
1 parent 7dcb3c4 commit 9940742

File tree

3 files changed

+9
-11
lines changed

3 files changed

+9
-11
lines changed

src/add-to-dagnode-transform.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ module.exports = function (err, res, send, done) {
1616
}
1717
var obj = {
1818
path: entry.Name,
19-
node: node
19+
hash: entry.Hash,
20+
size: node.size()
2021
}
2122
next(null, obj)
2223
})

test/interface-ipfs-core/files.spec.js

+4-5
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ const expect = require('chai').expect
77
const isNode = require('detect-node')
88
const path = require('path')
99
const test = require('interface-ipfs-core')
10-
const bs58 = require('bs58')
1110
const fs = require('fs')
1211
const FactoryClient = require('../factory/factory-client')
1312
const testfile = fs.readFileSync(path.join(__dirname, '/../data/testfile.txt'))
@@ -30,14 +29,14 @@ test.files(common)
3029
// mfs tests
3130
describe('.files (pseudo mfs)', () => {
3231
it('add file for testing', (done) => {
32+
const expectedMultihash = 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP'
33+
3334
apiClients.a.files.add(testfile, (err, res) => {
3435
expect(err).to.not.exist
3536

3637
expect(res).to.have.length(1)
37-
const mh = bs58.encode(res[0].node.multihash()).toString()
38-
expect(mh).to.equal('Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP')
39-
expect(res[0].path).to.equal(mh)
40-
expect(res[0].node.links).to.have.length(0)
38+
expect(res[0].hash).to.equal(expectedMultihash)
39+
expect(res[0].path).to.equal(expectedMultihash)
4140
done()
4241
})
4342
})

test/interface-ipfs-core/get.spec.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ const expect = require('chai').expect
88
const isNode = require('detect-node')
99
const fs = require('fs')
1010
const concat = require('concat-stream')
11-
const bs58 = require('bs58')
1211
const through = require('through2')
1312
const streamEqual = require('stream-equal')
1413
const path = require('path')
@@ -92,15 +91,14 @@ describe('.get', () => {
9291
}
9392

9493
const bigFile = fs.readFileSync(tfbPath)
94+
const expectedMultihash = 'Qme79tX2bViL26vNjPsF3DP1R9rMKMvnPYJiKTTKPrXJjq'
9595

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

9999
expect(res).to.have.length(1)
100-
expect(res[0].node.links).to.have.length(58)
101-
const mh = bs58.encode(res[0].node.multihash()).toString()
102-
expect(res[0].path).to.equal(mh)
103-
expect(mh).to.equal('Qme79tX2bViL26vNjPsF3DP1R9rMKMvnPYJiKTTKPrXJjq')
100+
expect(res[0].path).to.equal(expectedMultihash)
101+
expect(res[0].hash).to.equal(expectedMultihash)
104102
done()
105103
})
106104
})

0 commit comments

Comments
 (0)