From cf76f31a5efc6a6a67e1619219952969a0e72b47 Mon Sep 17 00:00:00 2001 From: nitro-neal <5314059+nitro-neal@users.noreply.github.com> Date: Thu, 15 Feb 2024 07:49:31 -0600 Subject: [PATCH] Create pres from cred test vector (#403) * new test vector * remove comment --- .../tests/presentation-exchange.spec.ts | 17 +++++++++++++++++ web5-spec | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/packages/credentials/tests/presentation-exchange.spec.ts b/packages/credentials/tests/presentation-exchange.spec.ts index 8a6ee05fb..610b7a4fb 100644 --- a/packages/credentials/tests/presentation-exchange.spec.ts +++ b/packages/credentials/tests/presentation-exchange.spec.ts @@ -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 { @@ -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 { diff --git a/web5-spec b/web5-spec index f46b53f34..bdabc55a7 160000 --- a/web5-spec +++ b/web5-spec @@ -1 +1 @@ -Subproject commit f46b53f34f6ecd6ff2e16e93d67890fa63528424 +Subproject commit bdabc55a7cad4b469855706f0ab4167d3755756d