- Pre-filter lobby tables before bankroll selection, enforce single-table reserve floor on total bankroll, and expand cash pools via /get-cash-table-list including waitlist sub-tables - Enforce strict stakes band for fallback picks, keep open/waitlisted/seated sub-tables alive across pool updates, and guard duplicate OS windows from blocking the target table count - Trigger immediate 4-grid tiling with OS window fallback and align Cockpit Arrange button with the planned table count - Reject premature layout probes on the table proxy during Unity boot and suppress Mega-Splash and Winner celebration popups in-stream without mouse clicks - Stabilize top-up target sizing, CDP port routing, emergency stop behavior, tournament phantom filtering, and in-process tournament action relay
181 lines
8.0 KiB
Python
181 lines
8.0 KiB
Python
#!/usr/bin/env python3
|
|
"""Spezifikation: Mittler schuetzt Spielstart vor verfruehtem Kacheln und unterdrueckt
|
|
Gewinn-/Mega-Splash-Modals ohne Mausklick (hand/mittler.py).
|
|
|
|
1. Live-Vorfall 10.11. (10:49:02-10:49:05, Tisch 1748878 im Endlos-Loading):
|
|
Waehrend Unity noch bootete (~3 s), verband `tischkanal.lage` (`reposition_table`) zuerst auf
|
|
`<Raum>-mitte`. `Mittler.annehmen` hielt den Kacheler fuer das Spiel, schickte
|
|
`receive_from_lobby` hoch an die Bruecke und beendete sich beim Schliessen des Kachelers ->
|
|
Unity fand beim Connect keinen `-mitte`-Socket und hing im Endlos-Loading fest.
|
|
|
|
2. Live-Vorfall 10.11. (`MEGA SPLASH WINNER` & `Congratulations! You Won` Modals):
|
|
`WinnerModalComponent` kennt im Spielcode weder ESC noch Pipe-Close. Im Kanalweg (`zum_spiel`)
|
|
unterdrueckt der Mittler laengen-exakt `megaSplash:true` und `showWinnerPopups:true`, bevor das
|
|
Spiel den Rahmen liest - Splash-Pot-Drops (20.0) und Log bleiben voll erhalten, das blockierende
|
|
Modal oeffnet aber ohne Maus gar nicht erst.
|
|
|
|
python3 tests/mittler_schutz_spec.py -v
|
|
"""
|
|
import json
|
|
import os
|
|
import shutil
|
|
import socket
|
|
import tempfile
|
|
import threading
|
|
import time
|
|
import unittest
|
|
import sys
|
|
|
|
HIER = os.path.dirname(os.path.abspath(__file__))
|
|
WURZEL = os.path.dirname(HIER)
|
|
for _u in ("hand", "client", "lesen", "betrieb"):
|
|
_p = os.path.join(WURZEL, _u)
|
|
if _p not in sys.path:
|
|
sys.path.insert(0, _p)
|
|
|
|
import mittler # noqa: E402
|
|
import pipe # noqa: E402
|
|
|
|
|
|
class AnnehmenSchuetztVorKacheln(unittest.TestCase):
|
|
def setUp(self):
|
|
self.tmp = tempfile.mkdtemp(prefix="ms-")
|
|
self.mit = mittler.Mittler("TestTisch 1748878", "127.0.0.1:7002", tmp=self.tmp)
|
|
self.mit.herrichten()
|
|
|
|
def tearDown(self):
|
|
self.mit.zu()
|
|
shutil.rmtree(self.tmp, ignore_errors=True)
|
|
|
|
def test_verfruehtes_reposition_table_stiehlt_nicht_den_spielplatz(self):
|
|
# 1. tischkanal.lage verbindet waehrend Unity noch bootet, schickt reposition_table und geht
|
|
# 2. 120 ms spaeter verbindet das echte Spiel (table_initialized)
|
|
ergebnis = []
|
|
t = threading.Thread(target=lambda: ergebnis.append(self.mit.annehmen(frist=3.0)), daemon=True)
|
|
t.start()
|
|
time.sleep(0.05)
|
|
|
|
kacheler = pipe.verbinden(mittler.unser_name("TestTisch 1748878"), self.tmp, 1.0)
|
|
lage_msg = json.dumps({"EventName": "receive_from_lobby", "RequestId": None,
|
|
"Data": {"event_type": "action", "action": "reposition_table"}})
|
|
kacheler.sendall(pipe.rahmen(lage_msg))
|
|
kacheler.close()
|
|
|
|
time.sleep(0.12)
|
|
echtes_spiel = pipe.verbinden(mittler.unser_name("TestTisch 1748878"), self.tmp, 1.0)
|
|
init_msg = json.dumps({"EventName": "send_to_bridge", "RequestId": None,
|
|
"Data": {"event_type": "table_initialized"}})
|
|
echtes_spiel.sendall(pipe.rahmen(init_msg))
|
|
|
|
t.join(timeout=2.5)
|
|
self.assertEqual(ergebnis, [True], "Mittler muss auf das echte Spiel warten statt am Kacheler auszusteigen")
|
|
self.assertIsNotNone(self.mit.spiel)
|
|
self.mit.spiel.settimeout(1.0)
|
|
empfangen = self.mit.spiel.recv(4096)
|
|
self.assertIn(b"table_initialized", empfangen, "self.mit.spiel muss das echte Spiel sein, nicht der Kacheler")
|
|
echtes_spiel.close()
|
|
|
|
def test_sofort_getrennter_leerer_verbinder_stiehlt_nicht_den_spielplatz(self):
|
|
ergebnis = []
|
|
t = threading.Thread(target=lambda: ergebnis.append(self.mit.annehmen(frist=3.0)), daemon=True)
|
|
t.start()
|
|
time.sleep(0.05)
|
|
sonde = pipe.verbinden(mittler.unser_name("TestTisch 1748878"), self.tmp, 1.0)
|
|
sonde.close()
|
|
time.sleep(0.1)
|
|
echtes_spiel = pipe.verbinden(mittler.unser_name("TestTisch 1748878"), self.tmp, 1.0)
|
|
t.join(timeout=2.5)
|
|
self.assertEqual(ergebnis, [True])
|
|
echtes_spiel.sendall(b"SPIEL")
|
|
self.mit.spiel.settimeout(1.0)
|
|
self.assertEqual(self.mit.spiel.recv(16), b"SPIEL")
|
|
echtes_spiel.close()
|
|
|
|
def test_nach_oben_schickt_receive_from_lobby_nie_an_die_bruecke(self):
|
|
msg = pipe.rahmen(json.dumps({"EventName": "receive_from_lobby",
|
|
"Data": {"action": "reposition_table"}}))
|
|
self.assertIs(mittler.Mittler._nach_oben(msg), False)
|
|
|
|
|
|
class ModalsOhneMausUnterdruecken(unittest.TestCase):
|
|
def test_mega_splash_und_winner_popups_laengen_exakt_abgeschaltet(self):
|
|
splash = pipe.rahmen(json.dumps({
|
|
"EventName": "extension_event",
|
|
"Data": {"cmd_bean": {
|
|
"Cmd": "game.splash_the_pot",
|
|
"BeanData": json.dumps({"isIllusion": False, "dropAmount": 20.0,
|
|
"megaSplash": True, "gameHandId": "174898200310"},
|
|
separators=(",", ":")),
|
|
}},
|
|
}, separators=(",", ":")))
|
|
cfg = pipe.rahmen(json.dumps({
|
|
"EventName": "send_to_table",
|
|
"Data": {"api": "app_static_config", "msg": json.dumps({
|
|
"gameTableConfig": {"showWinnerPopups": True, "minimumWinningsInBB": {"1": 400}},
|
|
}, separators=(",", ":"))},
|
|
}, separators=(",", ":")))
|
|
|
|
for roh in (splash, cfg):
|
|
out, rest = mittler.ohne_feier_modals(roh)
|
|
self.assertEqual(rest, b"")
|
|
self.assertEqual(len(out), len(roh), "Laengenkopf darf nicht verschoben werden")
|
|
ent = pipe.entrahmen(out)
|
|
self.assertIsNotNone(ent, "Rahmen muss vollstaendig decodierbar bleiben")
|
|
_, text, trailing = ent
|
|
self.assertEqual(trailing, b"")
|
|
self.assertNotIn('"megaSplash":true', text)
|
|
self.assertNotIn('\\"megaSplash\\":true', text)
|
|
self.assertNotIn('"showWinnerPopups":true', text)
|
|
self.assertNotIn('\\"showWinnerPopups\\":true', text)
|
|
# Drop-Hoehe und pot-relevante Daten bleiben exakt erhalten:
|
|
self.assertIn("20.0", pipe.entrahmen(mittler.ohne_feier_modals(splash)[0])[1])
|
|
|
|
def test_aufgesplittetes_muster_ueber_zwei_stuecke_erkannt(self):
|
|
roh = pipe.rahmen(json.dumps({"Data": {"msg": json.dumps({"megaSplash": True}, separators=(",", ":"))}}))
|
|
schnitt = roh.index(b"Splash")
|
|
out1, rest1 = mittler.ohne_feier_modals(roh[:schnitt])
|
|
out2, rest2 = mittler.ohne_feier_modals(roh[schnitt:], rest1)
|
|
gesamt = out1 + out2 + rest2
|
|
self.assertEqual(len(gesamt), len(roh))
|
|
self.assertNotIn(b"megaSplash", gesamt)
|
|
|
|
def test_normaler_unframed_text_hat_null_verzoegerung(self):
|
|
out, rest = mittler.ohne_feier_modals(b"hallo welt")
|
|
self.assertEqual((out, rest), (b"hallo welt", b""))
|
|
|
|
def test_pumpe_zum_spiel_filtert_modals_ueber_echte_verbindung(self):
|
|
b_out, b_in = socket.socketpair()
|
|
s_in, s_out = socket.socketpair()
|
|
mit = mittler.Mittler("Pumpe 123", "127.0.0.1:7000", tmp=tempfile.gettempdir())
|
|
mit.bruecke = b_in
|
|
mit.spiel = s_in
|
|
splash = pipe.rahmen(json.dumps({
|
|
"EventName": "extension_event",
|
|
"Data": {"cmd_bean": {"Cmd": "game.splash_the_pot",
|
|
"BeanData": json.dumps({"megaSplash": True, "dropAmount": 20.0},
|
|
separators=(",", ":"))}},
|
|
}, separators=(",", ":")))
|
|
t = threading.Thread(target=mit._pumpe, args=(b_in, "zum_spiel"), daemon=True)
|
|
t.start()
|
|
try:
|
|
b_out.sendall(splash)
|
|
b_out.close()
|
|
t.join(timeout=2.0)
|
|
s_out.settimeout(1.0)
|
|
empfangen = s_out.recv(4096)
|
|
ent = pipe.entrahmen(empfangen)
|
|
self.assertIsNotNone(ent)
|
|
self.assertNotIn('"megaSplash":true', ent[1])
|
|
self.assertNotIn('\\"megaSplash\\":true', ent[1])
|
|
self.assertIn("20.0", ent[1])
|
|
finally:
|
|
for sc in (b_in, s_in, s_out):
|
|
try:
|
|
sc.close()
|
|
except OSError:
|
|
pass
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main(verbosity=2)
|