Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add unit tests for wallets (funding sources) #2363

Merged
merged 75 commits into from
Apr 8, 2024
Merged

Conversation

motorina0
Copy link
Collaborator

@motorina0 motorina0 commented Mar 26, 2024

All funding sources must behave uniformly. If, for example, the endpoint returns an HTTP 404 then all wallets api should return a Pending state. It is nok for some wallets to return a status and for others to raise an exception.

This PR creates the basis for checking the interface of all rest wallets. It currently only handles corelightingrest and lndrest, but will easily be extended.

The test data is specified in a JSON fixture. Adding new funding sources means updating the JSON.

A new dev dependency to pytest-httpserver has been added. This lib is used to simulate the LN Node rest responses.

Minor changes have been made to corelightningrest.py, lndrest.py and base.py in order to unify the interface.

This PR also closes: #2062

@motorina0 motorina0 changed the title test: add unit tests for wallets (funding dources) test: add unit tests for wallets (funding sources) Mar 26, 2024
Copy link

codecov bot commented Mar 26, 2024

Codecov Report

Attention: Patch coverage is 92.24806% with 10 lines in your changes are missing coverage. Please review.

Project coverage is 59.46%. Comparing base (2161b25) to head (15cb0b4).

Files Patch % Lines
lnbits/wallets/base.py 80.95% 4 Missing ⚠️
lnbits/wallets/corelightningrest.py 92.72% 4 Missing ⚠️
lnbits/wallets/lndrest.py 96.22% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #2363      +/-   ##
==========================================
+ Coverage   58.73%   59.46%   +0.72%     
==========================================
  Files          65       65              
  Lines        9347     9404      +57     
==========================================
+ Hits         5490     5592     +102     
+ Misses       3857     3812      -45     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

tests/wallets/test_lndrest.py Outdated Show resolved Hide resolved
@bitkarrot
Copy link
Contributor

if one of you guys has a spare moment can you please check the unit test here: #2270

thanks in advance. :)

@dni dni self-requested a review April 2, 2024 06:45
@dni dni added core Core of LNbits code health Make the code more beautiful labels Apr 2, 2024
@dni dni added this to the 0.12.5 milestone Apr 2, 2024
@dni dni marked this pull request as ready for review April 2, 2024 06:46
@dni dni requested a review from arcbtc April 2, 2024 06:46
@prusnak
Copy link
Collaborator

prusnak commented Apr 5, 2024

Needs rebase to remove conflicts in poetry.lock and pyproject.toml

@motorina0
Copy link
Collaborator Author

CI mypy/pyright failures:

tests/wallets/test_rest_wallets.py:7: error: Cannot find implementation or library stub for module named "pytest_httpserver"  [import-not-found]
tests/wallets/test_rest_wallets.py:8: error: Cannot find implementation or library stub for module named "werkzeug.wrappers"  [import-not-found]
tests/wallets/test_rest_wallets.py:8: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports

Yeah, I've pushed the rebased branch then ran again poetry add --dev pytest_httpserver. Easier this way.

@motorina0 motorina0 merged commit bfda0b6 into dev Apr 8, 2024
25 checks passed
@motorina0 motorina0 deleted the test_http_wallets branch April 8, 2024 09:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code health Make the code more beautiful core Core of LNbits
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants