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

An example to follow would be really nice #14

Closed
brentzundel opened this issue Apr 26, 2019 · 8 comments
Closed

An example to follow would be really nice #14

brentzundel opened this issue Apr 26, 2019 · 8 comments
Assignees

Comments

@brentzundel
Copy link
Member

A VC implementation may successfully create conforming credentials, but how that implementation should interact with the test suite to prove itself is unclear.
The test suite could use better documentation (what precisely will be passed to the implementation by the test suite, what is the test suite expecting as output from the implementation, etc. ?)
A simple working example would also be very helpful.

@dmitrizagidulin
Copy link
Collaborator

Hey @brentzundel - copy that.
I've gotten the vc-js lib to pass this test suite, so maybe I can include an example of how to run it, etc?

@brentzundel
Copy link
Member Author

That would be exceptionally useful. E.g., the extent of the instructions for the config.json file are to "modify it," so seeing an example of how such a thing ought to be done would be really great.

@dmitrizagidulin
Copy link
Collaborator

dmitrizagidulin commented Apr 30, 2019

@brentzundel Ok, so the general idea is this.

Essentially, the test suite says "I'm going to pass you this JSON credential, have you sign it or whatever (turn it into a VC), and then I'll check for two things: 1) you didn't mangle it, and 2) your lib throws errors when something is non-compliant with the data model."

The test suite invokes a given library on a bunch of input credentials (all the json-ld files in /test/vc-data-model-1.0/input).
It does it through util.generate(), by shelling out to exec().
And then uses the output (which should be now be a verifiable credential, as a result of invocation) in the various tests.

But here's basically what you have to do to hook up any VC library to this test suite.
Assumptions:

a. You have some sort of executable that can accept as stdin input a JSON file (the credential that's going to be made verifiable), and call whatever appropriate issue() function your lib and language supports.
b. Your executable can handle the key generation part (this test suite does not provide any keys as input).

For example, for vc-js, I modified the config file in the following manner:

{
  "generator": "../vc-js/bin/vc-js test-issue < ",
  "presentationGenerator": "../vc-js/bin/vc-js test-presentation <",

  "generatorOptions": ""
}

The generator parameter is what gets exec'd on each input json file. So, for example, when a mocha test says const doc = generate('example-1.json'), this is what gets invoked:

../vc-js/bin/vc-js test-issue < example-1.json 

The ../vc-js/bin/vc-js part of this just refers to the fact that I had git cloned the vc-js lib one directory up, and it invokes the vc-js script that happens to be in the bin/ folder of that repo.

The test-issue command in that script parses the input file, and invokes issue() on it (using a test signing key pair -- though you can pass your external signing keys via generatorOptions if you prefer).

Does this help?

@brentzundel
Copy link
Member Author

I think this will help. I think it would be good to move these instructions to the readme, where we can continue to add clarification as more questions arise.

@dmitrizagidulin
Copy link
Collaborator

Sounds good, will be moving this to the README.

@dmitrizagidulin
Copy link
Collaborator

Next steps: @dmitrizagidulin to move remaining text from issue comments to README this week.

@dmitrizagidulin
Copy link
Collaborator

Addressed in PR #68.

@LuisOsta
Copy link

@dmitrizagidulin The link above no longer works, do you know where I could go to see a reference implementation of this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants