Skip to content

Commit

Permalink
Move createDiSuites & createSdSuites to helpers in tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
aljones15 committed Sep 22, 2024
1 parent 792fe0b commit fb060bf
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 45 deletions.
4 changes: 1 addition & 3 deletions test/50-issue.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,7 @@ function _runSuite({
verifiableCredential.proof.should.be.an('object');
should.not.exist(verifiableCredential.id, 'Expected no "vc.id".');
});
it.only('should throw an error on missing verificationMethod', async () => {
console.log('issue', suites.issue);
console.log('derive', suites.derive);
it.skip('should throw an error on missing verificationMethod', async () => {
let error;
try {
await vc.issue({
Expand Down
42 changes: 42 additions & 0 deletions test/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*/
import * as vc from '../lib/index.js';
import {CredentialIssuancePurpose} from '../lib/CredentialIssuancePurpose.js';
import {DataIntegrityProof} from '@digitalbazaar/data-integrity';
import {
documentLoader as defaultLoader
} from './testDocumentLoader.js';
Expand Down Expand Up @@ -108,3 +109,44 @@ export function createIssuerSuite({
cryptosuite: cryptosuite.createSignCryptosuite({mandatoryPointers})
});
}

export function createDiSuites({signer, cryptosuite}) {
return {
issue() {
return new DataIntegrityProof({
signer,
cryptosuite
});
},
verify() {
return new DataIntegrityProof({
cryptosuite
});
},
derive() {
throw new Error(
`cryptosuite ${cryptosuite.name} should have not derive proof`);
}
};
}

export function createSdSuites({signer, cryptosuite}) {
return {
issue({mandatoryPointers}) {
return new DataIntegrityProof({
signer,
cryptosuite: cryptosuite.createSignCryptosuite({mandatoryPointers})
});
},
verify() {
return new DataIntegrityProof({
cryptosuite: cryptosuite.createVerifyCryptosuite()
});
},
derive({selectivePointers}) {
return new DataIntegrityProof({
cryptosuite: cryptosuite.createDiscloseCryptosuite({selectivePointers})
});
}
};
}
43 changes: 1 addition & 42 deletions test/mocks/suites.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import * as EcdsaMultikey from '@digitalbazaar/ecdsa-multikey';
import * as ecdsaSd2023Cryptosuite from
'@digitalbazaar/ecdsa-sd-2023-cryptosuite';
import * as EddsaMultikey from '@digitalbazaar/ed25519-multikey';
import {createDiSuites, createSdSuites} from '../helpers.js';
import {assertionController} from './assertionController.js';
import {DataIntegrityProof} from '@digitalbazaar/data-integrity';
import {cryptosuite as ecdsaRdfc2019Cryptosuite} from
'@digitalbazaar/ecdsa-rdfc-2019-cryptosuite';
import {Ed25519Signature2018} from '@digitalbazaar/ed25519-signature-2018';
Expand Down Expand Up @@ -174,44 +174,3 @@ function registerKey({keyDoc}) {
// register the key document with documentLoader
remoteDocuments.set(keyDoc.id, keyDoc);
}

function createDiSuites({signer, cryptosuite}) {
return {
issue() {
return new DataIntegrityProof({
signer,
cryptosuite
});
},
verify() {
return new DataIntegrityProof({
cryptosuite
});
},
derive() {
throw new Error(
`cryptosuite ${cryptosuite.name} should have not derive proof`);
}
};
}

function createSdSuites({signer, cryptosuite}) {
return {
issue({mandatoryPointers}) {
return new DataIntegrityProof({
signer,
cryptosuite: cryptosuite.createSignCryptosuite({mandatoryPointers})
});
},
verify() {
return new DataIntegrityProof({
cryptosuite: cryptosuite.createVerifyCryptosuite()
});
},
derive({selectivePointers}) {
return new DataIntegrityProof({
cryptosuite: cryptosuite.createDiscloseCryptosuite({selectivePointers})
});
}
};
}

0 comments on commit fb060bf

Please sign in to comment.