Skip to content

Commit

Permalink
fix: get identifier metadata exist
Browse files Browse the repository at this point in the history
  • Loading branch information
Sotatek-BaoHoanga committed Dec 13, 2024
1 parent cecdcef commit 549553a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
7 changes: 5 additions & 2 deletions src/core/agent/services/identifierService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -404,9 +404,9 @@ describe("Single sig service of agent", () => {
eventEmitter.emit = jest.fn();
getIdentifiersMock.mockResolvedValue(identifierStateKeria);
findOperationMock.mockResolvedValueOnce(null);
identifierStorage.getIdentifierMetadata = jest
identifierStorage.getAllIdentifierMetadata = jest
.fn()
.mockResolvedValueOnce(undefined);
.mockResolvedValue([]);
createIdentifierMock.mockResolvedValue({
serder: {
ked: {
Expand Down Expand Up @@ -480,6 +480,9 @@ describe("Single sig service of agent", () => {
const displayName = "newDisplayName";
eventEmitter.emit = jest.fn();
getIdentifiersMock.mockResolvedValue(identifierStateKeria);
identifierStorage.getAllIdentifierMetadata = jest
.fn()
.mockResolvedValue([]);
const existRecord = new BasicRecord({
id: MiscRecordId.IDENTIFIERS_PENDING_CREATION,
content: {
Expand Down
5 changes: 3 additions & 2 deletions src/core/agent/services/identifierService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,9 @@ class IdentifierService extends AgentService {
}

const isPending = true;
const identifierMetadataRecord =
await this.identifierStorage.getIdentifierMetadata(identifier);
const identifierMetadataRecord = (
await this.identifierStorage.getAllIdentifierMetadata()
).some((record) => record.id === identifier);
if (!(backgroundTask && identifierMetadataRecord)) {
await this.identifierStorage.createIdentifierMetadataRecord({
id: identifier,
Expand Down

0 comments on commit 549553a

Please sign in to comment.