diff --git a/packages/api/src/health/health.controller.spec.ts b/packages/api/src/health/health.controller.spec.ts index 0dde57d1df..9bfd136f56 100644 --- a/packages/api/src/health/health.controller.spec.ts +++ b/packages/api/src/health/health.controller.spec.ts @@ -1,3 +1,4 @@ +import { ServiceUnavailableException } from "@nestjs/common"; import { Test, TestingModule } from "@nestjs/testing"; import { HealthCheckService, TypeOrmHealthIndicator, HealthCheckResult } from "@nestjs/terminus"; import { mock } from "jest-mock-extended"; @@ -63,6 +64,33 @@ describe("HealthController", () => { const result = await healthController.check(); expect(result).toBe(healthCheckResult); }); + + describe("when health checks fail with an error", () => { + const error: ServiceUnavailableException = new ServiceUnavailableException({ + status: "error", + db: { + status: "down", + }, + }); + + beforeEach(() => { + jest.spyOn(healthCheckServiceMock, "check").mockImplementation(() => { + throw error; + }); + }); + + it("throws generated error", async () => { + expect.assertions(4); + try { + await healthController.check(); + } catch (e) { + expect(e).toBeInstanceOf(ServiceUnavailableException); + expect(e.message).toBe("Service Unavailable Exception"); + expect(e.response).toEqual(error.getResponse()); + expect(e.stack).toEqual(error.stack); + } + }); + }); }); describe("beforeApplicationShutdown", () => { diff --git a/packages/api/src/health/health.controller.ts b/packages/api/src/health/health.controller.ts index d1a5db6640..a3b3509fe1 100644 --- a/packages/api/src/health/health.controller.ts +++ b/packages/api/src/health/health.controller.ts @@ -22,7 +22,12 @@ export class HealthController implements BeforeApplicationShutdown { @Get() @HealthCheck() public async check(): Promise { - return await this.healthCheckService.check([() => this.dbHealthChecker.pingCheck("database")]); + try { + return await this.healthCheckService.check([() => this.dbHealthChecker.pingCheck("database")]); + } catch (error) { + this.logger.error({ message: error.message, response: error.getResponse() }, error.stack); + throw error; + } } public async beforeApplicationShutdown(signal?: string): Promise { diff --git a/packages/app/src/components/blocks/InfoTable.vue b/packages/app/src/components/blocks/InfoTable.vue index 63ddc25491..0ce0fbebee 100644 --- a/packages/app/src/components/blocks/InfoTable.vue +++ b/packages/app/src/components/blocks/InfoTable.vue @@ -91,9 +91,9 @@ const tableInfoItems = computed(() => { : {}), }, { - label: t("blocks.table.rootHash"), - tooltip: t("blocks.table.rootHashTooltip"), - value: props.block.hash ? { value: props.block.hash } : t("blocks.table.noRootHashYet"), + label: t("blocks.table.blockHash"), + tooltip: t("blocks.table.blockHashTooltip"), + value: props.block.hash ? { value: props.block.hash } : t("blocks.table.noBlockHashYet"), component: props.block.hash ? CopyContent : undefined, }, { diff --git a/packages/app/src/locales/en.json b/packages/app/src/locales/en.json index e4b231daf5..2e92691d33 100644 --- a/packages/app/src/locales/en.json +++ b/packages/app/src/locales/en.json @@ -40,9 +40,9 @@ "blockNumberTooltip": "Block height, indicates the length of the blockchain, increases after the addition of the new block", "blockSize": "Block Size", "blockSizeTooltip": "Number of transactions inside the block", - "rootHash": "Root hash", - "rootHashTooltip": "State root hash obtained after this block execution", - "noRootHashYet": "No root hash yet", + "blockHash": "Block hash", + "blockHashTooltip": "The hash of the current block", + "noBlockHashYet": "No block hash yet", "commitTxHash": "Commit tx hash", "commitTxHashTooltip": "Hash of the L1 transaction sent to the smart contract to commit the block", "committedAt": "Committed", diff --git a/packages/app/src/locales/uk.json b/packages/app/src/locales/uk.json index c8b946f0fa..ab2f0a8ad6 100644 --- a/packages/app/src/locales/uk.json +++ b/packages/app/src/locales/uk.json @@ -26,8 +26,8 @@ "timestamp": "Створено", "blockNumber": "Номер", "blockSize": "Розмір", - "rootHash": "Кореневий хеш", - "noRootHashYet": "Ще немає кореневого хешу", + "blockHash": "Хеш блоку", + "noBlockHashYet": "Ще немає хешу блоку", "committedAt": "Затверджений", "commitTxHash": "Завірений хеш", "notYetCommitted": "Ще не затверджено", diff --git a/packages/app/tests/components/blocks/InfoTable.spec.ts b/packages/app/tests/components/blocks/InfoTable.spec.ts index 0fe1d956d1..9bbc286390 100644 --- a/packages/app/tests/components/blocks/InfoTable.spec.ts +++ b/packages/app/tests/components/blocks/InfoTable.spec.ts @@ -81,10 +81,10 @@ describe("InfoTable:", () => { expect(batch[0].find(".block-info-field-label").text()).toBe(i18n.global.t("blocks.table.batch")); expect(batch[0].findComponent(InfoTooltip).text()).toBe(i18n.global.t("blocks.table.batchTooltip")); expect(batch[1].findComponent(RouterLinkStub).text()).toBe("1"); - const rootHash = rowArray[4].findAll("td"); - expect(rootHash[0].find(".block-info-field-label").text()).toBe(i18n.global.t("blocks.table.rootHash")); - expect(rootHash[0].findComponent(InfoTooltip).text()).toBe(i18n.global.t("blocks.table.rootHashTooltip")); - expect(rootHash[1].text()).toBe("0xcd7533748f8f0c8f406f366e83d5e92d174845405418745d0f7228b85025cd6e"); + const blockHash = rowArray[4].findAll("td"); + expect(blockHash[0].find(".block-info-field-label").text()).toBe(i18n.global.t("blocks.table.blockHash")); + expect(blockHash[0].findComponent(InfoTooltip).text()).toBe(i18n.global.t("blocks.table.blockHashTooltip")); + expect(blockHash[1].text()).toBe("0xcd7533748f8f0c8f406f366e83d5e92d174845405418745d0f7228b85025cd6e"); const timestamp = rowArray[5].findAll("td"); expect(timestamp[0].find(".block-info-field-label").text()).toBe(i18n.global.t("blocks.table.timestamp")); expect(timestamp[0].findComponent(InfoTooltip).text()).toBe(i18n.global.t("blocks.table.timestampTooltip")); diff --git a/packages/app/tests/e2e/features/artifacts/artifactsSet2.feature b/packages/app/tests/e2e/features/artifacts/artifactsSet2.feature index 05043dc146..27e205d119 100644 --- a/packages/app/tests/e2e/features/artifacts/artifactsSet2.feature +++ b/packages/app/tests/e2e/features/artifacts/artifactsSet2.feature @@ -36,7 +36,7 @@ Feature: Main Page Examples: | Row | Value | - | Root hash | 0xfa8fadc06c46dc8a3c52 | + | Block hash | 0xfa8fadc06c46dc8a3c52 | | Timestamp | 2023-02-09 | | Commit tx hash | 0xc3211d8bc51163f923ff | @@ -48,7 +48,7 @@ Feature: Main Page Examples: | Row | Value | - | Root hash | 0xfa8fadc06c46dc8a3c52 | + | Block hash | 0xfa8fadc06c46dc8a3c52 | | Timestamp | 2023-03-24 | | Commit tx hash | 0xeb94693555bd2ef92c82 | diff --git a/packages/app/tests/e2e/features/copying.feature b/packages/app/tests/e2e/features/copying.feature index 7059af1c4b..6ce0fab371 100644 --- a/packages/app/tests/e2e/features/copying.feature +++ b/packages/app/tests/e2e/features/copying.feature @@ -120,7 +120,7 @@ Feature: Copying Examples: | Row | Text | - | Root hash | 0x51f81bcdfc324a0dff2b5bec9d92e21cbebc4d5e29d3a3d30de3e03fbeab8d7f | + | Block hash | 0x51f81bcdfc324a0dff2b5bec9d92e21cbebc4d5e29d3a3d30de3e03fbeab8d7f | | Commit tx hash | 0x6ad6a118e09a27e39ee57c63e812953788de4974987c76bc954c14a8c32688e8 | | Prove tx hash | 0xfbd3a89cee83e4f28999bc8fd5e96d133b7ebc367d5c7026f173d21687998379 | | Execute tx hash | 0x5131c1bb47dca3d42ccdfd12d1ab7224cbb88fb9ad91b94e2da26631602f6fab | @@ -134,7 +134,7 @@ Feature: Copying Examples: | Row | Text | - | Root hash | 0x51f81bcdfc324a0dff2b5bec9d92e21cbebc4d5e29d3a3d30de3e03fbeab8d7f | + | Block hash | 0x51f81bcdfc324a0dff2b5bec9d92e21cbebc4d5e29d3a3d30de3e03fbeab8d7f | | Commit tx hash | 0x33143afba6c91f77d18b0d7a50248e6255461ec0e0cd80a06d3bd86f2686768c | | Prove tx hash | 0x424cdbfb877178a909fbbe6dca6ef131a752e6c91c8b24470d919e30c06e3692 | | Execute tx hash | 0x51425089db3b2ce38b1893ec2f1dc23e3f5db8e9f48f06bb624e99d77fe76aca |