Open callebtc opened 1 year ago
I've used this testing library VCR a lot before, it's great for testing things that need to make requests where it's a pain to set up all the things you need to make requests to, or where responses can change over time making tests non-deterministic (e.g. secrets are ephemeral, tokens are invalid once spent, etc.).
It stores fixtures for responses and intercepts/monkey-patches the requesting library (works with requests, aiohttp, httpx, etc.) mocking the fixture in.
Also useful for catching regressions and unintended behaviour changes too
Maybe @xphade would be interested in this issue. Emulating Lightning with FakeWallet should work well by now!
Yes! I was pretty low on time the last couple of weeks but I would definitely like to work on the tests a bit next. So this would be something I can look into.
Here's a branch with cashu using python 3.10 and a cashu friendly version of lnbits as dependency.
https://github.com/dyKiU/cashu/tree/fake-lnbits-test
This is to avoid to a circular dependency of cashu -> lnbits -> old cashu The script tests/lnbits_env.sh sets up env for lnbits, runs poetry install and launches lnbits in the background Tests have been changed to use lightning and lnbits FakeWallet (!!! very broken still !!!)
So close to cashu tests with lighting via lnbits, until the main branch hit us with deps update. Now trying to get lnbits to use pydandic v2. This is challenging! Brain needs help https://github.com/dyKiU/cashu/tree/topic/tests_with_ln_brrr
i want lnbits with pydantic v2 aswell :) first needs lnurl lib to use it though, and i am struggling to make it happen here. https://github.com/lnbits/lnurl/pull/21
Thanks @dni, your repos made me think about a way around lnbits as a dependency using docker compose, but we actually need some of the lnbits python in the tests. The maintanance and package updates for cashu will be quite challenging with lnbits in tow.
i would rather use the lib directly https://github.com/cashubtc/cashu/pull/297 like here with the bolt11 lib
All tests right now use LIGHTNING=False (a lot easier to test things) but it would be great if some also test Lightning functions. We would have to set up an LNbits instance in the tests (with FakeWallet, i.e. not using the real Lightning network).