fix(multiplayer): harden live registration verification

This commit is contained in:
Josh Creek
2026-09-04 16:48:25 +01:00
parent 482d4b0985
commit a5cbba8ac9
6 changed files with 84 additions and 15 deletions
+34 -5
View File
@@ -20,7 +20,8 @@ set -euo pipefail
root_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$root_dir"
godot_bin="${GODOT_BIN:-godot}"
godot_bin="${GODOT_BIN:-}"
godot_image="barichello/godot-ci@sha256:622e5ca81b54cd8038ecf7de5d157b47efc800d7cf635af2eec18a6aee4bab7e"
container_name="cosmic-clash-control-plane-integration"
database="cosmic_clash_test"
user="cosmic_clash_test"
@@ -31,6 +32,30 @@ logs_dir="$(mktemp -d "${TMPDIR:-/tmp}/cosmic-clash-control-plane.XXXXXX")"
assignment_smoke="${ASSIGNMENT_SMOKE:-0}"
ranked_smoke="${RANKED_SMOKE:-0}"
if [[ -z "$godot_bin" ]]; then
if command -v godot >/dev/null 2>&1; then
godot_bin="$(command -v godot)"
elif [[ -x /Applications/Godot.app/Contents/MacOS/Godot ]]; then
godot_bin="/Applications/Godot.app/Contents/MacOS/Godot"
fi
fi
use_container_godot=0
if [[ -z "$godot_bin" || ! -x "$godot_bin" ]]; then
use_container_godot=1
fi
run_godot() {
if [[ "$use_container_godot" == 0 ]]; then
"$godot_bin" --headless --path Game res://tests/control_plane_smoke.tscn -- "$@"
return
fi
# Docker Desktop exposes host listeners through this name; use it only for
# the fallback client so the native path keeps its ordinary loopback URL.
docker run --rm --platform linux/amd64 \
--mount "type=bind,src=$root_dir,dst=/workspace" -w /workspace "$godot_image" \
godot --headless --path Game res://tests/control_plane_smoke.tscn -- "$@"
}
testkit_pid=""
cleanup() {
local status=$?
@@ -98,7 +123,11 @@ for attempt in $(seq 1 30); do
sleep 1
done
godot_args=(--control-plane-url="http://127.0.0.1:${api_port}")
client_api_host="127.0.0.1"
if [[ "$use_container_godot" == 1 ]]; then
client_api_host="host.docker.internal"
fi
godot_args=(--control-plane-url="http://${client_api_host}:${api_port}")
if [ "$assignment_smoke" = "1" ]; then
# Seed one complete, player-scoped assignment behind the real API. The fake
# Steam provider derives the player ID from the supplied ticket, so this
@@ -111,8 +140,8 @@ INSERT INTO identities (player_id, steam_id) VALUES ('$assignment_player_id', 'a
INSERT INTO queue_tickets (ticket_id, player_id, playlist, state, client_build, protocol_version, enqueued_at, expires_at, revision)
VALUES ('assignment-smoke-ticket', '$assignment_player_id', 'casual', 'ASSIGNMENT_READY', 'smoke-build', 1, now(), now() + interval '1 hour', 1)
ON CONFLICT (ticket_id) DO NOTHING;
INSERT INTO matches (match_id, playlist, state, region, protocol_version, server_id, revision)
VALUES ('assignment-smoke-match', 'casual', 'ASSIGNMENT_READY', 'EU', 1, 'assignment-smoke-server', 1)
INSERT INTO matches (match_id, playlist, state, region, protocol_version, server_id, revision, initial_connect_ready_at)
VALUES ('assignment-smoke-match', 'casual', 'ASSIGNMENT_READY', 'EU', 1, 'assignment-smoke-server', 1, now())
ON CONFLICT (match_id) DO NOTHING;
INSERT INTO match_participants (match_id, player_id, ticket_id, slot, team)
VALUES ('assignment-smoke-match', '$assignment_player_id', 'assignment-smoke-ticket', 0, 0)
@@ -132,7 +161,7 @@ ON CONFLICT (player_id) DO NOTHING;"
godot_args+=(--steam-ticket="$ranked_ticket" --ranked-profile-smoke)
fi
"$godot_bin" --headless --path Game res://tests/control_plane_smoke.tscn -- "${godot_args[@]}" \
run_godot "${godot_args[@]}" \
>"$logs_dir/godot-client.log" 2>&1
status=$?
@@ -13,7 +13,8 @@ set -euo pipefail
root_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$root_dir"
godot_bin="${GODOT_BIN:-godot}"
godot_bin="${GODOT_BIN:-}"
godot_image="barichello/godot-ci@sha256:622e5ca81b54cd8038ecf7de5d157b47efc800d7cf635af2eec18a6aee4bab7e"
container_name="cosmic-clash-control-plane-proposal-integration"
database="cosmic_clash_test"
user="cosmic_clash_test"
@@ -24,6 +25,27 @@ logs_dir="$(mktemp -d "${TMPDIR:-/tmp}/cosmic-clash-control-plane-proposal.XXXXX
testkit_pid=""
matcher_pid=""
if [[ -z "$godot_bin" ]]; then
if command -v godot >/dev/null 2>&1; then
godot_bin="$(command -v godot)"
elif [[ -x /Applications/Godot.app/Contents/MacOS/Godot ]]; then
godot_bin="/Applications/Godot.app/Contents/MacOS/Godot"
fi
fi
use_container_godot=0
if [[ -z "$godot_bin" || ! -x "$godot_bin" ]]; then
use_container_godot=1
fi
run_godot() {
if [[ "$use_container_godot" == 0 ]]; then
"$godot_bin" --headless --path Game res://tests/control_plane_proposal_smoke.tscn -- "$@"
return
fi
docker run --rm --platform linux/amd64 \
--mount "type=bind,src=$root_dir,dst=/workspace" -w /workspace "$godot_image" \
godot --headless --path Game res://tests/control_plane_proposal_smoke.tscn -- "$@"
}
cleanup() {
local status=$?
if (( status != 0 )); then
@@ -85,12 +107,14 @@ COSMIC_CLASH_POSTGRES_DSN="$dsn" "$logs_dir/matcher" --playlist=casual --size=2
>"$logs_dir/matcher.log" 2>&1 &
matcher_pid=$!
"$godot_bin" --headless --path Game res://tests/control_plane_proposal_smoke.tscn -- \
--control-plane-url="http://127.0.0.1:${api_port}" --role=player-a \
client_api_host="127.0.0.1"
if [[ "$use_container_godot" == 1 ]]; then
client_api_host="host.docker.internal"
fi
run_godot --control-plane-url="http://${client_api_host}:${api_port}" --role=player-a \
>"$logs_dir/godot-player-a.log" 2>&1 &
player_a_pid=$!
"$godot_bin" --headless --path Game res://tests/control_plane_proposal_smoke.tscn -- \
--control-plane-url="http://127.0.0.1:${api_port}" --role=player-b \
run_godot --control-plane-url="http://${client_api_host}:${api_port}" --role=player-b \
>"$logs_dir/godot-player-b.log" 2>&1 &
player_b_pid=$!