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

Create pres from cred test vector #403

Merged
merged 2 commits into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions packages/credentials/tests/presentation-exchange.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type { Validated, PresentationDefinitionV2 } from '../src/presentation-ex
import { VerifiableCredential } from '../src/verifiable-credential.js';
import { PresentationExchange } from '../src/presentation-exchange.js';
import PresentationExchangeSelectCredentialsTestVector from '../../../web5-spec/test-vectors/presentation_exchange/select_credentials.json' assert { type: 'json' };
import PresentationExchangeCreatePresentationFromCredentialsTestVector from '../../../web5-spec/test-vectors/presentation_exchange/create_presentation_from_credentials.json' assert { type: 'json' };


class BitcoinCredential {
Expand Down Expand Up @@ -252,6 +253,22 @@ describe('PresentationExchange', () => {
}
});
});

describe('Web5TestVectorsPresentationExchange', () => {
it('create_presentation_from_credentials', async () => {
const vectors = PresentationExchangeCreatePresentationFromCredentialsTestVector.vectors;

for (let i = 0; i < vectors.length; i++) {
const input = vectors[i].input;
const expectedOutput = vectors[i].output.presentationSubmission;

const presentation = PresentationExchange.createPresentationFromCredentials({ vcJwts: input.credentialJwts, presentationDefinition: input.presentationDefinition});

expect(presentation.presentationSubmission.definition_id).to.deep.equals(expectedOutput.definition_id);
expect(presentation.presentationSubmission.descriptor_map).to.deep.equals(expectedOutput.descriptor_map);
}
});
});
});

function createPresentationDefinition(): PresentationDefinitionV2 {
Expand Down
2 changes: 1 addition & 1 deletion web5-spec
Loading