컴퓨터 방 자동 정리 + 게스트 계정 삭제(로그아웃·하루 미접속) + 테스트 10분→1분
- 방 화면을 벗어나면(홈·규칙) detach: 자리·접속 상태는 유지, 방 접속 수에서 빠짐 - 컴퓨터가 있는 방: 사람이 모두 [방 나가기]하면 바로 닫고, 아무도 안 보면 대기실·끝난 방 1분, 게임 중 30분 뒤 정리 - 게스트 로그아웃 = 계정 삭제(자리·전적·세션·소켓), 사이트를 닫고 24시간 지난 게스트도 1분 주기로 삭제 - users.last_seen_at을 요청·소켓 종료 때 갱신(이전엔 갱신 안 됨), 003 마이그레이션에서 기존 게스트 시계 초기화 - 테스트: 무작위 대국 시드를 playoutSeeds()로 평소 1/10, test:full은 전부. bun test --parallel=4, 테스트 서버 종료 대기 1s→50ms Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { describe, expect, test } from 'bun:test';
|
||||
import { SeededRng, randomPlayout, seedN, type GameEvent, type Rng } from '@bg/engine';
|
||||
import { SeededRng, playoutSeeds, randomPlayout, seedN, type GameEvent, type Rng } from '@bg/engine';
|
||||
import {
|
||||
autoPlay,
|
||||
bestScore,
|
||||
@@ -854,10 +854,12 @@ const CONFIGS: [string, Partial<GostopOptions>][] = [
|
||||
];
|
||||
|
||||
describe('random playouts', () => {
|
||||
test('1,000 seeds: invariants, every legal action validates, onTimeout legal in every state', () => {
|
||||
const SEEDS = playoutSeeds(1000);
|
||||
const LEAK_SEEDS = playoutSeeds(300);
|
||||
test(`${SEEDS} seeds: invariants, every legal action validates, onTimeout legal in every state`, () => {
|
||||
let rounds = 0;
|
||||
let stops = 0;
|
||||
for (let seed = 1; seed <= 1000; seed++) {
|
||||
for (let seed = 1; seed <= SEEDS; seed++) {
|
||||
const n = 2 + (seed % 4);
|
||||
const ps = players(n);
|
||||
const [, opts] = CONFIGS[seed % CONFIGS.length]!;
|
||||
@@ -894,8 +896,8 @@ describe('random playouts', () => {
|
||||
invariants(s);
|
||||
expect(gostop.result(s)!.ranking.flat().sort()).toEqual([...ps].sort());
|
||||
}
|
||||
expect(rounds).toBeGreaterThan(900);
|
||||
expect(stops).toBeGreaterThan(100);
|
||||
expect(rounds).toBeGreaterThan(SEEDS * 0.9);
|
||||
expect(stops).toBeGreaterThan(SEEDS / 10);
|
||||
}, 60_000);
|
||||
|
||||
test('engine randomPlayout (leaks, JSON round-trip, determinism) in every mode', () => {
|
||||
@@ -920,7 +922,7 @@ describe('random playouts', () => {
|
||||
}, 60_000);
|
||||
|
||||
test('leak property: views never contain hidden hands / deck, events only reveal public cards', () => {
|
||||
for (let seed = 1; seed <= 300; seed++) {
|
||||
for (let seed = 1; seed <= LEAK_SEEDS; seed++) {
|
||||
const n = 2 + (seed % 4);
|
||||
const ps = players(n);
|
||||
const options = parse({ ...CONFIGS[seed % CONFIGS.length]![1], rounds: 1 });
|
||||
|
||||
Reference in New Issue
Block a user