Skip to content

Feat/test suite infrastructure#32

Merged
TrezorHannes merged 4 commits intomainfrom
feat/test-suite-infrastructure
Jan 14, 2026
Merged

Feat/test suite infrastructure#32
TrezorHannes merged 4 commits intomainfrom
feat/test-suite-infrastructure

Conversation

@TrezorHannes
Copy link
Owner

PR: Add Testing Suite Infrastructure

Summary of Changes

  • Introduced a comprehensive testing infrastructure using pytest and pytest-mock.
  • Added unit tests for fee_adjuster.py (focusing on the recent "stuck channel" fix).
  • Added unit tests for Magma/magma_sale_process.py (focusing on order handling and LND integration).
  • Configured GitHub Actions to automatically run tests on every Pull Request.
  • Updated documentation (fee_adjuster.md) with testing instructions.

Detailed Changes

  • Infrastructure:
    • requirements-dev.txt: Added pytest, pytest-mock, requests-mock.
    • tests/conftest.py: Added shared fixtures for fee configuration.
    • .github/workflows/tests.yml: New CI workflow.
  • Other/fee_adjuster.py:
    • Validated logic for stuck channel discounts and premium application via tests/test_fee_adjuster.py.
  • Magma/magma_sale_process.py:
    • Validated accept_order, reject_order, execute_lnd_command, and execute_lncli_addinvoice via tests/Magma/test_magma_sale_process.py.
    • Utilized sys.modules patching to mock global side-effects (telebot, configparser).

Testing Strategy

  • Unit Tests:
    • Fee Adjuster: Verified the core mathematical logic for fee bands, ensuring discounts are gated correctly by stuck status.
    • Magma: Verified API interactions and shell command parsing. Mocked all external dependencies (Amboss API, LND CLI, Telegram, Config) to ensure tests are fast, reliable, and run in isolation.
  • Verification Result: 12/12 tests passing locally ✅.

What's Left for Later

  • Expand test coverage to LNDg/ scripts (e.g., amboss_pull.py, channel_base-fee.py).
  • Add integration tests if a mock LND node environment becomes available.

Checklist

  • Code follows project conventions
  • All tests passing locally
  • Documentation updated (fee_adjuster.md)

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

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant