From 034b3374cb669216bb5ebd2636dcb2b8f13ef827 Mon Sep 17 00:00:00 2001 From: ivaylogarnev-limechain Date: Mon, 17 Feb 2025 18:53:41 +0200 Subject: [PATCH 1/8] feat: Added dockerization of the Go server and a Taskfile to execute tests within TCK Signed-off-by: ivaylogarnev-limechain --- tck/.dockerignore | 1 + tck/Dockerfile | 31 ++++++++++++++++++++ tck/Taskfile.yml | 65 ++++++++++++++++++++++++++++++++++++++++++ tck/cmd/server.go | 2 +- tck/docker-compose.yml | 14 +++++++++ tck/methods/sdk.go | 11 +++++++ 6 files changed, 123 insertions(+), 1 deletion(-) create mode 100644 tck/.dockerignore create mode 100644 tck/Dockerfile create mode 100644 tck/Taskfile.yml create mode 100644 tck/docker-compose.yml diff --git a/tck/.dockerignore b/tck/.dockerignore new file mode 100644 index 000000000..b512c09d4 --- /dev/null +++ b/tck/.dockerignore @@ -0,0 +1 @@ +node_modules \ No newline at end of file diff --git a/tck/Dockerfile b/tck/Dockerfile new file mode 100644 index 000000000..edb204159 --- /dev/null +++ b/tck/Dockerfile @@ -0,0 +1,31 @@ +# Use the official Golang image as a base +FROM golang:1.21 + +# Set the working directory inside the container +WORKDIR /app + +# Create directory for the SDK +RUN mkdir -p /app/hiero-sdk-go + +# Copy the SDK files first (from parent directory) +COPY . /app/hiero-sdk-go/ + +# Copy TCK files to their location +WORKDIR /app/hiero-sdk-go/tck + +# Copy go.mod and go.sum first +COPY tck/go.mod tck/go.sum ./ + +# Then copy the rest of the TCK files +COPY tck/ . + +ENV RUNNING_IN_DOCKER=true + +# Update and tidy the dependencies +RUN go mod tidy + +# Build the Go application - specifically building server.go +RUN go build -o server cmd/server.go + +# Command to run the server +CMD ["./server"] \ No newline at end of file diff --git a/tck/Taskfile.yml b/tck/Taskfile.yml new file mode 100644 index 000000000..38b43cf97 --- /dev/null +++ b/tck/Taskfile.yml @@ -0,0 +1,65 @@ +version: "3" + +tasks: + check-go: + desc: "Check if Go is installed and meets the version requirement" + silent: true + cmds: + - echo "Checking Go version..." + - | + if ! command -v go &> /dev/null || [ "$(go version | awk '{print $3}' | cut -c 3-)" \< "1.20" ]; then + echo "Go 1.20 or higher is required. Please install it." + exit 1 + fi + + install-hedera-local: + desc: "Install Hedera Local Node CLI tool if not installed" + silent: true + cmds: + - echo "Checking for Hedera Local Node CLI..." + - | + if ! command -v hedera &> /dev/null; then + echo "Hedera Local Node CLI not found, installing..." + npm install @hashgraph/hedera-local -g + else + echo "Hedera Local Node CLI is already installed." + fi + + start-local-node: + desc: "Start the local Hedera network" + silent: true + deps: [check-go, install-hedera-local] + cmds: + - echo "Starting local Hedera network..." + - hedera start + + build-tck-go-server: + desc: "Build the Docker image for tck-go-server" + silent: true + dir: tck + cmds: + - echo "Building Docker image for tck-go-server..." + - docker build -t tck-server-go -f Dockerfile . + + run-specific-test: + desc: "Run all services with a specific test" + silent: true + deps: [start-local-node, build-tck-go-server] + vars: + TEST: "{{.TEST}}" + cmds: + - echo "Running all services with TEST=${TEST}..." + - TEST=${TEST} docker compose up + + start-all-tests: + desc: "Start Docker Compose services" + silent: true + deps: [start-local-node] + cmds: + - echo "Starting Docker Compose services..." + - docker compose up + + default: + desc: "Start local node and Docker Compose" + silent: true + deps: [start-all-tests] diff --git a/tck/cmd/server.go b/tck/cmd/server.go index 3d45cc30b..58df9e324 100644 --- a/tck/cmd/server.go +++ b/tck/cmd/server.go @@ -66,7 +66,7 @@ func main() { http.HandleFunc("/", bridge.ServeHTTP) port := os.Getenv("TCK_PORT") if port == "" { - port = "80" + port = "8544" } log.Println("Server is listening on port: " + port) diff --git a/tck/docker-compose.yml b/tck/docker-compose.yml new file mode 100644 index 000000000..6fff30165 --- /dev/null +++ b/tck/docker-compose.yml @@ -0,0 +1,14 @@ +services: + tck-server: + image: tck-go-server + build: + context: . + ports: + - "8544:8544" + tck-client: + image: ivaylogarnev/tck-client + network_mode: "host" + environment: + TEST: "${TEST:-ALL}" + depends_on: + - tck-server diff --git a/tck/methods/sdk.go b/tck/methods/sdk.go index ba7f63895..8b0197cfa 100644 --- a/tck/methods/sdk.go +++ b/tck/methods/sdk.go @@ -4,6 +4,7 @@ package methods import ( "context" + "os" "github.com/hiero-ledger/hiero-sdk-go/tck/param" "github.com/hiero-ledger/hiero-sdk-go/tck/response" @@ -36,6 +37,16 @@ func (s *SDKService) Setup(_ context.Context, params param.SetupParams) (respons clientType = "testnet" } + // Check if running in Docker + if os.Getenv("RUNNING_IN_DOCKER") != "" { + // Create a network map for Docker + network := make(map[string]hiero.AccountID) + network["host.docker.internal:50211"] = hiero.AccountID{Account: 3} + + // Set the network on the client + s.Client.SetNetwork(network) + } + // Set operator (adjustments may be needed based on the Hiero SDK) operatorId, _ := hiero.AccountIDFromString(params.OperatorAccountId) operatorKey, _ := hiero.PrivateKeyFromString(params.OperatorPrivateKey) From 7be66b5caa424e96cae031c3ae9343bb377115f3 Mon Sep 17 00:00:00 2001 From: ivaylogarnev-limechain Date: Tue, 18 Feb 2025 09:52:36 +0200 Subject: [PATCH 2/8] refactor: Added README, fixed Taskfile to build up docker image correctly Signed-off-by: ivaylogarnev-limechain --- tck/README.md | 107 +++++++++++++++++++++++++++++++++++++++++++++-- tck/Taskfile.yml | 13 ++++-- 2 files changed, 112 insertions(+), 8 deletions(-) diff --git a/tck/README.md b/tck/README.md index 0f0d37da2..58c6c2d75 100644 --- a/tck/README.md +++ b/tck/README.md @@ -2,12 +2,111 @@ This is a server that implements the [SDK TCK specification](https://github.com/hiero-ledger/hiero-sdk-tck/) for the Go SDK. -## Running the server +# Server start up guide for Go 🛠️ -To run the server you need to run +This guide will help you set up, start, and test the TCK server using Docker and Go. Follow the steps below to ensure a smooth setup. -``` +## 🚀 Start the TCK Server + +Run the following commands to build and start the server: + +```bash +# From the tck directory +go mod tidy go run cmd/server.go ``` -This will start the server on port **80**. You can change the port by setting the `TCK_PORT` environment variable or by adding a .env file with the same variable. \ No newline at end of file +This will start the server on port **80**. You can change the port by setting the `TCK_PORT` environment variable or by adding a .env file with the same variable. + +Once started, your TCK server will be up and running! 🚦 + +# Start all TCK tests with Docker 🐳 + +This guide will help you set up and start the TCK server, local node and run all TCK tests using Docker. Follow these steps to ensure all dependencies are installed and the server runs smoothly. + +## Prerequisites + +Before you begin, ensure you have the following installed: + +- **Go**: Version 1.20 or higher +- **Docker**: Latest version +- **Docker Compose**: Latest version +- **Task**: Latest version + +### Installing Task + +You can install Task using one of these methods: + +```bash +# Using Homebrew (macOS) +brew install go-task + +# Using Go +go install github.com/go-task/task/v3/cmd/task@latest +``` + +## 🔧 Setup Instructions + +### 1. Check Go Version + +Verify that Go is installed and meets the version requirements: + +```bash +go version +``` + +### 2. Install Hedera Local Node CLI + +If not already installed, run the following command: + +```bash +npm install @hashgraph/hedera-local -g +``` + +### 3. Start the Local Hedera Network + +Run the following command to start the local Hedera network: + +```bash +task start-local-node +``` + +### 4. Build the Docker Image + +Build the Docker image for the TCK Go server: + +```bash +task build-tck-go-server +``` + +### 5. Run a specific test + +```bash +task run-specific-test -- TEST=AccountCreate +``` + +This will: + +- Spin up the TCK server +- Start required containers +- Run only the **AccountCreate** tests + +### 6. Start All Services + +Now, let's fire up all the services using Docker Compose: + +```bash +task start-all-tests +``` + +This will: + +- Spin up the TCK server +- Start required containers +- Run all tests automatically + +Sit back and let Docker do the magic! + +### 🎉 All Done! + +Your Go TCK server is now running inside Docker! 🚀 You can now execute tests and validate the system. diff --git a/tck/Taskfile.yml b/tck/Taskfile.yml index 38b43cf97..73d512206 100644 --- a/tck/Taskfile.yml +++ b/tck/Taskfile.yml @@ -7,8 +7,13 @@ tasks: cmds: - echo "Checking Go version..." - | - if ! command -v go &> /dev/null || [ "$(go version | awk '{print $3}' | cut -c 3-)" \< "1.20" ]; then - echo "Go 1.20 or higher is required. Please install it." + if ! command -v go &> /dev/null; then + echo "Go is not installed. Please install Go 1.20 or higher." + exit 1 + fi + GO_VERSION=$(go version | awk '{print $3}' | cut -c 3-) + if [ $(echo -e "1.20\n$GO_VERSION" | sort -V | head -n1) != "1.20" ]; then + echo "Go 1.20 or higher is required. Current version: $GO_VERSION" exit 1 fi @@ -36,10 +41,10 @@ tasks: build-tck-go-server: desc: "Build the Docker image for tck-go-server" silent: true - dir: tck + dir: ../ cmds: - echo "Building Docker image for tck-go-server..." - - docker build -t tck-server-go -f Dockerfile . + - docker build -t tck-go-server -f tck/Dockerfile . run-specific-test: desc: "Run all services with a specific test" From 53a80c391f0789118db3b29c0c43cc955abbb2a3 Mon Sep 17 00:00:00 2001 From: ivaylogarnev-limechain Date: Wed, 19 Feb 2025 16:26:20 +0200 Subject: [PATCH 3/8] feat: Added Testnet compabability, running specific test logic and cross-platform support Signed-off-by: ivaylogarnev-limechain --- tck/README.md | 81 ++++++++++++++++-------------------------- tck/Taskfile.yml | 50 +++++++++++++++++++++----- tck/docker-compose.yml | 20 +++++++++-- tck/methods/sdk.go | 2 +- 4 files changed, 91 insertions(+), 62 deletions(-) diff --git a/tck/README.md b/tck/README.md index 58c6c2d75..ee66f06b4 100644 --- a/tck/README.md +++ b/tck/README.md @@ -16,13 +16,13 @@ go mod tidy go run cmd/server.go ``` -This will start the server on port **80**. You can change the port by setting the `TCK_PORT` environment variable or by adding a .env file with the same variable. +This will start the server on port **8054**. You can change the port by setting the `TCK_PORT` environment variable or by adding a .env file with the same variable. Once started, your TCK server will be up and running! 🚦 # Start all TCK tests with Docker 🐳 -This guide will help you set up and start the TCK server, local node and run all TCK tests using Docker. Follow these steps to ensure all dependencies are installed and the server runs smoothly. +This section covers setting up and running TCK tests using Docker. ## Prerequisites @@ -33,80 +33,59 @@ Before you begin, ensure you have the following installed: - **Docker Compose**: Latest version - **Task**: Latest version -### Installing Task - -You can install Task using one of these methods: +## 🔹 Run a specific test ```bash -# Using Homebrew (macOS) -brew install go-task - -# Using Go -go install github.com/go-task/task/v3/cmd/task@latest +task run-specific-test TEST=AccountCreate ``` -## 🔧 Setup Instructions - -### 1. Check Go Version - -Verify that Go is installed and meets the version requirements: +This will: -```bash -go version -``` +- Verifies prerequisites -### 2. Install Hedera Local Node CLI +- Starts the TCK server -If not already installed, run the following command: +- Launches required containers -```bash -npm install @hashgraph/hedera-local -g -``` +- Run only the `AccountCreate` tests -### 3. Start the Local Hedera Network +## 🔹 Run all tests -Run the following command to start the local Hedera network: +To run all tests: ```bash -task start-local-node +task start-all-tests ``` -### 4. Build the Docker Image - -Build the Docker image for the TCK Go server: +This will: -```bash -task build-tck-go-server -``` +- Verifies prerequisites -### 5. Run a specific test +- Starts the TCK server -```bash -task run-specific-test -- TEST=AccountCreate -``` +- Launches required containers -This will: +- Run all tests automatically -- Spin up the TCK server -- Start required containers -- Run only the **AccountCreate** tests +Sit back and let Docker do the work! 🚀 -### 6. Start All Services +### ⚙️ Running Tests Against Hiero Testnet -Now, let's fire up all the services using Docker Compose: +To run tests against the Hiero Testnet, use the following command: ```bash -task start-all-tests +task run-specific-test \ + NETWORK=testnet \ + OPERATOR_ACCOUNT_ID=your-account-id \ + OPERATOR_ACCOUNT_PRIVATE_KEY=your-private-key \ + # Run specific test + TEST=AccountCreate ``` -This will: - -- Spin up the TCK server -- Start required containers -- Run all tests automatically +### 🎉 All Done! -Sit back and let Docker do the magic! +Your TCK server is now running inside Docker! 🚀 You can now execute tests and validate the system. -### 🎉 All Done! +Need help? Reach out to the team! 💬👨‍💻 -Your Go TCK server is now running inside Docker! 🚀 You can now execute tests and validate the system. +Happy coding! 💻✨ diff --git a/tck/Taskfile.yml b/tck/Taskfile.yml index 73d512206..033c17df5 100644 --- a/tck/Taskfile.yml +++ b/tck/Taskfile.yml @@ -38,8 +38,15 @@ tasks: - echo "Starting local Hedera network..." - hedera start + pull-tck-client-server: + desc: "Pull the Docker image for tck-client" + cmds: + - echo "Pulling Docker image for tck-client..." + - docker pull ivaylogarnev/tck-client-cross-network + build-tck-go-server: - desc: "Build the Docker image for tck-go-server" + desc: "Build the Docker image for tck-go-server & pulling tck-client image" + deps: [pull-tck-client-server] silent: true dir: ../ cmds: @@ -49,21 +56,48 @@ tasks: run-specific-test: desc: "Run all services with a specific test" silent: true - deps: [start-local-node, build-tck-go-server] + deps: [build-tck-go-server] vars: - TEST: "{{.TEST}}" + TEST: '{{.TEST | default "ALL"}}' + NETWORK: '{{.NETWORK | default "local"}}' + OPERATOR_ACCOUNT_ID: "{{.OPERATOR_ACCOUNT_ID}}" + OPERATOR_ACCOUNT_PRIVATE_KEY: "{{.OPERATOR_ACCOUNT_PRIVATE_KEY}}" cmds: - - echo "Running all services with TEST=${TEST}..." - - TEST=${TEST} docker compose up + - | + export TEST={{.TEST | default "ALL"}} + export NETWORK={{.NETWORK | default "local"}} + export OPERATOR_ACCOUNT_ID={{.OPERATOR_ACCOUNT_ID}} + export OPERATOR_ACCOUNT_PRIVATE_KEY="{{.OPERATOR_ACCOUNT_PRIVATE_KEY}}" + if [ "$NETWORK" = "testnet" ]; then + if [ -z "$OPERATOR_ACCOUNT_ID" ] || [ -z "$OPERATOR_ACCOUNT_PRIVATE_KEY" ]; then + echo "Error: OPERATOR_ACCOUNT_ID and OPERATOR_ACCOUNT_PRIVATE_KEY must be provided for testnet." + exit 1 + fi + fi + docker compose up start-all-tests: desc: "Start Docker Compose services" silent: true - deps: [start-local-node] + deps: [start-local-node, build-tck-go-server] + vars: + NETWORK: '{{.NETWORK | default "local"}}' + OPERATOR_ACCOUNT_ID: "{{.OPERATOR_ACCOUNT_ID}}" + OPERATOR_ACCOUNT_PRIVATE_KEY: "{{.OPERATOR_ACCOUNT_PRIVATE_KEY}}" cmds: - echo "Starting Docker Compose services..." - - docker compose up - + - | + export TEST={{.TEST | default "ALL"}} + export NETWORK={{.NETWORK | default "local"}} + export OPERATOR_ACCOUNT_ID={{.OPERATOR_ACCOUNT_ID}} + export OPERATOR_ACCOUNT_PRIVATE_KEY="{{.OPERATOR_ACCOUNT_PRIVATE_KEY}}" + if [ "$NETWORK" = "testnet" ]; then + if [ -z "$OPERATOR_ACCOUNT_ID" ] || [ -z "$OPERATOR_ACCOUNT_PRIVATE_KEY" ]; then + echo "Error: OPERATOR_ACCOUNT_ID and OPERATOR_ACCOUNT_PRIVATE_KEY must be provided for testnet." + exit 1 + fi + fi + docker compose up default: desc: "Start local node and Docker Compose" silent: true diff --git a/tck/docker-compose.yml b/tck/docker-compose.yml index 6fff30165..e2a7a51cd 100644 --- a/tck/docker-compose.yml +++ b/tck/docker-compose.yml @@ -1,14 +1,30 @@ services: tck-server: image: tck-go-server + networks: + - hedera-network-node + - hedera-mirror-node + environment: + NETWORK: "${NETWORK:-local}" build: context: . ports: - "8544:8544" tck-client: - image: ivaylogarnev/tck-client - network_mode: "host" + image: ivaylogarnev/tck-client-cross-network + networks: + - hedera-network-node + - hedera-mirror-node environment: TEST: "${TEST:-ALL}" + NETWORK: "${NETWORK:-local}" + OPERATOR_ACCOUNT_ID: "${OPERATOR_ACCOUNT_ID:-0.0.1022}" + OPERATOR_ACCOUNT_PRIVATE_KEY: "${OPERATOR_ACCOUNT_PRIVATE_KEY:-302e020100300506032b657004220420a608e2130a0a3cb34f86e757303c862bee353d9ab77ba4387ec084f881d420d4}" depends_on: - tck-server + +networks: + hedera-network-node: + external: true + hedera-mirror-node: + external: true diff --git a/tck/methods/sdk.go b/tck/methods/sdk.go index 8b0197cfa..1ff564da0 100644 --- a/tck/methods/sdk.go +++ b/tck/methods/sdk.go @@ -41,7 +41,7 @@ func (s *SDKService) Setup(_ context.Context, params param.SetupParams) (respons if os.Getenv("RUNNING_IN_DOCKER") != "" { // Create a network map for Docker network := make(map[string]hiero.AccountID) - network["host.docker.internal:50211"] = hiero.AccountID{Account: 3} + network["network-node:50211"] = hiero.AccountID{Account: 3} // Set the network on the client s.Client.SetNetwork(network) From 9863ec6564d0121b87e6028779089294091ce466 Mon Sep 17 00:00:00 2001 From: ivaylogarnev-limechain Date: Wed, 19 Feb 2025 16:35:36 +0200 Subject: [PATCH 4/8] refactor: Added multi-stage build Signed-off-by: ivaylogarnev-limechain --- tck/Dockerfile | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/tck/Dockerfile b/tck/Dockerfile index edb204159..e249cb232 100644 --- a/tck/Dockerfile +++ b/tck/Dockerfile @@ -1,31 +1,29 @@ -# Use the official Golang image as a base -FROM golang:1.21 +FROM golang:1.21 AS builder # Set the working directory inside the container WORKDIR /app -# Create directory for the SDK -RUN mkdir -p /app/hiero-sdk-go - # Copy the SDK files first (from parent directory) COPY . /app/hiero-sdk-go/ -# Copy TCK files to their location +# Set the working directory for the TCK files WORKDIR /app/hiero-sdk-go/tck # Copy go.mod and go.sum first COPY tck/go.mod tck/go.sum ./ -# Then copy the rest of the TCK files -COPY tck/ . +RUN go mod tidy +RUN go build -o server cmd/server.go -ENV RUNNING_IN_DOCKER=true -# Update and tidy the dependencies -RUN go mod tidy +FROM alpine:latest -# Build the Go application - specifically building server.go -RUN go build -o server cmd/server.go +WORKDIR /app +COPY --from=builder /app/hiero-sdk-go/tck/server . +RUN chmod +x /app/server + +# Install necessary libraries +RUN apk add --no-cache libc6-compat -# Command to run the server +ENV RUNNING_IN_DOCKER=true CMD ["./server"] \ No newline at end of file From cfef4c37798c4afdec7cd225705ed21b9dfdb1e3 Mon Sep 17 00:00:00 2001 From: ivaylogarnev-limechain Date: Wed, 19 Feb 2025 16:39:27 +0200 Subject: [PATCH 5/8] fix: Added start-local-node deps in the run-specific-test task Signed-off-by: ivaylogarnev-limechain --- tck/Taskfile.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tck/Taskfile.yml b/tck/Taskfile.yml index 033c17df5..6ccf1dea1 100644 --- a/tck/Taskfile.yml +++ b/tck/Taskfile.yml @@ -56,7 +56,7 @@ tasks: run-specific-test: desc: "Run all services with a specific test" silent: true - deps: [build-tck-go-server] + deps: [start-local-node, build-tck-go-server] vars: TEST: '{{.TEST | default "ALL"}}' NETWORK: '{{.NETWORK | default "local"}}' From dd9237ee445d5d0fc909d4f0dbeb20cfb7b390fa Mon Sep 17 00:00:00 2001 From: ivaylogarnev-limechain Date: Wed, 19 Feb 2025 16:54:35 +0200 Subject: [PATCH 6/8] fix: Added error handling for setting the custom network Signed-off-by: ivaylogarnev-limechain --- tck/methods/sdk.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tck/methods/sdk.go b/tck/methods/sdk.go index 1ff564da0..4539f6478 100644 --- a/tck/methods/sdk.go +++ b/tck/methods/sdk.go @@ -44,7 +44,9 @@ func (s *SDKService) Setup(_ context.Context, params param.SetupParams) (respons network["network-node:50211"] = hiero.AccountID{Account: 3} // Set the network on the client - s.Client.SetNetwork(network) + if err := s.Client.SetNetwork(network); err != nil { + return response.SetupResponse{}, err + } } // Set operator (adjustments may be needed based on the Hiero SDK) From 4b760df97a1a87a9929d6fdca34e060bbbd6b8bf Mon Sep 17 00:00:00 2001 From: ivaylogarnev-limechain Date: Thu, 20 Feb 2025 15:42:30 +0200 Subject: [PATCH 7/8] fix: Added additional env configuration and updated README Signed-off-by: ivaylogarnev-limechain --- tck/Dockerfile | 1 - tck/README.md | 2 ++ tck/Taskfile.yml | 10 +++++++++- tck/docker-compose.yml | 6 +++++- tck/methods/sdk.go | 13 ------------- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/tck/Dockerfile b/tck/Dockerfile index e249cb232..e16d03704 100644 --- a/tck/Dockerfile +++ b/tck/Dockerfile @@ -25,5 +25,4 @@ RUN chmod +x /app/server # Install necessary libraries RUN apk add --no-cache libc6-compat -ENV RUNNING_IN_DOCKER=true CMD ["./server"] \ No newline at end of file diff --git a/tck/README.md b/tck/README.md index ee66f06b4..671d10867 100644 --- a/tck/README.md +++ b/tck/README.md @@ -78,6 +78,8 @@ task run-specific-test \ NETWORK=testnet \ OPERATOR_ACCOUNT_ID=your-account-id \ OPERATOR_ACCOUNT_PRIVATE_KEY=your-private-key \ + MIRROR_NODE_REST_URL=https://testnet.mirrornode.hedera.com \ + MIRROR_NODE_REST_JAVA_URL=https://testnet.mirrornode.hedera.com \ # Run specific test TEST=AccountCreate ``` diff --git a/tck/Taskfile.yml b/tck/Taskfile.yml index 6ccf1dea1..735d972fc 100644 --- a/tck/Taskfile.yml +++ b/tck/Taskfile.yml @@ -42,7 +42,7 @@ tasks: desc: "Pull the Docker image for tck-client" cmds: - echo "Pulling Docker image for tck-client..." - - docker pull ivaylogarnev/tck-client-cross-network + - docker pull ivaylogarnev/tck-client build-tck-go-server: desc: "Build the Docker image for tck-go-server & pulling tck-client image" @@ -62,12 +62,16 @@ tasks: NETWORK: '{{.NETWORK | default "local"}}' OPERATOR_ACCOUNT_ID: "{{.OPERATOR_ACCOUNT_ID}}" OPERATOR_ACCOUNT_PRIVATE_KEY: "{{.OPERATOR_ACCOUNT_PRIVATE_KEY}}" + MIRROR_NODE_REST_URL: "{{.MIRROR_NODE_REST_URL}}" + MIRROR_NODE_REST_JAVA_URL: "{{.MIRROR_NODE_REST_JAVA_URL}}" cmds: - | export TEST={{.TEST | default "ALL"}} export NETWORK={{.NETWORK | default "local"}} export OPERATOR_ACCOUNT_ID={{.OPERATOR_ACCOUNT_ID}} export OPERATOR_ACCOUNT_PRIVATE_KEY="{{.OPERATOR_ACCOUNT_PRIVATE_KEY}}" + export MIRROR_NODE_REST_URL="{{.MIRROR_NODE_REST_URL}}" + export MIRROR_NODE_REST_JAVA_URL="{{.MIRROR_NODE_REST_JAVA_URL}}" if [ "$NETWORK" = "testnet" ]; then if [ -z "$OPERATOR_ACCOUNT_ID" ] || [ -z "$OPERATOR_ACCOUNT_PRIVATE_KEY" ]; then echo "Error: OPERATOR_ACCOUNT_ID and OPERATOR_ACCOUNT_PRIVATE_KEY must be provided for testnet." @@ -84,6 +88,8 @@ tasks: NETWORK: '{{.NETWORK | default "local"}}' OPERATOR_ACCOUNT_ID: "{{.OPERATOR_ACCOUNT_ID}}" OPERATOR_ACCOUNT_PRIVATE_KEY: "{{.OPERATOR_ACCOUNT_PRIVATE_KEY}}" + MIRROR_NODE_REST_URL: "{{.MIRROR_NODE_REST_URL}}" + MIRROR_NODE_REST_JAVA_URL: "{{.MIRROR_NODE_REST_JAVA_URL}}" cmds: - echo "Starting Docker Compose services..." - | @@ -91,6 +97,8 @@ tasks: export NETWORK={{.NETWORK | default "local"}} export OPERATOR_ACCOUNT_ID={{.OPERATOR_ACCOUNT_ID}} export OPERATOR_ACCOUNT_PRIVATE_KEY="{{.OPERATOR_ACCOUNT_PRIVATE_KEY}}" + export MIRROR_NODE_REST_URL="{{.MIRROR_NODE_REST_URL}}" + export MIRROR_NODE_REST_JAVA_URL="{{.MIRROR_NODE_REST_JAVA_URL}}" if [ "$NETWORK" = "testnet" ]; then if [ -z "$OPERATOR_ACCOUNT_ID" ] || [ -z "$OPERATOR_ACCOUNT_PRIVATE_KEY" ]; then echo "Error: OPERATOR_ACCOUNT_ID and OPERATOR_ACCOUNT_PRIVATE_KEY must be provided for testnet." diff --git a/tck/docker-compose.yml b/tck/docker-compose.yml index e2a7a51cd..242a325b1 100644 --- a/tck/docker-compose.yml +++ b/tck/docker-compose.yml @@ -11,7 +11,7 @@ services: ports: - "8544:8544" tck-client: - image: ivaylogarnev/tck-client-cross-network + image: ivaylogarnev/tck-client networks: - hedera-network-node - hedera-mirror-node @@ -20,6 +20,10 @@ services: NETWORK: "${NETWORK:-local}" OPERATOR_ACCOUNT_ID: "${OPERATOR_ACCOUNT_ID:-0.0.1022}" OPERATOR_ACCOUNT_PRIVATE_KEY: "${OPERATOR_ACCOUNT_PRIVATE_KEY:-302e020100300506032b657004220420a608e2130a0a3cb34f86e757303c862bee353d9ab77ba4387ec084f881d420d4}" + JSON_RPC_SERVER_URL: "http://tck-server:8544" + NODE_IP: "network-node:50211" + MIRROR_NODE_REST_URL: "${MIRROR_NODE_REST_URL:-http://mirror-node-rest:5551}" + MIRROR_NODE_REST_JAVA_URL: "${MIRROR_NODE_REST_JAVA_URL:-http://mirror-node-rest-java:8084}" depends_on: - tck-server diff --git a/tck/methods/sdk.go b/tck/methods/sdk.go index 4539f6478..ba7f63895 100644 --- a/tck/methods/sdk.go +++ b/tck/methods/sdk.go @@ -4,7 +4,6 @@ package methods import ( "context" - "os" "github.com/hiero-ledger/hiero-sdk-go/tck/param" "github.com/hiero-ledger/hiero-sdk-go/tck/response" @@ -37,18 +36,6 @@ func (s *SDKService) Setup(_ context.Context, params param.SetupParams) (respons clientType = "testnet" } - // Check if running in Docker - if os.Getenv("RUNNING_IN_DOCKER") != "" { - // Create a network map for Docker - network := make(map[string]hiero.AccountID) - network["network-node:50211"] = hiero.AccountID{Account: 3} - - // Set the network on the client - if err := s.Client.SetNetwork(network); err != nil { - return response.SetupResponse{}, err - } - } - // Set operator (adjustments may be needed based on the Hiero SDK) operatorId, _ := hiero.AccountIDFromString(params.OperatorAccountId) operatorKey, _ := hiero.PrivateKeyFromString(params.OperatorPrivateKey) From 7eae248da760f9932ac4939cf884a91f8c465911 Mon Sep 17 00:00:00 2001 From: ivaylogarnev-limechain Date: Fri, 21 Feb 2025 15:15:06 +0200 Subject: [PATCH 8/8] fix: Anchored alpine to a stable version Signed-off-by: ivaylogarnev-limechain --- tck/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tck/Dockerfile b/tck/Dockerfile index e16d03704..26ee21916 100644 --- a/tck/Dockerfile +++ b/tck/Dockerfile @@ -16,7 +16,7 @@ RUN go mod tidy RUN go build -o server cmd/server.go -FROM alpine:latest +FROM alpine:3.20 WORKDIR /app COPY --from=builder /app/hiero-sdk-go/tck/server .