Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix equality check #216

Closed
wants to merge 3 commits into from
Closed

Fix equality check #216

wants to merge 3 commits into from

Conversation

Gozala
Copy link
Contributor

@Gozala Gozala commented Oct 17, 2022

Fixes #208

I've looked into the issue and turns out it can only occur on CIDv0, because CIDv1 always seem to re-encode (which I think is a bug btw)

: CID.createV1(specs.codec, digest)

js-multiformats/src/cid.js

Lines 287 to 289 in 0ec751a

case 1: {
const bytes = encodeCID(version, code, digest.bytes)
return new CID(version, code, digest, bytes)

Never the less this turns byteOffset and byteLength to getters so they won't be considered in equality checks.

I also had to add check digest.bytes instance Uint8Array check otherwise some tests passing garbage data were no longer throwing on construction.

Copy link
Collaborator

@RangerMauve RangerMauve left a comment

Choose a reason for hiding this comment

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

@Gozala
Copy link
Contributor Author

Gozala commented Oct 17, 2022

Closing this in favor of #215

@Gozala Gozala closed this Oct 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CID equality
2 participants