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

Host web5 vectors example #66

Merged
merged 28 commits into from
Nov 21, 2023
Merged

Host web5 vectors example #66

merged 28 commits into from
Nov 21, 2023

Conversation

phoebe-lew
Copy link
Contributor

@phoebe-lew phoebe-lew commented Nov 20, 2023

closes #62

.github/workflows/publish-vectors-pages.yaml Outdated Show resolved Hide resolved
web5-test-vectors/vector-structure.json Outdated Show resolved Hide resolved
web5-test-vectors/vector-structure.json Outdated Show resolved Hide resolved
web5-test-vectors/vector-structure.json Outdated Show resolved Hide resolved
web5-test-vectors/vector-structure.json Outdated Show resolved Hide resolved
@mistermoe
Copy link
Member

@phoebe-lew mind if i add a did:jwk vector for an invalid did?

scripts/test-vector-validation/README.md Show resolved Hide resolved
"errors": {
"type": "boolean",
"default": false,
"description": "Indicates whether the test vector is expected to produce an error. Defaults to false if not present."
Copy link
Contributor

Choose a reason for hiding this comment

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

It's unclear to me how errors is meant to work still. Specifically,

  • when errors is true, what does the value of output do?
  • what do errors translate to in each implementation?

My suggestion is to remove the errors field. Output can encode that an error is expected.

Copy link
Member

Choose a reason for hiding this comment

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

when errors is true, what does the value of output do?

you can omit output entirely if errors is true. that's why neither is a required field. if output is present, you can omit errors

what do errors translate to in each implementation?

nothing is prescribed here. errors: true effectively means the code in question should return or throw an error/exception.

general reason for keeping this here is to account for functions that don't return anything on success or throw exceptions

My suggestion is to remove the errors field. Output can encode that an error is expected.

can you provide a concrete example? we're looking to avoid magic strings that mean specific things as much as possible

Copy link
Contributor

Choose a reason for hiding this comment

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

I was thinking of something along the lines of

{
  "output": {
    "type": "error",
    "message": "my expected error message"
  }
}

Regarding

we're looking to avoid magic strings that mean specific things as much as possible

Can you share the motivation? My first instinct is that "error" is already having a specific meaning. Is the line at the top level?

Having a Boolean field can be too vague to be useful in tests. Implementations may easily return a different type of error than what was intended, so I believe it's important to allow that flexibility so implementations can check error messaging.

If we decide that the current schema is the way to go, then I would suggest enforcing that only one of errors, output, can be populated, but not both. This can be done with a oneOf.

Copy link
Member

Choose a reason for hiding this comment

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

Can you share the motivation? My first instinct is that "error" is already having a specific meaning. Is the line at the top level?

was careful to say "avoid magic strings as much as possible" vs. at all because, like you said, the property names themselves are "magic". so more generally, just aiming to limit the use of them as much as possible regardless of level.

having a "type" provides quite a bit of flexibility, which, i'm not sure we necessarily need. could end up with an explosion of custom "types" when it doesn't seem needed (at least imo). doesn't feel like we need to go further than supporting:

  • the function works and returns something that should match output
  • the function throws an error (in whatever way the consuming language represents errors)
    • optionally, the error's output should match output

errors: true effectively means: expect an error in the consuming language.

  • so in kotlin or js, whenever errors: true, an assertThrows would be added.
  • in go i suppose you'd expect err to not be nil.
  • in Rust, you'd want the match to occur on Result.Err instead of Result.Ok. it's intentionally vague so as not to be too prescriptive for any given implementation.
  • I tried to provide a COBOL example but Chad made it apparent that COBOL tests are entirely separate programs that have to be written to run on mainframes.

If we decide that the current schema is the way to go, then I would suggest enforcing that only one of errors, output, can be populated, but not both. This can be done with a oneOf.

If we decide that the current schema is the way to go, then I would suggest enforcing that only one of errors, output, can be populated, but not both. This can be done with a oneOf.

i considered this as well initially, but decided not to make them mutually exclusive in order to provide the optionality of using output for error messages if desired

Copy link
Contributor

Choose a reason for hiding this comment

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

This all makes sense to me. Thanks for elaborating.

I would only add that the way to use error and output should be documented in the description field. Specifically the stuff we've talked about in this thread: "when errors is set to true, the output field can be used for further validation. For example, when doing error message validation."

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

@mistermoe mistermoe left a comment

Choose a reason for hiding this comment

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

🏅 excited about this

@phoebe-lew phoebe-lew merged commit c7c1f35 into main Nov 21, 2023
6 of 7 checks passed
@phoebe-lew phoebe-lew deleted the plew.host-web5-vectors branch November 21, 2023 09:23
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.

Decide how test vectors workflow will work
5 participants