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

Implement tooling to document hardcoded CIDs #112

Open
laurentsenta opened this issue Jul 26, 2023 · 1 comment
Open

Implement tooling to document hardcoded CIDs #112

laurentsenta opened this issue Jul 26, 2023 · 1 comment

Comments

@laurentsenta
Copy link
Contributor

See the changes in #87

We used fixtures + libraries to generate expectation values (like an expected payload or an expected CIDs)
But in some (most?) cases, this relies on the fact that the library itself is correct.

Take a test that verifies the ordering of blocks in a CAR produced by a gateway, if we use go-ipld-xyz to load the car and generate the array of blocks, then we test against the library, not against the spec.

The other option is to hardcode results (like arrays of CIDs) which is okay up to a point where we have dozens of long lists of random strings and one test breaks or we have to update it.

Ideally we'd have some way to describe CIDs & other payloads like documentation and load these in the code, similar to how we do DNS link configurations.

@lidel
Copy link
Member

lidel commented Jan 23, 2024

I've been thinking about this today while looking at #190 and if we modify utility helpers MustGetCid, MustGetCidWithCodec, MustGetDescendantsCids to take expected CIDs as argument, we have bidirectional verification of the test harness:

  • Hardcoded CIDs will make test cases explicit rather than implicit.
  • We keep the perk of programmatically loading fixtures AND we detect when the content of a fixture changes – CIDs will no longer match.

This will catch both software errors (CAR fixture parser library bugs) and human ones (someone swapping fixture file with something that has different CIDs).

For rare cases when we have a lot CIDs or not care about having exact blocks, we could have helpers which do not require explicit CID in argument.

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

No branches or pull requests

2 participants