diff --git a/tests/10-issue.js b/tests/10-issue.js index c23a7f4..74f5a1e 100644 --- a/tests/10-issue.js +++ b/tests/10-issue.js @@ -1,9 +1,9 @@ /*! * Copyright (c) 2022-2023 Digital Bazaar, Inc. All rights reserved. */ -import * as sl from '@digitalbazaar/vc-status-list'; +// import * as sl from '@digitalbazaar/vc-status-list'; import chai, {assert} from 'chai'; -import {getSlc, issueVc, decodeSl} from './helpers.js'; +import {decodeSl, getSlc, issueVc} from './helpers.js'; import {testCredential, testSlCredential} from './assertions.js'; import {filterByTag} from 'vc-test-suite-implementations'; @@ -434,11 +434,7 @@ describe('Issuers - BitstringStatusList', const credentialSubject = statusListCredential.credentialSubject; const {encodedList} = credentialSubject; - await sl.decodeList({encodedList}); - encodedList[0].should.equal('u', - 'Expected encodedList to be a Multibase-encoded ' + - 'base64url value.' - ); + await decodeSl({encodedList}); } } ); @@ -446,12 +442,10 @@ describe('Issuers - BitstringStatusList', async function() { this.test.link = 'https://www.w3.org/TR/vc-bitstring-status-list/#:~:text=The%20uncompressed%20bitstring%20MUST%20be%20at%20least%2016KB%20in%20size.'; for(statusListCredential of statusListCredentials) { - const credentialSubject = - statusListCredential.credentialSubject; - const {encodedList} = credentialSubject; - const decoded = await sl.decodeList({encodedList}); + const {encodedList} = statusListCredential.credentialSubject; + const decoded = await decodeSl({encodedList}); // decoded size should be 16kb - const decodedSize = (decoded.length / 8) / 1024; + const decodedSize = (decoded.length / 100); decodedSize.should.be.gte(16, 'Expected bitstring to be at least 16KB in size.' ); @@ -469,17 +463,15 @@ describe('Issuers - BitstringStatusList', this.test.cell.skipMessage = 'Test needs to be validated.'; this.skip(); for(statusListCredential of statusListCredentials) { - const credentialSubject = - statusListCredential.credentialSubject; - const {encodedList} = credentialSubject; - const decoded = await sl.decodeList({encodedList}); - decoded.bitstring.bits[0].should.be.equal(0, + const {encodedList} = statusListCredential.credentialSubject; + const decoded = await decodeSl({encodedList}); + decoded[0].should.be.equal(0, 'Expected the first index of the statusList to have ' + 'the value 0.' ); - decoded.bitstring.bits[ - decoded.bitstring.bits.length - 1].should.be.equal( - decoded.bitstring.bits.length - 1, + decoded[ + decoded.length - 1].should.be.equal( + decoded.length - 1, 'Expected the last index of the statusList to have ' + 'the value of the bitstring length minus 1.' ); diff --git a/tests/helpers.js b/tests/helpers.js index 7c69c1b..dde5710 100644 --- a/tests/helpers.js +++ b/tests/helpers.js @@ -1,7 +1,8 @@ /*! * Copyright (c) 2022-2023 Digital Bazaar, Inc. All rights reserved. */ -import * as sl from '@digitalbazaar/vc-status-list'; +import * as base64url from 'base64url-universal'; +// import * as sl from '@digitalbazaar/vc-status-list'; import chai from 'chai'; import {createRequire} from 'node:module'; import {decodeList} from '@digitalbazaar/vc-status-list'; @@ -9,6 +10,7 @@ import {documentLoader} from './documentLoader.js'; import {httpClient} from '@digitalbazaar/http-client'; import https from 'https'; import {klona} from 'klona'; +import {ungzip} from 'pako'; import {v4 as uuidv4} from 'uuid'; const require = createRequire(import.meta.url); const validVc = require('./validVc.json'); @@ -107,15 +109,16 @@ export async function updateStatus({ return vc; } -export async function decodeSl({ - encodedList -}) { +export async function decodeSl({encodedList}) { + encodedList[0].should.equal('u', + 'Expected encodedList to be a Multibase-encoded ' + + 'base64url value.' + ); let decoded; let error; - console.log(encodedList); try { // Uncompress encodedList - decoded = await sl.decodedList({encodedList}); + decoded = ungzip(base64url.decode(encodedList.substring(1))); } catch(e) { error = e; }