Add a first batch of non regression tests#164
Open
mruiz-ledger wants to merge 5 commits intodevelopfrom
Open
Conversation
2e1cd5f to
7e40060
Compare
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Run UPDATE_SNAPSHOTS=1 pytest to regenerate fixtures after an intentional APDU change. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This pull request adds an initial suite of non-regression tests for ledgerblue, including snapshot (“golden”) APDU comparisons for loadApp offline mode, plus CI wiring to run pytest (with coverage) across supported Python versions.
Changes:
- Add pytest-based unit/integration tests for
hexParser,hexLoader, andloadApp(offline/APDU snapshot testing). - Add shared test fixtures that download a known app-boilerplate ELF release and convert it to Intel HEX (cached under
tests/.cache). - Enable pytest + coverage in
pyproject.tomland run tests in GitHub Actions CI.
Reviewed changes
Copilot reviewed 23 out of 27 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/test_smoke.py | Adds a minimal smoke test verifying the package imports and exposes a version string. |
| tests/test_load_app.py | Adds offline loadApp snapshot tests and smoke coverage for several CLI argument combinations. |
| tests/test_hex_parser.py | Adds unit tests for Intel HEX parsing/printing helpers and round-trip behavior. |
| tests/test_hex_loader.py | Adds APDU-level tests for HexLoader, including secure wrap/unwrap round-trips. |
| tests/fixtures/ref_signature.apdu | Adds/updates a golden APDU reference for signature handling. |
| tests/fixtures/ref_nocrc.apdu | Adds/updates a golden APDU reference for --nocrc. |
| tests/fixtures/ref_installparams_size.apdu | Adds/updates a golden APDU reference for install params sizing. |
| tests/conftest.py | Introduces session fixtures that fetch and cache boilerplate ELF→HEX test inputs. |
| README.md | Documents how to run tests and how to update golden APDU snapshots. |
| pyproject.toml | Adds dev test dependencies + pytest/coverage configuration defaults. |
| .gitignore | Ignores coverage output and the tests cache directory. |
| .github/workflows/ci.yml | Updates CI to install dev extras and run pytest across multiple Python versions. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+85
to
+87
| Run the test suite with: | ||
|
|
||
| ```bash |
Comment on lines
+99
to
+102
| ``` | ||
|
|
||
| The updated `tests/fixtures/minimal_reference.apdu` should then be committed alongside the code change so the diff in the reference file documents exactly what changed at the wire level. | ||
|
|
| out = tmp_path / "out.hex" | ||
| printer.writeTo(str(out)) | ||
| content = out.read_text() | ||
| assert "030000" in content.lower() or content.startswith(":") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.