397777089e
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
35 lines
1.8 KiB
JavaScript
35 lines
1.8 KiB
JavaScript
import { describe, it, expect } from 'vitest';
|
|
import { buildJudgeGo, judgeGoValidFor } from './judge-go-store.mjs';
|
|
|
|
const key = 'k-123';
|
|
|
|
describe('judge-go-store — передача GO судьи в Post-печать наставника (фикс дедлока)', () => {
|
|
it('подписанный GO валиден для своего plan_hash', () => {
|
|
const r = buildJudgeGo({ planHash: 'PH', judgedHash: 'JH', judgeMode: 'live-block', key });
|
|
expect(judgeGoValidFor(r, { planHash: 'PH', key })).toBe(true);
|
|
});
|
|
it('чужой plan_hash → невалиден (binding нах.F4)', () => {
|
|
const r = buildJudgeGo({ planHash: 'PH', judgedHash: 'JH', key });
|
|
expect(judgeGoValidFor(r, { planHash: 'OTHER', key })).toBe(false);
|
|
});
|
|
it('подделка judged_hash → невалиден (подпись не сходится)', () => {
|
|
const r = buildJudgeGo({ planHash: 'PH', judgedHash: 'JH', key });
|
|
expect(judgeGoValidFor({ ...r, judged_hash: 'FAKE' }, { planHash: 'PH', key })).toBe(false);
|
|
});
|
|
it('без ключа подпись null → невалиден (fail-closed)', () => {
|
|
const r = buildJudgeGo({ planHash: 'PH', judgedHash: 'JH', key: null });
|
|
expect(judgeGoValidFor(r, { planHash: 'PH', key })).toBe(false);
|
|
});
|
|
it('null/битая запись → false', () => {
|
|
expect(judgeGoValidFor(null, { planHash: 'PH', key })).toBe(false);
|
|
expect(judgeGoValidFor('bad', { planHash: 'PH', key })).toBe(false);
|
|
});
|
|
it('запись несёт decision:GO, wired:true, judged_hash, judge_mode', () => {
|
|
const r = buildJudgeGo({ planHash: 'PH', judgedHash: 'JH', judgeMode: 'live-block', key });
|
|
expect(r.decision).toBe('GO');
|
|
expect(r.wired).toBe(true);
|
|
expect(r.judged_hash).toBe('JH');
|
|
expect(r.judge_mode).toBe('live-block');
|
|
});
|
|
});
|