Skip to content

Commit 18ea246

Browse files
committed
test(integrity): guard computeHashes emits sha512 integrity + sha256 checksum
Locks the load-bearing invariant that OUR-side integrity is sha512 (the fleet convention) while checksum stays sha256 hex for upstream-SHASUMS interop. Fails loudly if a refactor downgrades the integrity algorithm.
1 parent 7ef34a5 commit 18ea246

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

test/unit/integrity.test.mts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,17 @@ describe('integrity', () => {
304304
const sri = checksumToIntegrity(checksum)
305305
expect(integrityToChecksum(sri)).toBe(checksum)
306306
})
307+
308+
it('emits integrity as sha512 (the canonical OUR-side algorithm)', () => {
309+
// Load-bearing invariant: OUR integrity values are sha512, not sha256.
310+
// The whole fleet's integrity convention depends on this. A refactor that
311+
// downgrades the integrity field would silently weaken every consumer's
312+
// pin; this assertion fails loudly if that happens.
313+
const { checksum, integrity } = computeHashes(Buffer.from('x'))
314+
expect(integrity.startsWith('sha512-')).toBe(true)
315+
// The checksum field stays sha256 hex — the upstream-SHASUMS interop shape.
316+
expect(checksum).toMatch(/^[a-f0-9]{64}$/)
317+
})
307318
})
308319

309320
describe('verifyHash', () => {

0 commit comments

Comments
 (0)