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

fix(core/components/dag): fix default hash algorithm for put() api #1419

Merged
merged 1 commit into from
Jul 4, 2018

Conversation

0x-r4bbit
Copy link
Contributor

Turns out we've introduced a little bug in d299ed7
in which the default hash algorithm has a typo.

This didn't fail on CI because the options.hashAlg passed down to ipld.put()
is actually not being used at time of this commit.

For more info see: https://github.com/ipld/js-ipld/blob/d3d78e053ebd3f8c85a8b5579715be8812773d4d/src/index.js#L236-L239

License: MIT
Signed-off-by: Pascal Precht [email protected]

Turns out we've introduced a little bug in ipfs@d299ed7
in which the default hash algorithm has a typo.

This didn't fail on CI because the `options.hashAlg` passed down to `ipld.put()`
is actually not being used at time of this commit.

For more info see: https://github.com/ipld/js-ipld/blob/d3d78e053ebd3f8c85a8b5579715be8812773d4d/src/index.js#L236-L239

License: MIT
Signed-off-by: Pascal Precht <[email protected]>
@0x-r4bbit
Copy link
Contributor Author

@alanshaw sorry this one slipped through 🙇🏻‍♂️

@alanshaw
Copy link
Member

alanshaw commented Jul 4, 2018

Good catch, thank you 🚀 . Would you be willing to add a test to interface-ipfs-core for using a hash algorithm other than the default? We'd need to skip it here until ipld/js-ipld#133 is merged and released.

@alanshaw alanshaw merged commit 1a36375 into ipfs:master Jul 4, 2018
@0x-r4bbit 0x-r4bbit deleted the fix/dag-put-defaults branch July 4, 2018 10:45
@0x-r4bbit
Copy link
Contributor Author

I can certainly do that. But just to clarify: You want a test that simply checks whether a non-default hashAlg is used?

Cause that's kind of covered in the existing tests: https://github.com/ipfs/interface-ipfs-core/blob/master/js/src/dag/put.js#L55-L81

Although, those don't really check if the resulting CID resolves to the configured hash algorithm.

Maybe it makes sense to change those to look more like the one here? https://github.com/ipfs/interface-ipfs-core/blob/master/js/src/dag/put.js#L103-L110

Otherwise I can also just add a new one that checks on the resolved CID similar to the one above.

0x-r4bbit added a commit to 0x-r4bbit/interface-ipfs-core that referenced this pull request Jul 4, 2018
As discussed in ipfs/js-ipfs#1419 (comment)
at the time of this commit, `dag.put()` basically ignores the `hashAlg`
option, as it passes it down to `ipld.put()`, which won't honor it until
ipld/js-ipld#133 is merged.

Once ipld/js-ipld#133 is merged, this test verifies
that e.g.

```
dag.put(cborNode, {
  format: 'dag-cbor',
  hashAlg: 'sha3-512'
}, (err, cid) => {
  ...
})
```

Actually results in a `CID` instance that decodes to `sha3-512` and not
the `sha2-256` default.

License: MIT
Signed-off-by: Pascal Precht [email protected]
0x-r4bbit added a commit to 0x-r4bbit/interface-ipfs-core that referenced this pull request Jul 4, 2018
As discussed in ipfs/js-ipfs#1419 (comment)
at the time of this commit, `dag.put()` basically ignores the `hashAlg`
option, as it passes it down to `ipld.put()`, which won't honor it until
ipld/js-ipld#133 is merged.

Once ipld/js-ipld#133 is merged, this test verifies
that e.g.

```
dag.put(cborNode, {
  format: 'dag-cbor',
  hashAlg: 'sha3-512'
}, (err, cid) => {
  ...
})
```

Actually results in a `CID` instance that decodes to `sha3-512` and not
the `sha2-256` default.

License: MIT
Signed-off-by: Pascal Precht [email protected]
alanshaw pushed a commit to ipfs-inactive/interface-js-ipfs-core that referenced this pull request Jul 5, 2018
As discussed in ipfs/js-ipfs#1419 (comment)
at the time of this commit, `dag.put()` basically ignores the `hashAlg`
option, as it passes it down to `ipld.put()`, which won't honor it until
ipld/js-ipld#133 is merged.

Once ipld/js-ipld#133 is merged, this test verifies
that e.g.

```
dag.put(cborNode, {
  format: 'dag-cbor',
  hashAlg: 'sha3-512'
}, (err, cid) => {
  ...
})
```

Actually results in a `CID` instance that decodes to `sha3-512` and not
the `sha2-256` default.

License: MIT
Signed-off-by: Pascal Precht [email protected]
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants