컴퓨터 방 자동 정리 + 게스트 계정 삭제(로그아웃·하루 미접속) + 테스트 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 } from '@bg/engine';
|
||||
import { SeededRng, playoutSeeds, randomPlayout, seedN, type GameEvent } from '@bg/engine';
|
||||
import {
|
||||
KINDS,
|
||||
allCardIds,
|
||||
@@ -481,7 +481,8 @@ describe('비공개 정보 (§8.3)', () => {
|
||||
});
|
||||
|
||||
test('무작위 진행 중 모든 view가 비공개 정보를 숨기고 이벤트에도 미공개 카드가 없음', () => {
|
||||
for (let seed = 1; seed <= 150; seed++) {
|
||||
const seeds = playoutSeeds(150);
|
||||
for (let seed = 1; seed <= seeds; seed++) {
|
||||
const n = 2 + (seed % 5);
|
||||
const players = Array.from({ length: n }, (_, i) => `P${i}`);
|
||||
const r = SeededRng.fromSeed(seedN(seed));
|
||||
@@ -553,8 +554,10 @@ function invariant(st: unknown): void {
|
||||
}
|
||||
|
||||
describe('무작위 대국 (docs/09 §7)', () => {
|
||||
test('engine randomPlayout, seeds 1–200: 끝남, 카드 보존, 유출 없음, onTimeout 합법, 결정성', () => {
|
||||
for (let i = 1; i <= 200; i++) {
|
||||
const ENGINE_SEEDS = playoutSeeds(200);
|
||||
const FAST_LAST = 200 + playoutSeeds(800);
|
||||
test(`engine randomPlayout, seeds 1–${ENGINE_SEEDS}: 끝남, 카드 보존, 유출 없음, onTimeout 합법, 결정성`, () => {
|
||||
for (let i = 1; i <= ENGINE_SEEDS; i++) {
|
||||
const { players, options } = cfg(i);
|
||||
const r = randomPlayout(game, { players, options, seed: seedN(i), maxSteps: 2000, invariant, maxApplyMs: 50 });
|
||||
expect(r.finished).toBe(true);
|
||||
@@ -569,9 +572,9 @@ describe('무작위 대국 (docs/09 §7)', () => {
|
||||
}
|
||||
}, 60_000);
|
||||
|
||||
test('fast loop, seeds 201–1000 (+ timeouts): 끝남, 카드 보존, 상태 JSON 왕복, 같은 로그 재생 = 같은 결과', () => {
|
||||
test(`fast loop, seeds 201–${FAST_LAST} (+ timeouts): 끝남, 카드 보존, 상태 JSON 왕복, 같은 로그 재생 = 같은 결과`, () => {
|
||||
let maxSteps = 0;
|
||||
for (let i = 201; i <= 1000; i++) {
|
||||
for (let i = 201; i <= FAST_LAST; i++) {
|
||||
const { players, options } = cfg(i);
|
||||
const r = SeededRng.fromSeed(seedN(i));
|
||||
const chooser = SeededRng.fromSeed(seedN(i + 5000));
|
||||
|
||||
Reference in New Issue
Block a user