Skip to content

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)

- Added  and  to
- Created  with standard fee fixtures
- Created  with unit tests for fee band logic covers:
  - Stuck vs Non-stuck discount application
  - New channel safeguard
  - Premium application
- Added GitHub Actions workflow
@TrezorHannes TrezorHannes self-assigned this Jan 14, 2026
@TrezorHannes TrezorHannes added the enhancement New feature or request label Jan 14, 2026
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @TrezorHannes, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the project's quality assurance by establishing a robust testing framework. It introduces unit tests for key components, specifically fee_adjuster.py and Magma/magma_sale_process.py, to ensure their core functionalities and external interactions behave as expected. The integration of these tests into GitHub Actions provides an automated continuous integration pipeline, which will help catch regressions early and maintain code stability.

Highlights

  • Testing Infrastructure: Introduced a comprehensive testing infrastructure using pytest and pytest-mock to improve code reliability and maintainability.
  • Unit Tests for Fee Adjuster: Added unit tests for fee_adjuster.py to validate the logic for stuck channel discounts and premium applications.
  • Unit Tests for Magma Sale Process: Implemented unit tests for Magma/magma_sale_process.py, covering order handling, Amboss API interactions, and LND integration, with extensive mocking of external dependencies.
  • Continuous Integration: Configured GitHub Actions to automatically run the newly added test suite on every Pull Request, ensuring automated quality checks.
  • Documentation Update: Updated fee_adjuster.md with clear instructions on how to set up and run the test suite locally.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Ignored Files
  • Ignored by pattern: .github/workflows/** (1)
    • .github/workflows/tests.yml
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a comprehensive testing infrastructure using pytest and pytest-mock, which is a significant step towards improving code quality and reliability. The addition of unit tests for fee_adjuster.py and Magma/magma_sale_process.py, along with CI configuration, is highly commendable. The documentation update for fee_adjuster.md is also a good addition, providing clear instructions for running the new test suite. The tests cover important logic and edge cases, demonstrating a thorough approach to verification.

- tests/Magma: switch to pytest style, use fixtures for mocking, stricter args checks
- infra: add pyproject.toml, remove sys.path hacks
- docs: update fee_adjuster.md
@TrezorHannes TrezorHannes merged commit aa258b3 into main Jan 14, 2026
3 checks passed
@TrezorHannes TrezorHannes deleted the feat/test-suite-infrastructure branch January 14, 2026 19:12
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.

2 participants