Skip to content

Commit

Permalink
Create pres from cred test vector (#403)
Browse files Browse the repository at this point in the history
* new test vector

* remove comment
  • Loading branch information
nitro-neal authored Feb 15, 2024
1 parent 7a975f7 commit cf76f31
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
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

0 comments on commit cf76f31

Please sign in to comment.