Fix city generation retries and remove city-wide economy mechanics

This commit is contained in:
mrleo1nid committed 2026-10-30 22:54:06 +03:00
1 parent 85df37c26e
commit 63f0c72ff3
21 files changed
+252 -585

No files matched your search

+11 -4
View File
@@ -27,7 +27,7 @@ test('times out a hanging request and tries the next server', async (t) => {
return ++calls === 1 ? pending(init.signal!) : Promise.resolve(ok());
});
const result = fetchOverpass(bbox);
t.mock.timers.tick(45_000);
t.mock.timers.tick(90_000);
assert.deepEqual(await result, elements);
assert.equal(calls, 2);
});
@@ -41,7 +41,7 @@ test('timeout also covers downloading the response body', async (t) => {
});
const result = fetchOverpass(bbox);
await Promise.resolve();
t.mock.timers.tick(45_000);
t.mock.timers.tick(90_000);
assert.deepEqual(await result, elements);
assert.equal(calls, 2);
});
@@ -76,11 +76,18 @@ test('reports failure when every server times out', async (t) => {
t.mock.timers.enable({ apis: ['setTimeout'] });
const fetch = t.mock.method(globalThis, 'fetch', (_url: string, init: RequestInit) => pending(init.signal!));
const result = fetchOverpass(bbox);
const check = assert.rejects(result, /Таймаут.*45 секунд/);
const check = assert.rejects(result, /Таймаут.*90 секунд/);
for (let i = 0; i < OVERPASS_ENDPOINTS.length; i++) {
t.mock.timers.tick(45_000);
t.mock.timers.tick(90_000);
await Promise.resolve();
}
await check;
assert.equal(fetch.mock.callCount(), OVERPASS_ENDPOINTS.length);
});
test('server identifies itself to Overpass rather than using the generic Node user agent', async (t) => {
t.mock.method(globalThis, 'fetch', async (_url: string, init: RequestInit) => {
assert.match(new Headers(init.headers).get('User-Agent')!, /citygen/);
return ok();
});
assert.deepEqual(await fetchOverpass(bbox), elements);
});