test(encryption): make tamper tests deterministic #262
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
track:api
track:auto
track:core
track:deploy
track:infra
track:ui
v0.1.0
v0.1.1
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
barrettruth/delta!262
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/encryption-test-deterministic-tampering"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The two tampered-input tests in
tests/core/encryption.test.ts(fails to decrypt tampered ciphertextandfails to decrypt tampered auth tag) built their tampered byte by replacing the last hex byte with the literalff. When the original last byte was already0xff— ~1/256 of encrypts, since the per-encrypt random IV cascades through AES-256-GCM into a random ciphertext + auth tag — the "tamper" was a no-op, decrypt succeeded, and the test failed withexpected [Function] to throw an error. Combined per-vitest-run flake rate was1 - (255/256)^2 ≈ 0.78%, which is what bit the migration commit8eb1d7a8.Fix is to pick the replacement byte based on the original:
ffif the original last byte was anything else,00if it was alreadyff. Either way the byte is meaningfully altered so the decrypt rejects the bad input and the test asserts what it intends.Verification: 500 consecutive vitest runs of
tests/core/encryption.test.tspost-fix — 0 failures (pre-fix expectation was ~4 failures at the 0.78% rate).nix develop .#ci --command just cigreen locally.