Skip to content

Commit

Permalink
fix: rename root hash to block hash (#249)
Browse files Browse the repository at this point in the history
# What ❔

Rename root hash on the block screen to block hash.

## Checklist

<!-- Check your PR fulfills the following items. -->
<!-- For draft PRs check the boxes as you complete them. -->

- [X] PR title corresponds to the body of PR (we generate changelog
entries from PRs).
- [X] Tests for the changes have been added / updated.
  • Loading branch information
vasyl-ivanchuk authored Apr 23, 2024
1 parent bc94960 commit c094d99
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 17 deletions.
28 changes: 28 additions & 0 deletions packages/api/src/health/health.controller.spec.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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", () => {
Expand Down
7 changes: 6 additions & 1 deletion packages/api/src/health/health.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@ export class HealthController implements BeforeApplicationShutdown {
@Get()
@HealthCheck()
public async check(): Promise<HealthCheckResult> {
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<void> {
Expand Down
6 changes: 3 additions & 3 deletions packages/app/src/components/blocks/InfoTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
{
Expand Down
6 changes: 3 additions & 3 deletions packages/app/src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions packages/app/src/locales/uk.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
"timestamp": "Створено",
"blockNumber": "Номер",
"blockSize": "Розмір",
"rootHash": "Кореневий хеш",
"noRootHashYet": "Ще немає кореневого хешу",
"blockHash": "Хеш блоку",
"noBlockHashYet": "Ще немає хешу блоку",
"committedAt": "Затверджений",
"commitTxHash": "Завірений хеш",
"notYetCommitted": "Ще не затверджено",
Expand Down
8 changes: 4 additions & 4 deletions packages/app/tests/components/blocks/InfoTable.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Feature: Main Page

Examples:
| Row | Value |
| Root hash | 0xfa8fadc06c46dc8a3c52 |
| Block hash | 0xfa8fadc06c46dc8a3c52 |
| Timestamp | 2023-02-09 |
| Commit tx hash | 0xc3211d8bc51163f923ff |

Expand All @@ -48,7 +48,7 @@ Feature: Main Page

Examples:
| Row | Value |
| Root hash | 0xfa8fadc06c46dc8a3c52 |
| Block hash | 0xfa8fadc06c46dc8a3c52 |
| Timestamp | 2023-03-24 |
| Commit tx hash | 0xeb94693555bd2ef92c82 |

Expand Down
4 changes: 2 additions & 2 deletions packages/app/tests/e2e/features/copying.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand All @@ -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 |
Expand Down

0 comments on commit c094d99

Please sign in to comment.