test(refactor): [BASE-01] freeze published core and chapter baselines

This commit is contained in:
Harvey Zhao committed 2026-09-10 18:36:02 +08:00
1 parent 7a5354e356
commit 1d705b3056
10 files changed
+454 -7

No files matched your search

+11
View File
@@ -0,0 +1,11 @@
import assert from 'node:assert/strict'
import { test } from 'node:test'
import { hash, verifyIntegrity } from './releases.mjs'
test('release integrity rejects corrupted bytes and inconsistent frozen digests', () => {
const bytes = Buffer.from('known release artifact')
const release = { name: 'fixture', integrity: `sha512-${hash(bytes, 'sha512', 'base64')}`, sha256: hash(bytes) }
assert.doesNotThrow(() => verifyIntegrity(bytes, release))
assert.throws(() => verifyIntegrity(Buffer.from('replaced artifact'), release), /Integrity mismatch/)
assert.throws(() => verifyIntegrity(bytes, { ...release, sha256: '0'.repeat(64) }), /Archive hash mismatch/)
})