Initial commit: AetherForge Linux (forge-mesh) v0.1.0-dev
Some checks failed
Test / test (push) Has been cancelled
Some checks failed
Test / test (push) Has been cancelled
This commit is contained in:
92
scripts/e2e-lib.sh
Executable file
92
scripts/e2e-lib.sh
Executable file
@@ -0,0 +1,92 @@
|
||||
#!/usr/bin/env bash
|
||||
# Shared helpers for e2e-test.sh
|
||||
set -euo pipefail
|
||||
|
||||
e2e_log() { echo "==> [e2e] $*"; }
|
||||
e2e_pass() { echo " ✓ $*"; }
|
||||
|
||||
e2e_wait_health() {
|
||||
local base="$1" tries="${2:-60}"
|
||||
for _ in $(seq 1 "$tries"); do
|
||||
if curl -fsS "${base}/api/v1/health" >/dev/null 2>&1; then
|
||||
return 0
|
||||
fi
|
||||
sleep 0.25
|
||||
done
|
||||
echo "server did not become healthy at ${base}" >&2
|
||||
return 1
|
||||
}
|
||||
|
||||
e2e_wait_port() {
|
||||
local host="$1" port="$2" tries="${3:-40}"
|
||||
for _ in $(seq 1 "$tries"); do
|
||||
if (echo >/dev/tcp/"${host}"/"${port}") 2>/dev/null; then
|
||||
return 0
|
||||
fi
|
||||
sleep 0.25
|
||||
done
|
||||
echo "port ${host}:${port} not open" >&2
|
||||
return 1
|
||||
}
|
||||
|
||||
e2e_json_field() {
|
||||
local json="$1" field="$2"
|
||||
echo "${json}" | sed -n "s/.*\"${field}\":\"\([^\"]*\)\".*/\1/p" | head -1
|
||||
}
|
||||
|
||||
e2e_curl_auth() {
|
||||
curl -fsS -u "${E2E_USER}:${E2E_PASS}" "$@"
|
||||
}
|
||||
|
||||
e2e_curl_fleet() {
|
||||
curl -fsS -H "Authorization: Bearer ${FLEET_SECRET}" "$@"
|
||||
}
|
||||
|
||||
e2e_write_config() {
|
||||
local path="$1" port="$2" clearance="$3" xmr_port="$4" rvn_port="$5"
|
||||
mkdir -p "$(dirname "${path}")" "/tmp/forge-mesh-e2e"
|
||||
cat > "${path}" <<EOF
|
||||
{
|
||||
"listen_addr": ":${port}",
|
||||
"data_dir": "/tmp/forge-mesh-e2e",
|
||||
"database_path": "/tmp/forge-mesh-e2e/test-${port}.db",
|
||||
"operator_clearance": ${clearance},
|
||||
"auth": {
|
||||
"basic_username": "${E2E_USER}",
|
||||
"basic_password": "${E2E_PASS}",
|
||||
"fleet_secret": "${FLEET_SECRET}"
|
||||
},
|
||||
"wallet_policy": {
|
||||
"default_wallet": "e2e-test-wallet",
|
||||
"currency": "XMR"
|
||||
},
|
||||
"stratum": {
|
||||
"xmr_listen": ":${xmr_port}",
|
||||
"rvn_listen": ":${rvn_port}",
|
||||
"upstream_xmr": "",
|
||||
"upstream_rvn": ""
|
||||
},
|
||||
"forge": {
|
||||
"signing_key_path": "/tmp/forge-mesh-e2e/signing-${port}.key",
|
||||
"artifacts_dir": "/tmp/forge-mesh-e2e/artifacts-${port}"
|
||||
},
|
||||
"court": { "enabled": false, "ollama_url": "http://127.0.0.1:11434" },
|
||||
"telegram": { "enabled": false, "bot_token": "", "chat_id": "" }
|
||||
}
|
||||
EOF
|
||||
}
|
||||
|
||||
e2e_start_server() {
|
||||
local config="$1"
|
||||
./bin/forge-mesh-server -config "${config}" -install-tmpl scripts/install.sh.tpl &
|
||||
SERVER_PID=$!
|
||||
e2e_wait_health "${BASE}"
|
||||
}
|
||||
|
||||
e2e_stop_server() {
|
||||
if [[ -n "${SERVER_PID:-}" ]] && kill -0 "${SERVER_PID}" 2>/dev/null; then
|
||||
kill "${SERVER_PID}" 2>/dev/null || true
|
||||
wait "${SERVER_PID}" 2>/dev/null || true
|
||||
fi
|
||||
SERVER_PID=""
|
||||
}
|
||||
Reference in New Issue
Block a user