#!/usr/bin/env bash
# Differential check: Rust vs the proven Python FIFA 17 backend.
#
#   1. assert the committed fixtures still match what the Python oracle emits
#   2. replay every fixture through the Rust implementation, byte-for-byte
#
# Read-only with respect to the running backend: the oracle is imported as a
# library, no responder is started, no port is bound, no live service is
# touched. Safe to run while the Python backend is serving a live FIFA client.
#
# Use --regen to rewrite the fixtures after an intentional oracle change.
set -euo pipefail

cd "$(dirname "$(readlink -f "$0")")"

if [[ "${1:-}" == "--regen" ]]; then
  echo "==> regenerating fixtures from the Python oracle"
  python3 fixtures/generate.py
else
  echo "==> checking committed fixtures against the Python oracle"
  python3 fixtures/generate.py --check
fi

echo "==> replaying fixtures through the Rust implementation"
cargo test -p openfut-protocol-blaze

echo
echo "PARITY OK — Rust matches the Python oracle byte-for-byte."
