#!/usr/bin/env bash # End-to-end integration test: boot a dedicated server, connect two scripted # bot clients over a real ENet socket, and assert that the whole loop happened -- # handshake, lobby, portal into a dungeon, and the emergency escape back. # # This is the test that catches everything unit tests structurally cannot: RPC # wiring, codec round-trips over the wire, instance transfers, and the client's # reconciliation loop. Run it before calling any networking change done. # # tools/smoke.sh # ~35s # KEEP=1 tools/smoke.sh # keep the logs and print where they are set -uo pipefail cd "$(dirname "$0")/.." GODOT="${GODOT:-godot}" PORT="${PORT:-27099}" SERVER_TICKS="${SERVER_TICKS:-2000}" CLIENT_TICKS="${CLIENT_TICKS:-1700}" OUT="$(mktemp -d -t transcience-smoke-XXXXXX)" cleanup() { kill %1 %2 %3 2>/dev/null wait 2>/dev/null if [[ "${KEEP:-0}" == "1" ]]; then echo "logs kept in $OUT" else rm -rf "$OUT" fi } trap cleanup EXIT echo "smoke: server on port $PORT, logs in $OUT" "$GODOT" --headless --path . -- --server --port "$PORT" --autoquit "$SERVER_TICKS" \ > "$OUT/server.log" 2>&1 & for _ in $(seq 1 60); do grep -q "SERVER_READY" "$OUT/server.log" 2>/dev/null && break sleep 0.25 done if ! grep -q "SERVER_READY" "$OUT/server.log" 2>/dev/null; then echo "FAIL: server never became ready"; cat "$OUT/server.log"; exit 1 fi for n in 1 2; do "$GODOT" --headless --path . -- --bot --host 127.0.0.1 --port "$PORT" \ --name "bot$n" --autoquit "$CLIENT_TICKS" > "$OUT/bot$n.log" 2>&1 & sleep 0.4 done wait %2 %3 2>/dev/null wait %1 2>/dev/null fails=0 check() { # check