fix(test): rootless fixture should have no roots, not null roots #293
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I was trying to use this as a fixture and it's causing a bit of a problem. What we want this fixture to test is that the
version
or42
, so the error isinvalid car version: 42
. But, because it's got a Nullroots
it violates the schema in a novel way. The schemas for CARv1 headers dictate that theroots
field is strictly necessary, and notnullable
, but for the CARv2 pragma, we remove it entirely. So this effectively makes the initial bytes schema something like:So it serves both the CARv2 pragma, and the CARv1 header proper.
But this fixture would make it:
Which introduces additional awkwardness.
So I'd like to hand-wave this problem away entirely.
I'll also note here that it's a bit too easy at the moment to write a CARv1 with a Null in this position,
WriteCar()
and friends, andReplaceRootsInFile()
in CARv2 just pass theroots
value on tocbor.DumpObject()
which doesn't care about these nuances, it'll write anil
as a Null. I'm thinking that maybe we should switch from go-ipld-cbor to bindnode and assert a strict schema for the header to make this go away. The alternative is to add anullable
to the CARv1 spec (I started a PR to do this but then thought that maybe it'd be better to sweep this fixture under the carpet and defer this problem till later).