Skip to content

Commit

Permalink
use logger, update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
LiranCohen committed Oct 11, 2024
1 parent 96e25b2 commit 0bdb0e1
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/agent/src/agent-did-resolver-cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export class AgentDidResolverCache extends DidResolverCacheLevel implements DidR
} catch(error: any) {
// if the error is not due to no changes detected, log the error
if (error.message && !error.message.includes('No changes detected, update aborted')) {
console.error(`Error updating DID: ${error.message}`);
logger.error(`Error updating DID: ${error.message}`);
}
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/agent/src/local-key-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,7 @@ export class LocalKeyManager implements AgentKeyManager {
// Compute the key URI for the key.
const keyUri = await this.getKeyUri({ key: privateKey });

// Store the key in the key store.
await this._keyStore.set({
id : keyUri,
data : privateKey,
Expand Down
7 changes: 3 additions & 4 deletions packages/agent/tests/agent-did-resolver-cach.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { TestAgent } from './utils/test-agent.js';
import sinon from 'sinon';
import { expect } from 'chai';
import { BearerDid, DidJwk } from '@web5/dids';
import { BearerIdentity } from '../src/bearer-identity.js';

describe('AgentDidResolverCache', () => {
let resolverCache: AgentDidResolverCache;
Expand Down Expand Up @@ -81,7 +80,7 @@ describe('AgentDidResolverCache', () => {

const getStub = sinon.stub(resolverCache['cache'], 'get').resolves(JSON.stringify({ ttlMillis: Date.now() - 1000, value: { didDocument: { id: did.uri } } }));
const resolveSpy = sinon.spy(testHarness.agent.did, 'resolve').withArgs(did.uri);
const nextTickSpy = sinon.stub(resolverCache['cache'], 'nextTick').resolves();
sinon.stub(resolverCache['cache'], 'nextTick').resolves();
const didApiStub = sinon.stub(testHarness.agent.did, 'get');
const updateSpy = sinon.stub(testHarness.agent.did, 'update').resolves();
didApiStub.withArgs({ didUri: did.uri, tenant: testHarness.agent.agentDid.uri }).resolves(new BearerDid({
Expand All @@ -104,7 +103,7 @@ describe('AgentDidResolverCache', () => {

const getStub = sinon.stub(resolverCache['cache'], 'get').resolves(JSON.stringify({ ttlMillis: Date.now() - 1000, value: { didDocument: { id: did.uri } } }));
const resolveSpy = sinon.spy(testHarness.agent.did, 'resolve').withArgs(did.uri);
const nextTickSpy = sinon.stub(resolverCache['cache'], 'nextTick').resolves();
sinon.stub(resolverCache['cache'], 'nextTick').resolves();
const didApiStub = sinon.stub(testHarness.agent.did, 'get');
const updateSpy = sinon.stub(testHarness.agent.did, 'update').rejects(new Error('Some Error'));
const consoleErrorSpy = sinon.stub(console, 'error');
Expand Down Expand Up @@ -137,7 +136,7 @@ describe('AgentDidResolverCache', () => {

it('throws if the error is anything other than a notFound error', async () => {
const did = testHarness.agent.agentDid.uri;
const getStub = sinon.stub(resolverCache['cache'], 'get').rejects(new Error('Some Error'));
sinon.stub(resolverCache['cache'], 'get').rejects(new Error('Some Error'));

try {
await resolverCache.get(did);
Expand Down

0 comments on commit 0bdb0e1

Please sign in to comment.