From 39f09c263d7863ced2f99e8e2a3e4f90d10d87fe Mon Sep 17 00:00:00 2001 From: iFergal Date: Fri, 13 Dec 2024 10:07:54 -0300 Subject: [PATCH] feat(core): expose witness set function to UI --- .../agent/services/identifierService.test.ts | 21 +++++++++++++++++++ src/core/agent/services/identifierService.ts | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/core/agent/services/identifierService.test.ts b/src/core/agent/services/identifierService.test.ts index 154e26045..aeeafc4f3 100644 --- a/src/core/agent/services/identifierService.test.ts +++ b/src/core/agent/services/identifierService.test.ts @@ -870,4 +870,25 @@ describe("Single sig service of agent", () => { expect(identifierService.deleteIdentifier).toHaveBeenCalledWith("id1"); expect(identifierService.deleteIdentifier).toHaveBeenCalledWith("id2"); }); + + test("cannot get available witnesses list if the config is misconfigured", async () => { + getAgentConfigMock.mockResolvedValueOnce({}); + + await expect( + identifierService.getAvailableWitnesses() + ).rejects.toThrowError(IdentifierService.MISCONFIGURED_AGENT_CONFIGURATION); + expect(getAgentConfigMock).toBeCalled(); + }); + + test("can get available witnesses list", async () => { + getAgentConfigMock.mockResolvedValueOnce({ + iurls: [ + "http://witnesess:5642/oobi/BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha/controller", + WITNESSES[1] + ], + }); + + expect(await identifierService.getAvailableWitnesses()).toStrictEqual([witnessEids[1]]); + expect(getAgentConfigMock).toBeCalled(); + }); }); diff --git a/src/core/agent/services/identifierService.ts b/src/core/agent/services/identifierService.ts index c204cf990..7c8d3438f 100644 --- a/src/core/agent/services/identifierService.ts +++ b/src/core/agent/services/identifierService.ts @@ -489,7 +489,7 @@ class IdentifierService extends AgentService { } } - private async getAvailableWitnesses(): Promise { + async getAvailableWitnesses(): Promise { const config = await this.props.signifyClient.config().get(); if (!config.iurls) { throw new Error(IdentifierService.MISCONFIGURED_AGENT_CONFIGURATION);