This commit is contained in:
dahyeon committed 2026-08-12 10:48:33 -07:00
1 parent 7dbbf22515
commit 499890cdaa
6 files changed
+35 -3

No files matched your search

+15
View File
@@ -82,6 +82,21 @@ describe('multi-attempt (salvo) auto reservation scheduler', () => {
expect(service.getState().attempts.map((attempt) => attempt.status)).toEqual(['failed', 'failed', 'failed'])
})
it('fires every attempt in parallel without waiting for earlier requests to resolve', async () => {
vi.useFakeTimers()
vi.setSystemTime(new Date('2026-08-12T06:00:00.000Z'))
// 첫 요청이 계속 진행 중이어도(응답 없음) 뒤 시도들이 자기 시각에 발사되어야 한다.
const execute = vi.fn<() => Promise<ReservationResult>>().mockImplementation(() => new Promise<ReservationResult>(() => {}))
const clock = { ensureSample: async () => estimate(), getEstimate: estimate, setAutoTarget: vi.fn() }
const service = new AutoSalvoService(clock, execute, vi.fn())
await service.arm(config(Date.now() + 2_000, 3, 300))
await vi.advanceTimersByTimeAsync(3_000)
expect(execute).toHaveBeenCalledTimes(3)
expect(service.getState().status).toBe('firing')
})
it('cancels remaining attempts after the first success when stopOnSuccess is set', async () => {
vi.useFakeTimers()
vi.setSystemTime(new Date('2026-08-12T06:00:00.000Z'))
Binary file not shown.

Before

Width:  |  Height:  |  Size: 91 KiB

After

Width:  |  Height:  |  Size: 90 KiB