Skip to content

Commit

Permalink
Improved coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
macterra committed Dec 19, 2024
1 parent f208972 commit 1d3f578
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion tests/gatekeeper.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2613,7 +2613,7 @@ describe('checkDIDs', () => {
mockFs.restore();
});

it('should check all DIDs in db', async () => {
it('should check all DIDs', async () => {
mockFs({});

const keypair = cipher.generateRandomJwk();
Expand All @@ -2632,6 +2632,32 @@ describe('checkDIDs', () => {
expect(check.byVersion[1]).toBe(2);
});

it('should report unconfirmed DIDs', async () => {
mockFs({});

const keypair = cipher.generateRandomJwk();
const agentOp = await createAgentOp(keypair, 1, 'hyperswarm');
const agentDID = await gatekeeper.createDID(agentOp);
const assetOp = await createAssetOp(agentDID, keypair, 'hyperswarm');
const assetDID = await gatekeeper.createDID(assetOp);
const doc = await gatekeeper.resolveDID(assetDID);
doc.didDocumentData = { mock: 1 };
const updateOp = await createUpdateOp(keypair, assetDID, doc);
const ok = await gatekeeper.updateDID(updateOp);

const check = await gatekeeper.checkDIDs({ chatty: true });

expect(ok).toBe(true);
expect(check.total).toBe(2);
expect(check.confirmed).toBe(1);
expect(check.unconfirmed).toBe(1);
expect(check.ephemeral).toBe(0);
expect(check.invalid).toBe(0);
expect(check.byRegistry['hyperswarm']).toBe(2);
expect(check.byVersion[1]).toBe(1);
expect(check.byVersion[2]).toBe(1);
});

it('should report invalid DIDs', async () => {
mockFs({});

Expand Down

0 comments on commit 1d3f578

Please sign in to comment.