입찰 장수가 사라진 유니크 경매를 복구하고 시스템 공지를 지원한다

This commit is contained in:
Hide_D committed 2026-12-04 09:57:02 +09:00
1 parent 0ae14d5ee0
commit 3f51bec90a
6 files changed
+344 -23

No files matched your search

@@ -153,6 +153,61 @@ describe('unique auction inheritance log compatibility', () => {
expect(resolveAuctionResourceAmount(undefined, 'invalid')).toBeNull();
});
it.each([
{ description: '장수 ID를 새 소유자가 사용함', provenOwner: 'original-account', refund: true },
{ description: '사라진 장수의 입찰 계정을 확인할 수 없음', provenOwner: null, refund: false },
])('유니크 경매를 끝낸다. $description', async ({ provenOwner, refund }) => {
const closeAt = new Date('0193-07-01T00:00:00.000Z');
const reusedGeneral = { id: 7, userId: 'new-account' };
const db = {
$queryRaw: vi.fn(async (query: { strings: readonly string[] }) => {
const sql = query.strings.join(' ');
if (sql.includes('JOIN input_event')) return provenOwner ? [{ userId: provenOwner }] : [];
if (sql.includes('FROM auction_bid')) return [{ id: 9, generalId: 7, amount: 5_100, meta: {} }];
return [{ id: 31, type: 'UNIQUE_ITEM', status: 'FINALIZING', detail: {}, closeAt }];
}),
$executeRaw: vi.fn(async () => 1),
inheritancePoint: { updateManyAndReturn: vi.fn(async () => [{ value: 6_100 }]) },
inheritanceLog: { create: vi.fn(async () => undefined) },
errorLog: { create: vi.fn(async () => undefined) },
};
const world = {
getGeneralById: () => (provenOwner ? reusedGeneral : null),
getState: () => ({ currentYear: 193, currentMonth: 7 }),
gameTickToDate: () => closeAt,
listGenerals: () => [reusedGeneral],
updateGeneral: vi.fn(),
pushLog: vi.fn(),
};
const finalizer = await createAuctionFinalizer({
databaseUrl: 'postgresql://unused',
world: world as unknown as Parameters<typeof createAuctionFinalizer>[0]['world'],
});
await expect(
finalizer.finalize(
withDaemonBoundary({ type: 'auctionFinalize', auctionId: 31, expectedCloseTick: 72_000_000 }),
db as unknown as NonNullable<Parameters<typeof finalizer.finalize>[1]>
)
).resolves.toMatchObject({ ok: true });
expect(db.$executeRaw).toHaveBeenCalledWith(expect.objectContaining({ values: ['CANCELED', 31] }));
expect(world.updateGeneral).not.toHaveBeenCalled();
if (refund) {
expect(db.inheritancePoint.updateManyAndReturn).toHaveBeenCalledWith(
expect.objectContaining({
where: { userId: provenOwner, key: 'previous' },
data: { value: { increment: 5_100 } },
})
);
expect(db.inheritanceLog.create).toHaveBeenCalledOnce();
expect(db.errorLog.create).not.toHaveBeenCalled();
} else {
expect(db.inheritancePoint.updateManyAndReturn).not.toHaveBeenCalled();
expect(db.errorLog.create).toHaveBeenCalledOnce();
}
await finalizer.close();
});
it('uses the Ref-inclusive close boundary and the logical tick as the deadline generation', () => {
const closeAt = new Date('0193-07-01T00:00:00.000Z');
const auction = { closeAt, closeTick: 72_000_000n };