This repository has been archived by the owner on Feb 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: jsipfs add --only-hash (#1233)
* add --only-hash flag * skeleton http option passing, checkpoint commit to check some broken tests. * deep logging for debugging. Checkpoint * found the levledown problem! line endings! * add only-hash as a qs option for the send-files-stream. Also added some tests to help me figure that out * update --only-hash test, increase timeout for the afterAll hook. I think it takes longer because the --only-hash test leaves an unresolved ipfs.ls command. Would love to be able to cancel it :) * ipfs-exec/ipfs.fail should throw on a non-failing command && use random file for ipfs add --only-hash test. * fix an ipfs config test. * lint * clean: move test/http-api/extra/files.js to test/http-api/files.js
- Loading branch information
Showing
7 changed files
with
104 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* eslint-env mocha */ | ||
/* eslint max-nested-callbacks: ["error", 8] */ | ||
'use strict' | ||
|
||
const chai = require('chai') | ||
const dirtyChai = require('dirty-chai') | ||
chai.use(dirtyChai) | ||
|
||
describe('.files', () => { | ||
let ipfs = null | ||
let ipfsd = null | ||
before(function (done) { | ||
this.timeout(20 * 1000) | ||
df.spawn({ initOptions: { bits: 512 } }, (err, _ipfsd) => { | ||
expect(err).to.not.exist() | ||
ipfsd = _ipfsd | ||
ipfs = ipfsd.api | ||
done() | ||
}) | ||
}) | ||
|
||
after((done) => ipfsd.stop(done)) | ||
|
||
describe('.add', function () { | ||
it('performs a speculative add, --only-hash', () => { | ||
const content = String(Math.random()) | ||
|
||
return ipfs.add(Buffer.from(content), { onlyHash: true }) | ||
.then(files => { | ||
const getAttempt = ipfs.object.get(files[0].hash) | ||
.then(() => { | ||
throw new Error('Should not find an object for content added with --only-hash') | ||
}) | ||
|
||
return Promise.race([ | ||
getAttempt, | ||
new Promise((resolve, reject) => setTimeout(resolve, 4000)) | ||
]) | ||
}) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters