조건부 통합 테스트 등록과 시계 fixture를 바로잡는다

This commit is contained in:
2026-09-23 16:21:52 +00:00
parent 7e1783d651
commit 08be92b6fa
6 changed files with 37 additions and 4 deletions
@@ -5,6 +5,7 @@ import { SystemClock } from '@sammo-ts/common';
import {
createDatabaseTurnHooks,
DatabaseTurnDaemonCommandQueue,
DatabaseTurnDaemonLease,
EngineStateManager,
InMemoryTurnStateStore,
InMemoryTurnWorld,
@@ -695,6 +696,10 @@ liveDescribe('auction worker durable recovery', () => {
const redisConnector = createRedisConnector(resolveRedisConfigFromEnv());
await redisConnector.connect();
// 독립 worker는 활성 daemon의 clock_ready fence가 있을 때만 GAME_TIME을 진행한다.
const lease = await DatabaseTurnDaemonLease.connect(databaseUrl!, { profile: profileName });
await lease.acquire();
await lease.markClockReady();
const keys = buildAuctionTimerKeys(profileName);
const abortController = new AbortController();
const worker = runAuctionWorker({ signal: abortController.signal });
@@ -725,6 +730,8 @@ liveDescribe('auction worker durable recovery', () => {
} finally {
abortController.abort();
await worker;
await lease.close();
await connector.prisma.turnDaemonLease.delete({ where: { profile: profileName } });
await redisConnector.client.del([keys.timerKey, keys.historyKey]);
await redisConnector.disconnect();
await connector.prisma.errorLog.deleteMany({
@@ -384,8 +384,8 @@ integration('generic general creation through the durable turn daemon', () => {
actorUserId: userId,
});
expect(access.lastRefresh?.getTime()).toBe(event.createdAt.getTime());
const turnGridOffsetSeconds =
((created.turnTime.getTime() - runtime!.world.getState().lastTurnTime.getTime()) / 1000 + 300) % 300;
// 상속 턴 시간대는 daemon cursor가 아닌 5분 격자의 위상을 보존한다.
const turnGridOffsetSeconds = ((created.turnTime.getTime() / 1000) % 300 + 300) % 300;
expect(turnGridOffsetSeconds).toBeGreaterThanOrEqual(35);
expect(turnGridOffsetSeconds).toBeLessThan(40);