hosted-write-eval-hints-budget-stress.test.mjs
38 lines 1.4 KB
Raw
sha256:700fafdd1afa490919f9515d660ca6e75456bcd5bb67513abcd8757a634c01f6 docs: record AIP-b SD-21 land (KN #308) Human 9 days ago
1 /**
2 * HOSTED-WRITE-EVAL hints budget — Tier 4 stress: repeated skip + budget races.
3 */
4 import { describe, it } from 'node:test';
5 import assert from 'node:assert/strict';
6 import { SCOOLING_REVIEW_TRAY_INTENT } from '../lib/hub-proposal-personal-self-apply.mjs';
7 import {
8 HOSTED_PROPOSAL_REVIEW_HINTS_INLINE_BUDGET_MS,
9 maybeScheduleHostedProposalReviewHints,
10 shouldSkipInlineReviewHintsOnCreate,
11 } from '../hub/gateway/proposal-review-hints-async.mjs';
12
13 describe('hosted review-hints budget (stress)', () => {
14 it('N self-apply skips stay cheap and consistent', async () => {
15 const N = 40;
16 const started = Date.now();
17 for (let i = 0; i < N; i++) {
18 assert.equal(
19 shouldSkipInlineReviewHintsOnCreate({ intent: SCOOLING_REVIEW_TRAY_INTENT }),
20 true,
21 );
22 await maybeScheduleHostedProposalReviewHints({
23 method: 'POST',
24 pathOnly: '/api/v1/proposals',
25 upstreamStatus: 200,
26 responseText: JSON.stringify({ proposal_id: `prop-stress-${i}` }),
27 canisterUrl: 'https://example.invalid',
28 effectiveUserId: `user-${i % 3}`,
29 actorUserId: `user-${i % 3}`,
30 vaultId: 'default',
31 hintsEnabled: true,
32 createBody: { intent: SCOOLING_REVIEW_TRAY_INTENT },
33 });
34 }
35 assert.ok(Date.now() - started < 1000);
36 assert.equal(HOSTED_PROPOSAL_REVIEW_HINTS_INLINE_BUDGET_MS, 2000);
37 });
38 });
File History 1 commit
sha256:700fafdd1afa490919f9515d660ca6e75456bcd5bb67513abcd8757a634c01f6 docs: record AIP-b SD-21 land (KN #308) Human 9 days ago