30 lines
1.3 KiB
TypeScript
30 lines
1.3 KiB
TypeScript
|
|
/**
|
||
|
|
* @module tests/unit/db/pad-frame-total
|
||
|
|
* @description Pad-frame construction is TOTAL: every size from the minimum
|
||
|
|
* through 4096+257 is constructible byte-exact (a production adoption found
|
||
|
|
* the msgpack class-boundary hole at 291 bytes — sync died whole, and the
|
||
|
|
* failure cascaded into a counter rewind after a successful append). Every
|
||
|
|
* constructed pad decodes as skip-by-definition filler.
|
||
|
|
*/
|
||
|
|
import { describe, it, expect } from 'vitest'
|
||
|
|
import { encodePadFrame, minPadFrameBytes, decodeGroupV2 } from '../../../src/db/factLogFormat.js'
|
||
|
|
|
||
|
|
describe('pad frames are constructible at EVERY size', () => {
|
||
|
|
it('exact construction from the minimum through a full sector + boundary spill', () => {
|
||
|
|
const min = minPadFrameBytes()
|
||
|
|
for (let size = min; size <= 4096 + 257; size++) {
|
||
|
|
const frame = encodePadFrame(size)
|
||
|
|
expect(frame.length, `size ${size}`).toBe(size)
|
||
|
|
}
|
||
|
|
})
|
||
|
|
|
||
|
|
it('the production case (291) and its class-boundary siblings decode as invisible filler', () => {
|
||
|
|
for (const size of [291, minPadFrameBytes(), 300, 511, 512, 513, 4096]) {
|
||
|
|
const frame = encodePadFrame(size)
|
||
|
|
const group = decodeGroupV2(frame)
|
||
|
|
expect(group.facts, `size ${size} is reader-invisible`).toEqual([])
|
||
|
|
expect(group.validBytes).toBe(size)
|
||
|
|
}
|
||
|
|
})
|
||
|
|
})
|