import { STATUS_LIST } from '../../../src/config.js'; import { RevocationStatusList } from '../../../src/statusList/revocationStatusList.js'; import { RevocationStatusListArray } from '../../../src/statusList/revocationStatusListArray.js'; describe('RevocationStatusList should', () => { it('revoke a credential', () => { const encodedList = 'H4sIAAAAAAAAE+3BMQEAAADCoPVPbQwfoAAAAAAAAAAAAAAAAAAAAIC3AYbSVKsAQAAA'; const revocationStatusList: RevocationStatusList = RevocationStatusListArray.fromEncoded(encodedList); revocationStatusList.revokeCredential(1); expect(revocationStatusList.isRevoked(1)).toBeTruthy(); expect(encodedList).not.toBe(revocationStatusList.encoded()); }); it('decode an EncodedList with a credential revoked', () => { const encodedList = 'H4sIAAAAAAAAE+3BIQEAAAACIKf5f5UzLEAaAAAAAAAAAAAAAAAAAAAA4GxcqaqmAEAAAA=='; const revocationStatusList: RevocationStatusList = RevocationStatusListArray.fromEncoded(encodedList); const expectedRevocationStatusList = new RevocationStatusListArray(); expect(revocationStatusList.isRevoked(9)).toBeTruthy(); }); it('raise an Error when the credentialId to revoke is not valid', () => { const expectedRevocationStatusList = new RevocationStatusListArray(); expect(() => expectedRevocationStatusList.revokeCredential( STATUS_LIST.MAX_CREDENTIAL_ID + 1, ), ).toThrow(Error); expect(() => expectedRevocationStatusList.revokeCredential(-1)).toThrow( Error, ); }); });