import { test } from '@japa/runner' import { articleAtDate } from '#lib/nntp/date_search' test.group('nntp / articleAtDate', () => { test('finds the article posted at a time, skipping gaps', async ({ assert }) => { // One article a second from t0, articles 1,000,000–1,100,000; 1,040,000–1,040,999 expired. const t0 = Date.UTC(2026, 8, 1) const dateOf = async (n: bigint) => (n >= 1_040_000n && n < 1_041_000n ? null : t0 + Number(n - 1_000_000n) * 1000) const at = await articleAtDate(1_000_000n, 1_100_000n, t0 + 60_000 * 1000, dateOf, 100n) assert.isAtLeast(Number(at), 1_059_900) assert.isAtMost(Number(at), 1_060_000) assert.equal(await articleAtDate(1_000_000n, 1_100_000n, t0 - 1, dateOf, 100n), 1_000_000n) }) })