Skip to content

test: add Python unit tests and CI workflow#27

Open
dolepee wants to merge 1 commit intocirclefin:masterfrom
dolepee:test-add-python-unit-tests
Open

test: add Python unit tests and CI workflow#27
dolepee wants to merge 1 commit intocirclefin:masterfrom
dolepee:test-add-python-unit-tests

Conversation

@dolepee
Copy link

@dolepee dolepee commented Feb 7, 2026

Summary

This PR adds 30 unit tests for the Python codebase and a GitHub Actions CI workflow to run them automatically.

Problem

The repository has zero Python test coverage. The existing CI workflow only runs Foundry/Forge tests for the Solidity contracts, leaving the Python code (chainmail.py, chainlink.py) entirely untested.

Changes

Test files:

  • tests/test_chainmail.py — 15 tests covering:

    • get_content_string(): valid roundtrip, unicode, empty input, invalid base64/zlib error handling
    • get_verification_url(): URL format, parameter encoding, roundtrip with get_content_string()
    • modify_signature_header(): replacement, no-match passthrough
    • PGP_sign_message() and verify_signature(): GPG calls (mocked)
    • send_email(): end-to-end integration with mocked GPG
    • email_send_message(): stub behavior
  • tests/test_chainlink.py — 15 tests covering:

    • hash(), hash_email_address(), hash_message(): determinism, case-insensitivity, whitespace normalization
    • parse_cast_send_output(): success/failure parsing of cast send output
    • is_cast_and_send_succeed(): boolean result verification
    • get_chainmail_address(): missing file and existing file scenarios

CI workflow:

  • .github/workflows/python-tests.yml — runs pytest tests/ -v on push/PR to master across Python 3.10, 3.11, and 3.12

Dependencies:

  • Added pytest and pytest-mock to requirements.txt

Design decisions

  • External dependencies (GPG, blockchain/cast, filesystem) are mocked to keep tests fast and isolated
  • Tests use pytest class-based grouping for readability
  • The CI matrix covers three Python versions for broad compatibility

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments