Skip to content

Tests: get, put, cp and hash keep every byte of a binary file - #127

Merged
bdbarnett merged 1 commit into
mainfrom
fix/get-null-bytes
Oct 21, 2026
Merged

bdbarnett merged 1 commit into
mainfrom
fix/get-null-bytes

Conversation

@bdbarnett

Copy link
Copy Markdown
Collaborator

A model file such as a .espdl holds every byte value and long runs of zeros. mpftp sends and receives file content through printed reprs that mpremote parses on the host, so a step that treats the content as text, or passes it through eval or compile, fails on a null byte with "source code string cannot contain null bytes".

These tests run the real CLI and sidecar commands (put, get with and without verify, get -r, cp in all three directions, hash) against a stand-in board that executes mpremote's own board-side code under CPython, and compare sha256 of a file holding all 256 byte values, 1,000 zeros in a row and noise. No board needed. They run against both mpremote versions CI installs.

I also ran put, get, get -r, cp and hash on the same kinds of files (6.7 KB, and 1.5 MB with a 4 KB run of zeros) through the desktop MicroPython and CircuitPython interpreters, and every file came back byte-exact on both. A planted bug that routes the bytes through eval makes the new tests fail with the error above.

@bdbarnett
bdbarnett merged commit b3c80a1 into main Oct 21, 2026
4 checks passed
@bdbarnett
bdbarnett deleted the fix/get-null-bytes branch October 21, 2026 18:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant