Skip to content

Commit

Permalink
Add filterVerifiers for DI verifier tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
aljones15 committed Jun 7, 2024
1 parent cff9e9a commit 918d784
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
9 changes: 4 additions & 5 deletions tests/15-di-bbs-verify.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,19 @@ import {
checkDataIntegrityProofVerifyErrors
} from 'data-integrity-test-suite-assertion';
import {endpoints} from 'vc-test-suite-implementations';
import {filterVerifiers} from './helpers.js';
import {getMultiKey} from './vc-generator/key-gen.js';
import {getSuiteConfig} from './test-config.js';

const tag = 'bbs-2023';
const {tags, credentials, vectors} = getSuiteConfig(tag);
// only use implementations with `bbs-2023` verifiers.
const {match} = endpoints.filterByTag({
tags: [...tags],
property: 'verifiers'
});
const key = await getMultiKey({keyType: 'P-381'});
const {subjectNestedObjects} = credentials.verify;

for(const vcVersion of vectors.vcTypes) {
const {match} = endpoints.filter({
filter: filterVerifiers.bind({vcVersion, tags})
});
checkDataIntegrityProofVerifyErrors({
implemented: match,
testDescription: `Data Integrity (bbs-2023 verifiers) VC ${vcVersion}`,
Expand Down
19 changes: 19 additions & 0 deletions tests/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,25 @@ export const supportsVc = ({vcVersion, endpoint}) => {
return supports.vc.includes(vcVersion);
};

/**
* Filters Verifiers for the Data Integrity Verifier tests.
* Needs to have tags and vcVersion binded to it.
*
* @param {object} options - Options to use.
* @param {object} options.implementation - An impelementation.
*
* @returns {Array<object>} Filtered endpoints.
*/
export function filterVerifiers({implementation}) {
const endpoints = implementation.verifiers;
return endpoints.filter(endpoint => {
if(this.tags.every(tag => endpoint.tags.has(tag))) {
return supportsVc({vcVersion: this.vcVersion, endpoint});
}
return false;
});
}

export const createInitialVc = async ({
issuer,
vc,
Expand Down

0 comments on commit 918d784

Please sign in to comment.