-
Notifications
You must be signed in to change notification settings - Fork 300
fix(dag): ensure dag.put()
allows for optional options
#801
fix(dag): ensure dag.put()
allows for optional options
#801
Conversation
This is to align with API changes made in ipfs-inactive/interface-js-ipfs-core@011c417 and ipfs/js-ipfs#1415 License: MIT Signed-off-by: Pascal Precht <[email protected]>
dag.put()
allows for optional optionsdag.put()
allows for optional options
@alanshaw following your comment on #785 (comment), I've changed the base of this PR to your branch. If you approve, let's get this one merged there and then merge one clean PR to master. |
src/dag/put.js
Outdated
@@ -15,29 +14,35 @@ module.exports = (send) => { | |||
|
|||
return promisify((dagNode, options, callback) => { | |||
if (typeof options === 'function') { | |||
return setImmediate(() => callback(new Error('no options were passed'))) | |||
callback = options | |||
} else if (options.cid && (options.format || options.hash)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Notice that js-ipfs-api
's implementation expects options.hash
instead of options.hashAlg
. This seems to be inconsistent with the spec as per https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/DAG.md#javascript---ipfsdagputdagnode-options-callback
Changing this would be a breaking change. @alanshaw how do you feel about this?
src/dag/put.js
Outdated
} else if (options.cid && (options.format || options.hash)) { | ||
return callback(new Error('Can\'t put dag node. Please provide either `cid` OR `format` and `hash` options.')) | ||
} else if ((options.format && !options.hash) || (!options.format && options.hash)) { | ||
return callback(new Error('Can\'t put dag node. Please provide `format` AND `hash` options.')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Turns out this is a breaking change as well (which is also one of the reasons CI fails at this time) Prior to this commit, it was okay to just have format
with hash
falling back to sha2-256
.
Again, this would be a point of either introducing a breaking change and staying consistent with js-ipfs
API, or leaving as is and live with the consequences of inconsistency.
@alanshaw your call.
License: MIT Signed-off-by: Alan Shaw <[email protected]>
@PascalPrecht I pushed a fix, I hope you don't mind, this PR is now on the critical path to getting the modular interface tests merged 😉 I think the problem was that |
License: MIT Signed-off-by: Alan Shaw <[email protected]>
License: MIT Signed-off-by: Alan Shaw <[email protected]>
Sadly we can't guarantee ipfs.io will respond within 5s License: MIT Signed-off-by: Alan Shaw <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alanshaw I reviewed your changes and left a minor comment.
@@ -160,7 +160,9 @@ describe('.util', () => { | |||
.then(out => expectTimeout(ipfs.object.get(out[0].hash), 4000)) | |||
}) | |||
|
|||
it('with wrap-with-directory=true', (done) => { | |||
it('with wrap-with-directory=true', function (done) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the function
keyword is a leftover here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm using function
here because on the next time we want to call this.timeout
. Mocha provides an object with this method on it for the function context (this
) but arrow functions do not allow you to change the context.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it. Thanks for clarifying!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good! :)
dag.put()
allows for optional optionsdag.put()
allows for optional options
* feat: uses modular interface tests Reduces code repetition, allows test skipping and running only some tests. License: MIT Signed-off-by: Alan Shaw <[email protected]> * feat: skip unimplemented files tests and add ls* tests License: MIT Signed-off-by: Alan Shaw <[email protected]> * fix: adds skips for #339 License: MIT Signed-off-by: Alan Shaw <[email protected]> * fix: adds skips for key and miscellaneous License: MIT Signed-off-by: Alan Shaw <[email protected]> * feat: add types and util tests (skipped as currently failing) License: MIT Signed-off-by: Alan Shaw <[email protected]> * feat: add pin tests License: MIT Signed-off-by: Alan Shaw <[email protected]> * fix(pubsub): adds skips for tests on windows License: MIT Signed-off-by: Alan Shaw <[email protected]> * fix(config): adds skip for config.replace License: MIT Signed-off-by: Alan Shaw <[email protected]> * chore: re-adds bitswap tests License: MIT Signed-off-by: Alan Shaw <[email protected]> * chore: move detect-node back to dependencies License: MIT Signed-off-by: Alan Shaw <[email protected]> * chore: add skip reasons License: MIT Signed-off-by: Alan Shaw <[email protected]> * chore: update interface-ipfs-core dependency License: MIT Signed-off-by: Alan Shaw <[email protected]> * chore: add reason for pubsub in browser skips License: MIT Signed-off-by: Alan Shaw <[email protected]> * chore: add bitswap skips for offline errors License: MIT Signed-off-by: Alan Shaw <[email protected]> * fix: remove skip for test that was removed License: MIT Signed-off-by: Alan Shaw <[email protected]> * chore: update interface-ipfs-core version License: MIT Signed-off-by: Alan Shaw <[email protected]> * chore: update deps and test on CI (#802) * chore: update interface-ipfs-core * fix(dag): `dag.put()` allows for optional options (#801) * fix(dag): ensure `dag.put()` allows for optional options This is to align with API changes made in ipfs-inactive/interface-js-ipfs-core@011c417 and ipfs/js-ipfs#1415 License: MIT Signed-off-by: Pascal Precht <[email protected]> * fix(dag): fixes to allow options to be optional License: MIT Signed-off-by: Alan Shaw <[email protected]> * chore: update interface-ipfs-core dependency License: MIT Signed-off-by: Alan Shaw <[email protected]> * chore: update ipfsd-ctl dependency License: MIT Signed-off-by: Alan Shaw <[email protected]> * fix: increase timeout for addFromURL with wrap-with-directory Sadly we can't guarantee ipfs.io will respond within 5s License: MIT Signed-off-by: Alan Shaw <[email protected]> * fix: skip bitswap offline tests on all platforms The offline tests create and stop a node. ipfs/kubo#4078 seems to not only be restricted to windows. License: MIT Signed-off-by: Alan Shaw <[email protected]>
* feat: uses modular interface tests Reduces code repetition, allows test skipping and running only some tests. License: MIT Signed-off-by: Alan Shaw <[email protected]> * feat: skip unimplemented files tests and add ls* tests License: MIT Signed-off-by: Alan Shaw <[email protected]> * fix: adds skips for ipfs-inactive#339 License: MIT Signed-off-by: Alan Shaw <[email protected]> * fix: adds skips for key and miscellaneous License: MIT Signed-off-by: Alan Shaw <[email protected]> * feat: add types and util tests (skipped as currently failing) License: MIT Signed-off-by: Alan Shaw <[email protected]> * feat: add pin tests License: MIT Signed-off-by: Alan Shaw <[email protected]> * fix(pubsub): adds skips for tests on windows License: MIT Signed-off-by: Alan Shaw <[email protected]> * fix(config): adds skip for config.replace License: MIT Signed-off-by: Alan Shaw <[email protected]> * chore: re-adds bitswap tests License: MIT Signed-off-by: Alan Shaw <[email protected]> * chore: move detect-node back to dependencies License: MIT Signed-off-by: Alan Shaw <[email protected]> * chore: add skip reasons License: MIT Signed-off-by: Alan Shaw <[email protected]> * chore: update interface-ipfs-core dependency License: MIT Signed-off-by: Alan Shaw <[email protected]> * chore: add reason for pubsub in browser skips License: MIT Signed-off-by: Alan Shaw <[email protected]> * chore: add bitswap skips for offline errors License: MIT Signed-off-by: Alan Shaw <[email protected]> * fix: remove skip for test that was removed License: MIT Signed-off-by: Alan Shaw <[email protected]> * chore: update interface-ipfs-core version License: MIT Signed-off-by: Alan Shaw <[email protected]> * chore: update deps and test on CI (ipfs-inactive#802) * chore: update interface-ipfs-core * fix(dag): `dag.put()` allows for optional options (ipfs-inactive#801) * fix(dag): ensure `dag.put()` allows for optional options This is to align with API changes made in ipfs-inactive/interface-js-ipfs-core@011c417 and ipfs/js-ipfs#1415 License: MIT Signed-off-by: Pascal Precht <[email protected]> * fix(dag): fixes to allow options to be optional License: MIT Signed-off-by: Alan Shaw <[email protected]> * chore: update interface-ipfs-core dependency License: MIT Signed-off-by: Alan Shaw <[email protected]> * chore: update ipfsd-ctl dependency License: MIT Signed-off-by: Alan Shaw <[email protected]> * fix: increase timeout for addFromURL with wrap-with-directory Sadly we can't guarantee ipfs.io will respond within 5s License: MIT Signed-off-by: Alan Shaw <[email protected]> * fix: skip bitswap offline tests on all platforms The offline tests create and stop a node. ipfs/kubo#4078 seems to not only be restricted to windows. License: MIT Signed-off-by: Alan Shaw <[email protected]>
Note: Only review last commit as it's rebased on top of #785 to make test runner work
This is to align with API changes in
ipfs-inactive/interface-js-ipfs-core@011c417
and
ipfs/js-ipfs#1415
Temporarily rebased on top of #785
Note: this is a WIP as I have to run now :D will make tests green once I'm back