test: sealed_file_wrong_size_is_an_error_test fails 1 run in 256 (a random key ending in a newline is read as 19 bytes) #13

Open
opened 2026-12-02 09:47:52 +00:00 by neptunus · 0 comments
Member

Purpose (test fix): sealed_file_wrong_size_is_an_error_test passes on every run, not on 255 runs in 256.

Found on reckon-db#11's PR run 6740 (job 27542, commit 46222e0). The same commit's push run, 6741, was green. eunit reported 1 failure in 712:

reckon_db_integrity_key_tests: sealed_file_wrong_size_is_an_error_test...*failed*
{assertMatch, ... {pattern,"{ error , { integrity_key_invalid_size , 20 } }"},
                  {value,{error,{integrity_key_invalid_size,19}}}}

Cause: the test writes crypto:strong_rand_bytes(20) as the sealed file (test/unit/reckon_db_integrity_key_tests.erl:196). The loader strips one trailing newline (strip_trailing_newline/1, src/reckon_db_integrity_key.erl:212), so when the last random byte is \n (1 in 256) the key reads back as 19 bytes. The loader is right: a sealed file written with echo ends in a newline. The test's input is wrong.

Done when

  1. The test's too-short key cannot end in \n. For example, 20 fixed bytes, or random bytes with the last byte forced to a non-newline, still asserting {integrity_key_invalid_size, 20}.
  2. The test is not changed to accept 19.
Purpose (test fix): `sealed_file_wrong_size_is_an_error_test` passes on every run, not on 255 runs in 256. Found on reckon-db#11's PR run 6740 (job 27542, commit 46222e0). The same commit's push run, 6741, was green. eunit reported 1 failure in 712: ``` reckon_db_integrity_key_tests: sealed_file_wrong_size_is_an_error_test...*failed* {assertMatch, ... {pattern,"{ error , { integrity_key_invalid_size , 20 } }"}, {value,{error,{integrity_key_invalid_size,19}}}} ``` Cause: the test writes `crypto:strong_rand_bytes(20)` as the sealed file (`test/unit/reckon_db_integrity_key_tests.erl:196`). The loader strips one trailing newline (`strip_trailing_newline/1`, `src/reckon_db_integrity_key.erl:212`), so when the last random byte is `\n` (1 in 256) the key reads back as 19 bytes. The loader is right: a sealed file written with `echo` ends in a newline. The test's input is wrong. ## Done when 1. The test's too-short key cannot end in `\n`. For example, 20 fixed bytes, or random bytes with the last byte forced to a non-newline, still asserting `{integrity_key_invalid_size, 20}`. 2. The test is not changed to accept 19.
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
reckon-db-org/reckon-db#13
No description provided.