From 5a6985b59d93e4dcac25f888a53a1bba1d86e383 Mon Sep 17 00:00:00 2001 From: ivaylogarnev-limechain Date: Thu, 6 Feb 2025 15:31:32 +0200 Subject: [PATCH 1/4] feat: Added Dockerfile for building an image of the TCK, adjusted the Client Signed-off-by: ivaylogarnev-limechain --- .dockerignore | 1 + Dockerfile | 142 +++++++++++++++++++++++++++++++++++++++++ README.md | 75 +++++++++++++++++++++- src/services/Client.ts | 10 ++- 4 files changed, 226 insertions(+), 2 deletions(-) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..2eea525d --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +.env \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..2ad16eaf --- /dev/null +++ b/Dockerfile @@ -0,0 +1,142 @@ +FROM node:22-slim + +# Set working directory +WORKDIR /app + +# Copy package files first for better caching +COPY package.json package-lock.json ./ +RUN npm ci + +# Environment Variables +ENV NETWORK=local \ + RUNNING_IN_DOCKER=true \ + TEST="ALL" + +# Test Mapping +RUN echo '#!/bin/sh\n\ +if [ "$NETWORK" = "testnet" ]; then\n\ + if [ -z "$OPERATOR_ACCOUNT_ID" ] || [ -z "$OPERATOR_ACCOUNT_PRIVATE_KEY" ]; then\n\ + echo "Error: OPERATOR_ACCOUNT_ID and OPERATOR_ACCOUNT_PRIVATE_KEY must be provided for running on testnet"\n\ + exit 1\n\ + fi\n\ + export NODE_TYPE=testnet\n\ + export NODE_TIMEOUT=30000\n\ + export MIRROR_NODE_REST_URL=https://testnet.mirrornode.hedera.com\n\ + export MIRROR_NODE_REST_JAVA_URL=https://testnet.mirrornode.hedera.com\n\ +else\n\ + export NODE_TYPE=local\n\ + export NODE_IP=localhost:50211\n\ + export NODE_ACCOUNT_ID=0.0.3\n\ + export NODE_TIMEOUT=1000000\n\ + export MIRROR_NETWORK=localhost:5600\n\ + export MIRROR_NODE_REST_URL=http://localhost:5551\n\ + export MIRROR_NODE_REST_JAVA_URL=http://localhost:8084\n\ + export OPERATOR_ACCOUNT_ID=0.0.1022\n\ + export OPERATOR_ACCOUNT_PRIVATE_KEY=302e020100300506032b657004220420a608e2130a0a3cb34f86e757303c862bee353d9ab77ba4387ec084f881d420d4\n\ +fi\n\ +\n\ +case "$TEST" in\n\ + # Crypto Service Tests\n\ + "AccountCreate")\n\ + TEST_PATH="src/tests/crypto-service/test-account-create-transaction.ts"\n\ + ;;\n\ + "AccountUpdate")\n\ + TEST_PATH="src/tests/crypto-service/test-account-update-transaction.ts"\n\ + ;;\n\ + "AccountDelete")\n\ + TEST_PATH="src/tests/crypto-service/test-account-delete-transaction.ts"\n\ + ;;\n\ + "AccountAllowanceDelete")\n\ + TEST_PATH="src/tests/crypto-service/test-account-allowance-delete-transaction.ts"\n\ + ;;\n\ + "AccountAllowanceApprove")\n\ + TEST_PATH="src/tests/crypto-service/test-account-allowance-approve-transaction.ts"\n\ + ;;\n\ + # Token Service Tests\n\ + "TokenCreate")\n\ + TEST_PATH="src/tests/token-service/test-token-create-transaction.ts"\n\ + ;;\n\ + "TokenUpdate")\n\ + TEST_PATH="src/tests/token-service/test-token-update-transaction.ts"\n\ + ;;\n\ + "TokenDelete")\n\ + TEST_PATH="src/tests/token-service/test-token-delete-transaction.ts"\n\ + ;;\n\ + "TokenBurn")\n\ + TEST_PATH="src/tests/token-service/test-token-burn-transaction.ts"\n\ + ;;\n\ + "TokenMint")\n\ + TEST_PATH="src/tests/token-service/test-token-mint-transaction.ts"\n\ + ;;\n\ + "TokenAssociate")\n\ + TEST_PATH="src/tests/token-service/test-token-associate-transaction.ts"\n\ + ;;\n\ + "TokenDissociate")\n\ + TEST_PATH="src/tests/token-service/test-token-dissociate-transaction.ts"\n\ + ;;\n\ + "TokenFeeScheduleUpdate")\n\ + TEST_PATH="src/tests/token-service/test-token-fee-schedule-update-transaction.ts"\n\ + ;;\n\ + "TokenGrantKyc")\n\ + TEST_PATH="src/tests/token-service/test-token-grant-kyc-transaction.ts"\n\ + ;;\n\ + "TokenRevokeKyc")\n\ + TEST_PATH="src/tests/token-service/test-token-revoke-kyc-transaction.ts"\n\ + ;;\n\ + "TokenPause")\n\ + TEST_PATH="src/tests/token-service/test-token-pause-transaction.ts"\n\ + ;;\n\ + "TokenUnpause")\n\ + TEST_PATH="src/tests/token-service/test-token-unpause-transaction.ts"\n\ + ;;\n\ + "TokenFreeze")\n\ + TEST_PATH="src/tests/token-service/test-token-freeze-transaction.ts"\n\ + ;;\n\ + "TokenUnfreeze")\n\ + TEST_PATH="src/tests/token-service/test-token-unfreeze-transaction.ts"\n\ + ;;\n\ + "ALL")\n\ + TEST_PATH="src/tests/**/*.ts"\n\ + ;;\n\ + *)\n\ + echo "\ +Unknown test: $TEST\n\ +\n\ +Available tests:\n\ + Crypto Service:\n\ + - AccountCreate\n\ + - AccountUpdate\n\ + - AccountAllowanceDelete\n\ + - AccountAllowanceApprove\n\ + Token Service:\n\ + - TokenCreate\n\ + - TokenUpdate\n\ + - TokenDelete\n\ + - TokenBurn\n\ + - TokenMint\n\ + - TokenAssociate\n\ + - TokenDissociate\n\ + - TokenFeeScheduleUpdate\n\ + - TokenGrantKyc\n\ + - TokenRevokeKyc\n\ + - TokenPause\n\ + - TokenUnpause\n\ + - TokenFreeze\n\ + - TokenUnfreeze\n\ + - ALL (runs all tests)"\n\ + exit 1\n\ + ;;\n\ +esac\n\ +\n\ +npx mocha \ + --require ts-node/register \ + --require tsconfig-paths/register \ + --recursive \"$TEST_PATH\" \ + --reporter mochawesome \ + --exit' > /app/run-tests.sh && chmod +x /app/run-tests.sh + +# Copy the rest of the application +COPY . . + +# Use the mapping script +CMD ["/app/run-tests.sh"] \ No newline at end of file diff --git a/README.md b/README.md index 2ef03fc3..dbb1659d 100644 --- a/README.md +++ b/README.md @@ -84,6 +84,79 @@ Please read our [contributing guide](https://github.com/hiero-ledger/.github/blo Hiero uses the Linux Foundation Decentralised Trust [Code of Conduct](https://www.lfdecentralizedtrust.org/code-of-conduct). + +## Docker + +The TCK is also available as a Docker image, providing an easy way to run tests in an isolated environment. + +### Pull the Docker Image + +You can pull the pre-built Docker image from DockerHub: + +```bash +docker pull ivaylogarnev/tck-client +``` + +### Running Tests + +The Docker image supports running tests against both local and testnet environments. + +#### Local Network (Default) +To run tests against a local network: +```bash +# Run specific test +docker run --network host -e TEST=AccountCreate ivaylogarnev/tck-client + +# Run all tests +docker run --network host ivaylogarnev/tck-client +``` + +#### Testnet +To run tests against Hedera Testnet: +```bash +docker run --network host \ + -e NETWORK=testnet \ + -e OPERATOR_ACCOUNT_ID=your-account-id \ + -e OPERATOR_ACCOUNT_PRIVATE_KEY=your-private-key \ + # Run specific test + -e TEST=AccountCreate \ + ivaylogarnev/tck-client +``` + +### Available Tests +Some of the available test options include: +- AccountCreate +- AccountUpdate +- AccountDelete +- AccountAllowanceDelete +- AccountAllowanceApprove +- TokenCreate +- TokenUpdate +- TokenDelete +- TokenBurn +- TokenMint +- TokenAssociate +- TokenDissociate +- TokenFeeScheduleUpdate +- TokenGrantKyc +- TokenRevokeKyc +- TokenPause +- TokenUnpause +- TokenFreeze +- TokenUnfreeze +- ALL (runs all tests) + +Running an invalid test name will display the complete list of available tests. + +### Building the Docker Image Locally + +If you want to build the image locally: +```bash +docker build -t tck-client . +``` + +Then run it using the same commands as above, replacing `ivaylogarnev/tck-client` with `tck-client`. + ## License -[Apache License 2.0](LICENSE) +[Apache License 2.0](LICENSE) \ No newline at end of file diff --git a/src/services/Client.ts b/src/services/Client.ts index 14207915..0ef74157 100644 --- a/src/services/Client.ts +++ b/src/services/Client.ts @@ -5,12 +5,20 @@ import "dotenv/config"; let nextID = 0; const createID: CreateID = () => nextID++; +// Determine the host based on environment +const getHost = () => { + if (process.env.RUNNING_IN_DOCKER) { + return "http://host.docker.internal"; + } + return "http://localhost"; +}; + // JSONRPCClient needs to know how to send a JSON-RPC request. // Tell it by passing a function to its constructor. The function must take a JSON-RPC request and send it. const JSONRPClient = new JSONRPCClient( async (jsonRPCRequest): Promise => { try { - const response = await axios.post("http://localhost", jsonRPCRequest, { + const response = await axios.post(getHost(), jsonRPCRequest, { headers: { "Content-Type": "application/json", }, From 5213b82784472fdffbc38faee3feee318378b927 Mon Sep 17 00:00:00 2001 From: ivaylogarnev-limechain Date: Mon, 10 Feb 2025 18:01:26 +0200 Subject: [PATCH 2/4] refactor: Refactored the Dockerfile, split the logic into separate files and updated the image Signed-off-by: ivaylogarnev-limechain --- Dockerfile | 127 +---------------------------- src/services/Client.ts | 6 +- src/utils/docker/network-config.ts | 66 +++++++++++++++ src/utils/docker/run-tests.ts | 50 ++++++++++++ src/utils/docker/test-paths.ts | 29 +++++++ 5 files changed, 151 insertions(+), 127 deletions(-) create mode 100644 src/utils/docker/network-config.ts create mode 100644 src/utils/docker/run-tests.ts create mode 100644 src/utils/docker/test-paths.ts diff --git a/Dockerfile b/Dockerfile index 2ad16eaf..1907bb1e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,131 +12,8 @@ ENV NETWORK=local \ RUNNING_IN_DOCKER=true \ TEST="ALL" -# Test Mapping -RUN echo '#!/bin/sh\n\ -if [ "$NETWORK" = "testnet" ]; then\n\ - if [ -z "$OPERATOR_ACCOUNT_ID" ] || [ -z "$OPERATOR_ACCOUNT_PRIVATE_KEY" ]; then\n\ - echo "Error: OPERATOR_ACCOUNT_ID and OPERATOR_ACCOUNT_PRIVATE_KEY must be provided for running on testnet"\n\ - exit 1\n\ - fi\n\ - export NODE_TYPE=testnet\n\ - export NODE_TIMEOUT=30000\n\ - export MIRROR_NODE_REST_URL=https://testnet.mirrornode.hedera.com\n\ - export MIRROR_NODE_REST_JAVA_URL=https://testnet.mirrornode.hedera.com\n\ -else\n\ - export NODE_TYPE=local\n\ - export NODE_IP=localhost:50211\n\ - export NODE_ACCOUNT_ID=0.0.3\n\ - export NODE_TIMEOUT=1000000\n\ - export MIRROR_NETWORK=localhost:5600\n\ - export MIRROR_NODE_REST_URL=http://localhost:5551\n\ - export MIRROR_NODE_REST_JAVA_URL=http://localhost:8084\n\ - export OPERATOR_ACCOUNT_ID=0.0.1022\n\ - export OPERATOR_ACCOUNT_PRIVATE_KEY=302e020100300506032b657004220420a608e2130a0a3cb34f86e757303c862bee353d9ab77ba4387ec084f881d420d4\n\ -fi\n\ -\n\ -case "$TEST" in\n\ - # Crypto Service Tests\n\ - "AccountCreate")\n\ - TEST_PATH="src/tests/crypto-service/test-account-create-transaction.ts"\n\ - ;;\n\ - "AccountUpdate")\n\ - TEST_PATH="src/tests/crypto-service/test-account-update-transaction.ts"\n\ - ;;\n\ - "AccountDelete")\n\ - TEST_PATH="src/tests/crypto-service/test-account-delete-transaction.ts"\n\ - ;;\n\ - "AccountAllowanceDelete")\n\ - TEST_PATH="src/tests/crypto-service/test-account-allowance-delete-transaction.ts"\n\ - ;;\n\ - "AccountAllowanceApprove")\n\ - TEST_PATH="src/tests/crypto-service/test-account-allowance-approve-transaction.ts"\n\ - ;;\n\ - # Token Service Tests\n\ - "TokenCreate")\n\ - TEST_PATH="src/tests/token-service/test-token-create-transaction.ts"\n\ - ;;\n\ - "TokenUpdate")\n\ - TEST_PATH="src/tests/token-service/test-token-update-transaction.ts"\n\ - ;;\n\ - "TokenDelete")\n\ - TEST_PATH="src/tests/token-service/test-token-delete-transaction.ts"\n\ - ;;\n\ - "TokenBurn")\n\ - TEST_PATH="src/tests/token-service/test-token-burn-transaction.ts"\n\ - ;;\n\ - "TokenMint")\n\ - TEST_PATH="src/tests/token-service/test-token-mint-transaction.ts"\n\ - ;;\n\ - "TokenAssociate")\n\ - TEST_PATH="src/tests/token-service/test-token-associate-transaction.ts"\n\ - ;;\n\ - "TokenDissociate")\n\ - TEST_PATH="src/tests/token-service/test-token-dissociate-transaction.ts"\n\ - ;;\n\ - "TokenFeeScheduleUpdate")\n\ - TEST_PATH="src/tests/token-service/test-token-fee-schedule-update-transaction.ts"\n\ - ;;\n\ - "TokenGrantKyc")\n\ - TEST_PATH="src/tests/token-service/test-token-grant-kyc-transaction.ts"\n\ - ;;\n\ - "TokenRevokeKyc")\n\ - TEST_PATH="src/tests/token-service/test-token-revoke-kyc-transaction.ts"\n\ - ;;\n\ - "TokenPause")\n\ - TEST_PATH="src/tests/token-service/test-token-pause-transaction.ts"\n\ - ;;\n\ - "TokenUnpause")\n\ - TEST_PATH="src/tests/token-service/test-token-unpause-transaction.ts"\n\ - ;;\n\ - "TokenFreeze")\n\ - TEST_PATH="src/tests/token-service/test-token-freeze-transaction.ts"\n\ - ;;\n\ - "TokenUnfreeze")\n\ - TEST_PATH="src/tests/token-service/test-token-unfreeze-transaction.ts"\n\ - ;;\n\ - "ALL")\n\ - TEST_PATH="src/tests/**/*.ts"\n\ - ;;\n\ - *)\n\ - echo "\ -Unknown test: $TEST\n\ -\n\ -Available tests:\n\ - Crypto Service:\n\ - - AccountCreate\n\ - - AccountUpdate\n\ - - AccountAllowanceDelete\n\ - - AccountAllowanceApprove\n\ - Token Service:\n\ - - TokenCreate\n\ - - TokenUpdate\n\ - - TokenDelete\n\ - - TokenBurn\n\ - - TokenMint\n\ - - TokenAssociate\n\ - - TokenDissociate\n\ - - TokenFeeScheduleUpdate\n\ - - TokenGrantKyc\n\ - - TokenRevokeKyc\n\ - - TokenPause\n\ - - TokenUnpause\n\ - - TokenFreeze\n\ - - TokenUnfreeze\n\ - - ALL (runs all tests)"\n\ - exit 1\n\ - ;;\n\ -esac\n\ -\n\ -npx mocha \ - --require ts-node/register \ - --require tsconfig-paths/register \ - --recursive \"$TEST_PATH\" \ - --reporter mochawesome \ - --exit' > /app/run-tests.sh && chmod +x /app/run-tests.sh - # Copy the rest of the application COPY . . -# Use the mapping script -CMD ["/app/run-tests.sh"] \ No newline at end of file +# Use the runner script +CMD ["npx", "ts-node", "--files", "/app/src/utils/docker/run-tests.ts"] \ No newline at end of file diff --git a/src/services/Client.ts b/src/services/Client.ts index eadda688..1e405776 100644 --- a/src/services/Client.ts +++ b/src/services/Client.ts @@ -7,10 +7,12 @@ const createID: CreateID = () => nextID++; // Determine the host based on environment const getHost = () => { + const url = process.env.JSON_RPC_SERVER_URL ?? "http://localhost:8544"; + if (process.env.RUNNING_IN_DOCKER) { - return "http://host.docker.internal"; + return url.replace("localhost", "host.docker.internal"); } - return process.env.JSON_RPC_SERVER_URL ?? "http://localhost:8544"; + return url; }; // JSONRPCClient needs to know how to send a JSON-RPC request. diff --git a/src/utils/docker/network-config.ts b/src/utils/docker/network-config.ts new file mode 100644 index 00000000..a915a99c --- /dev/null +++ b/src/utils/docker/network-config.ts @@ -0,0 +1,66 @@ +import dotenv from "dotenv"; + +// Helper function to convert camelCase to SNAKE_CASE +const toEnvFormat = (str: string): string => { + return str + .split(/(?=[A-Z])/) + .join("_") + .toUpperCase(); +}; + +// Set the network config based on the network name +export const getNetworkConfig = ( + network: string, +): Record => { + if (network === "testnet") { + dotenv.config({ path: ".env.testnet" }); + + if ( + process.env.OPERATOR_ACCOUNT_ID === "***" || + process.env.OPERATOR_ACCOUNT_PRIVATE_KEY === "***" + ) { + console.log( + "\n" + + "TESTNET_OPERATOR_ACCOUNT_ID and TESTNET_OPERATOR_ACCOUNT_PRIVATE_KEY must be set for testnet!", + ); + + process.exit(1); + } + + return { + nodeType: "testnet", + nodeTimeout: process.env.NODE_TIMEOUT, + mirrorNodeRestUrl: process.env.MIRROR_NODE_REST_URL, + operatorAccountId: process.env.OPERATOR_ACCOUNT_ID, + operatorAccountPrivateKey: process.env.OPERATOR_ACCOUNT_PRIVATE_KEY, + jsonRpcServerUrl: process.env.JSON_RPC_SERVER_URL, + }; + } + + dotenv.config({ path: ".env.custom_node" }); + + return { + nodeType: "local", + nodeTimeout: process.env.NODE_TIMEOUT, + nodeIp: process.env.NODE_IP, + nodeAccountId: process.env.NODE_ACCOUNT_ID, + mirrorNetwork: process.env.MIRROR_NETWORK, + mirrorNodeRestUrl: process.env.MIRROR_NODE_REST_URL, + mirrorNodeRestJavaUrl: process.env.MIRROR_NODE_REST_JAVA_URL, + operatorAccountId: process.env.OPERATOR_ACCOUNT_ID, + operatorAccountPrivateKey: process.env.OPERATOR_ACCOUNT_PRIVATE_KEY, + jsonRpcServerUrl: process.env.JSON_RPC_SERVER_URL, + }; +}; + +export const setNetworkEnvironment = (network: string): void => { + const config = getNetworkConfig(network); + + // Set environment variables with correct naming convention + Object.entries(config).forEach(([key, value]) => { + if (value) { + const envKey = toEnvFormat(key); + process.env[envKey] = value.toString(); + } + }); +}; diff --git a/src/utils/docker/run-tests.ts b/src/utils/docker/run-tests.ts new file mode 100644 index 00000000..9edebc85 --- /dev/null +++ b/src/utils/docker/run-tests.ts @@ -0,0 +1,50 @@ +/* eslint-disable no-console */ +import { TEST_CONFIGURATIONS } from "./test-paths"; +import { setNetworkEnvironment } from "./network-config"; + +const runTests = async (testName: string, network: string): Promise => { + try { + // Test parameter validation + const testConfig = TEST_CONFIGURATIONS[testName]; + if (!testConfig) { + console.error(`Unknown test: ${testName}`); + console.log("\nAvailable tests:"); + Object.entries(TEST_CONFIGURATIONS).forEach(([name]) => { + console.log(` - ${name}`); + }); + process.exit(1); + } + + setNetworkEnvironment(network); + + // Run the test + const { execSync } = require("child_process"); + + const command = [ + "npx mocha", + "--require ts-node/register", + "--require tsconfig-paths/register", + `--recursive "${testConfig}"`, + "--reporter mochawesome", + "--exit", + ].join(" "); + + execSync(command, { + stdio: "inherit", + env: process.env, + shell: true, + }); + } catch (error: any) { + console.error("Unhandled error:", error); + process.exit(1); + } +}; + +// Get arguments from process.argv or environment variables +const testName = process.env.TEST || "ALL"; +const network = process.env.NETWORK || "local"; + +runTests(testName, network).catch((error) => { + console.error("Unhandled error:", error); + process.exit(1); +}); diff --git a/src/utils/docker/test-paths.ts b/src/utils/docker/test-paths.ts new file mode 100644 index 00000000..9643b857 --- /dev/null +++ b/src/utils/docker/test-paths.ts @@ -0,0 +1,29 @@ +export const TEST_CONFIGURATIONS: Record = { + // Crypto Service Tests + AccountCreate: "src/tests/crypto-service/test-account-create-transaction.ts", + AccountUpdate: "src/tests/crypto-service/test-account-update-transaction.ts", + AccountDelete: "src/tests/crypto-service/test-account-delete-transaction.ts", + AccountAllowanceDelete: + "src/tests/crypto-service/test-account-allowance-delete-transaction.ts", + AccountAllowanceApprove: + "src/tests/crypto-service/test-account-allowance-approve-transaction.ts", + // Token Service Tests + TokenCreate: "src/tests/token-service/test-token-create-transaction.ts", + TokenUpdate: "src/tests/token-service/test-token-update-transaction.ts", + TokenDelete: "src/tests/token-service/test-token-delete-transaction.ts", + TokenBurn: "src/tests/token-service/test-token-burn-transaction.ts", + TokenMint: "src/tests/token-service/test-token-mint-transaction.ts", + TokenAssociate: "src/tests/token-service/test-token-associate-transaction.ts", + TokenDissociate: + "src/tests/token-service/test-token-dissociate-transaction.ts", + TokenFeeScheduleUpdate: + "src/tests/token-service/test-token-fee-schedule-update-transaction.ts", + TokenGrantKyc: "src/tests/token-service/test-token-grant-kyc-transaction.ts", + TokenRevokeKyc: + "src/tests/token-service/test-token-revoke-kyc-transaction.ts", + TokenPause: "src/tests/token-service/test-token-pause-transaction.ts", + TokenUnpause: "src/tests/token-service/test-token-unpause-transaction.ts", + TokenFreeze: "src/tests/token-service/test-token-freeze-transaction.ts", + TokenUnfreeze: "src/tests/token-service/test-token-unfreeze-transaction.ts", + ALL: "src/tests/**/*.ts", +}; From 15b04fd19090014c055aa8939eb6894cc44914d1 Mon Sep 17 00:00:00 2001 From: ivaylogarnev-limechain Date: Tue, 11 Feb 2025 16:54:00 +0200 Subject: [PATCH 3/4] fix: Comments fix Signed-off-by: ivaylogarnev-limechain --- Dockerfile | 2 +- README.md | 33 +++++++++++-------- .../RunTestsInContainer.ts} | 4 +-- src/utils/{docker => constants}/test-paths.ts | 0 .../{docker => helpers}/network-config.ts | 0 5 files changed, 23 insertions(+), 16 deletions(-) rename src/{utils/docker/run-tests.ts => services/RunTestsInContainer.ts} (89%) rename src/utils/{docker => constants}/test-paths.ts (100%) rename src/utils/{docker => helpers}/network-config.ts (100%) diff --git a/Dockerfile b/Dockerfile index 1907bb1e..44b54153 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,4 +16,4 @@ ENV NETWORK=local \ COPY . . # Use the runner script -CMD ["npx", "ts-node", "--files", "/app/src/utils/docker/run-tests.ts"] \ No newline at end of file +CMD ["npx", "ts-node", "--files", "/app/src/services/RunTestsInContainer.ts"] \ No newline at end of file diff --git a/README.md b/README.md index 396ed409..6f84645c 100644 --- a/README.md +++ b/README.md @@ -111,19 +111,6 @@ task generate-mirror-node-models This command uses `openapi-typescript-codegen` to parse the `mirror-node.yaml` file and generate corresponding TypeScript models in `src/utils/models/mirror-node-models` - -## Contributing - -Whether you’re fixing bugs, enhancing features, or improving documentation, your contributions are important — let’s build something great together! - -Please read our [contributing guide](https://github.com/hiero-ledger/.github/blob/main/CONTRIBUTING.md) to see how you can get involved. - - -## Code of Conduct - -Hiero uses the Linux Foundation Decentralised Trust [Code of Conduct](https://www.lfdecentralizedtrust.org/code-of-conduct). - - ## Docker The TCK is also available as a Docker image, providing an easy way to run tests in an isolated environment. @@ -193,6 +180,26 @@ If you want to build the image locally: ```bash docker build -t tck-client . ``` +### Docker additional notes + +```bash +# entry point for the Docker image. It sets the network environment, maps the ports, and runs the tests. + +RunTestsInContainer.ts +``` + +**Note:** This file is specifically used for running tests within the Docker environment and does not affect how tests are run locally. For local test execution, please refer to the instructions provided in the "Install and run" section above. + +## Contributing + +Whether you’re fixing bugs, enhancing features, or improving documentation, your contributions are important — let’s build something great together! + +Please read our [contributing guide](https://github.com/hiero-ledger/.github/blob/main/CONTRIBUTING.md) to see how you can get involved. + + +## Code of Conduct + +Hiero uses the Linux Foundation Decentralised Trust [Code of Conduct](https://www.lfdecentralizedtrust.org/code-of-conduct). Then run it using the same commands as above, replacing `ivaylogarnev/tck-client` with `tck-client`. diff --git a/src/utils/docker/run-tests.ts b/src/services/RunTestsInContainer.ts similarity index 89% rename from src/utils/docker/run-tests.ts rename to src/services/RunTestsInContainer.ts index 9edebc85..a4da43d0 100644 --- a/src/utils/docker/run-tests.ts +++ b/src/services/RunTestsInContainer.ts @@ -1,6 +1,6 @@ /* eslint-disable no-console */ -import { TEST_CONFIGURATIONS } from "./test-paths"; -import { setNetworkEnvironment } from "./network-config"; +import { TEST_CONFIGURATIONS } from "../utils/constants/test-paths"; +import { setNetworkEnvironment } from "../utils/helpers/network-config"; const runTests = async (testName: string, network: string): Promise => { try { diff --git a/src/utils/docker/test-paths.ts b/src/utils/constants/test-paths.ts similarity index 100% rename from src/utils/docker/test-paths.ts rename to src/utils/constants/test-paths.ts diff --git a/src/utils/docker/network-config.ts b/src/utils/helpers/network-config.ts similarity index 100% rename from src/utils/docker/network-config.ts rename to src/utils/helpers/network-config.ts From 6938468ae3ea611bcb539c23cf760b9bec251299 Mon Sep 17 00:00:00 2001 From: ivaylogarnev-limechain Date: Tue, 11 Feb 2025 22:15:33 +0200 Subject: [PATCH 4/4] refactor: Fixed misplaced sentence in the README Signed-off-by: ivaylogarnev-limechain --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6f84645c..2a7bc3fc 100644 --- a/README.md +++ b/README.md @@ -180,6 +180,9 @@ If you want to build the image locally: ```bash docker build -t tck-client . ``` + +Then run it using the same commands as above, replacing `ivaylogarnev/tck-client` with `tck-client`. + ### Docker additional notes ```bash @@ -201,8 +204,6 @@ Please read our [contributing guide](https://github.com/hiero-ledger/.github/blo Hiero uses the Linux Foundation Decentralised Trust [Code of Conduct](https://www.lfdecentralizedtrust.org/code-of-conduct). -Then run it using the same commands as above, replacing `ivaylogarnev/tck-client` with `tck-client`. - ## License [Apache License 2.0](LICENSE) \ No newline at end of file