Skip to content

Commit

Permalink
Also test embedded
Browse files Browse the repository at this point in the history
  • Loading branch information
cykoder committed May 1, 2024
1 parent 2ca44a7 commit 3152edc
Showing 1 changed file with 43 additions and 11 deletions.
54 changes: 43 additions & 11 deletions tests/integration/anoncreds/issuing.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,34 +239,66 @@ describe.each(Schemes)('Issuance', ({
}, 30000);

test(`Can issue+verify a ${Name} credential with blank schema and custom parsingOptions`, async () => {
const parsingOptions = {
...DefaultSchemaParsingOpts,
defaultDecimalPlaces: 5,
useDefaults: true,
};

const issuerKey = getKeyDoc(did1, keypair, keypair.type, keypair.id);
const unsignedCred = {
...credentialJSON,
issuer: did1,
};
delete unsignedCred.credentialSchema;

unsignedCred.credentialSchema = {
id: '',
type: 'JsonSchemaValidator2018',
parsingOptions: {
...DefaultSchemaParsingOpts,
defaultDecimalPlaces: 4,
useDefaults: true,
},
parsingOptions,
};

const credential = await issueCredential(issuerKey, unsignedCred);

// Ensure schema was now defined, added by crypto-wasm-ts
expect(credential.credentialSchema).toBeDefined();
expect(credential.credentialSchema).toMatchObject({
parsingOptions: {
useDefaults: true,
defaultMinimumInteger: -4294967295,
defaultMinimumDate: -17592186044415,
defaultDecimalPlaces: 4,
parsingOptions,
version: CredentialSchema.VERSION,
});

const result = await verifyCredential(credential, { resolver });
expect(result).toMatchObject(
expect.objectContaining(getProofMatcherDoc()),
);
}, 30000);

test(`Can issue+verify a ${Name} credential with embedded schema and custom parsingOptions`, async () => {
const parsingOptions = {
...DefaultSchemaParsingOpts,
defaultDecimalPlaces: 5,
useDefaults: true,
};

const issuerKey = getKeyDoc(did1, keypair, keypair.type, keypair.id);
const unsignedCred = {
...credentialJSON,
credentialSchema: {
id: credentialJSON.credentialSchema.id,
type: 'JsonSchemaValidator2018',
parsingOptions,
},
issuer: did1,
};

expect(unsignedCred.credentialSchema.id).toBeDefined();
expect(unsignedCred.credentialSchema.id).not.toEqual('');

const credential = await issueCredential(issuerKey, unsignedCred);

// Ensure schema was now defined, added by crypto-wasm-ts
expect(credential.credentialSchema).toBeDefined();
expect(credential.credentialSchema).toMatchObject({
parsingOptions,
version: CredentialSchema.VERSION,
});

Expand Down

0 comments on commit 3152edc

Please sign in to comment.