Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/example-status/java-status.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
=== Java Examples Runner ===
Timestamp (UTC): 2026-03-03 22:14:19Z
Network: local
Mirror: http://localhost:8080/api/v1
Mirror: http://localhost:38081/api/v1

▶️ Running all examples…

Expand Down
2 changes: 1 addition & 1 deletion .github/examples/java/CreateTokenDemo.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public static void main(String[] args ) throws Exception {
String network = System.getenv().getOrDefault("HEDERA_NETWORK", "local"); // "local" for Solo
String mirrorNode = System.getenv().getOrDefault(
"MIRROR_NODE_URL",
"http://localhost:8080/api/v1"
"http://localhost:38081/api/v1"
);

if (operatorId == null || operatorKey == null) {
Expand Down
2 changes: 1 addition & 1 deletion .github/examples/java/CreateTopicDemo.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public static void main(String[] args ) throws Exception {
String network = System.getenv().getOrDefault("HEDERA_NETWORK", "local");
String mirrorNode = System.getenv().getOrDefault(
"MIRROR_NODE_URL",
"http://localhost:8080/api/v1"
"http://localhost:38081/api/v1"
);

if (operatorId == null || operatorKey == null) {
Expand Down
134 changes: 28 additions & 106 deletions .github/workflows/examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ jobs:

env:
HEDERA_NETWORK: local
MIRROR_NODE_URL: http://localhost:8080/api/v1
MIRROR_HEALTH_URL: http://localhost:8080/health
MIRROR_NODE_URL: http://localhost:38081/api/v1
MIRROR_HEALTH_URL: http://localhost:38081/health
MIRROR_HEALTH_TRIES: "180"
MIRROR_HEALTH_INTERVAL: "2"
STATUS_DIR: .github/example-status
Expand Down Expand Up @@ -58,129 +58,51 @@ jobs:
verbosity: 3
wait: 120s

- name: Set up Node.js
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020
with:
node-version: 22.12.0
- name: Install Homebrew
run: |
set -euo pipefail
NONINTERACTIVE=1 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
echo "/home/linuxbrew/.linuxbrew/bin" >> "$GITHUB_PATH"
echo "/home/linuxbrew/.linuxbrew/sbin" >> "$GITHUB_PATH"
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
brew --version

- name: Install Solo CLI
run: |
set -euo pipefail
npm install -g @hashgraph/solo
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
brew install hiero-ledger/tools/solo
solo --version
kind --version

- name: Deploy Solo
env:
SOLO_CLUSTER_NAME: solo
SOLO_NAMESPACE: solo
SOLO_CLUSTER_SETUP_NAMESPACE: solo-cluster
SOLO_DEPLOYMENT: solo-deployment
run: |
set -euo pipefail
kind create cluster -n "${SOLO_CLUSTER_NAME}"
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
solo one-shot single deploy | tee solo-deploy.log

- name: Wait for Mirror Node data (/network/nodes)
env:
API_BASE: ${{ env.MIRROR_NODE_URL }}
TRIES: "180"
INTERVAL: "2"
- name: Verify Mirror Node REST API
shell: bash
run: |
set -euo pipefail
url="http://localhost:38081/api/v1/transactions"

# Tools
if ! command -v jq >/dev/null; then sudo apt-get update -y && sudo apt-get install -y jq >/dev/null; fi
if ! command -v timeout >/dev/null; then sudo apt-get update -y && sudo apt-get install -y coreutils >/dev/null; fi

base_api="${API_BASE%/}"
host="$(echo "$base_api" | awk -F[/:] '{print $4}')"
port="$(echo "$base_api" | awk -F[/:] '{print $5}')"

echo "Waiting for TCP ${host}:${port}…"
for i in $(seq 1 60); do
if (echo >/dev/tcp/"$host"/"$port") >/dev/null 2>&1; then
echo "✅ Port ${port} is accepting connections"
break
fi
echo "⏳ TCP not ready (try $i/60)…"
sleep 1
done

probe_nodes="${base_api}/network/nodes?limit=1"
echo "Probing Mirror REST for data at: ${probe_nodes}"

# First ensure 200s…
for i in $(seq 1 "${TRIES}"); do
code="$(curl -m 3 --connect-timeout 2 -sS -o /dev/null -w '%{http_code}' "$probe_nodes" || true)"
echo "Waiting for ${url} ..."
for i in $(seq 1 180); do
code="$(curl -s -o response.json -w '%{http_code}' "$url" || true)"
if [ "$code" = "200" ]; then
echo "✅ HTTP 200 from Mirror REST"
break
fi
echo "⏳ Mirror REST not 200 yet (try $i/${TRIES})… (code=$code)"
sleep "${INTERVAL}"
done

if [ "${code:-}" != "200" ]; then
echo "❌ Mirror REST never returned 200 for ${probe_nodes}"
curl -m 3 --connect-timeout 2 -sS -v "$probe_nodes" || true
exit 1
fi

for i in $(seq 1 "${TRIES}"); do
body="$(curl -fsS "$probe_nodes" || true)"
count="$(echo "$body" | jq -r '.nodes | length' 2>/dev/null || echo "0")"

if [ "$count" -ge 1 ]; then
echo "✅ Mirror REST returned ${count} node(s)"
echo "Sample response:"
echo "$body" | jq '{nodes: (.nodes | .[:1])}' -C
ready=1
break
fi

echo "⏳ Mirror REST returned empty/invalid data (try $i/${TRIES})…"
sleep "${INTERVAL}"
done

if [ "${ready:-0}" -ne 1 ]; then
echo "❌ Mirror REST never produced non-empty nodes list at ${probe_nodes}"
echo "Last payload (truncated to 500 chars):"
echo "$body" | head -c 500 || true
exit 1
fi

# ---- Probe account balance for the provided ACCOUNT_ID ----
if [ -z "${ACCOUNT_ID:-}" ]; then
echo "⚠️ ACCOUNT_ID not provided; skipping balance check."
exit 0
fi

echo "Checking balance for ACCOUNT_ID=${ACCOUNT_ID}"

# 1) Snapshot endpoint (works on public testnet; may be empty on local)
bal_url="${base_api}/balances?account.id=${ACCOUNT_ID}&limit=1"
echo "Trying snapshot endpoint: ${bal_url}"

snapshot_ok=0
tinybars=""
for i in $(seq 1 "${TRIES}"); do
resp="$(curl -fsS "$bal_url" || true)"
tb="$(echo "$resp" | jq -r '.balances[0].balance // empty' 2>/dev/null || true)"
if [ -n "$tb" ]; then
tinybars="$tb"
snapshot_ok=1
break
count="$(jq '.transactions | length' response.json 2>/dev/null || echo 0)"
if [ "$count" -ge 1 ]; then
echo "REST API response:"
cat response.json | jq .
exit 0
fi
fi
echo "⏳ /balances has no snapshot yet (try $i/${TRIES})…"
sleep "${INTERVAL}"
echo "Attempt $i/180: not ready yet"
sleep 2
done

if [ "$snapshot_ok" -eq 1 ]; then
echo "✅ Mirror /balances returned a snapshot balance: ${tinybars} tinybars"
exit 0
fi
echo "Mirror Node API never became ready"
exit 1

- name: Set up JDK 21
uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1
Expand Down
Loading