nutshell icon indicating copy to clipboard operation
nutshell copied to clipboard

[Mint] Write test pipeline with `LIGHTNING=True`

Open callebtc opened this issue 2 years ago • 8 comments

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).

callebtc avatar Mar 05 '23 10:03 callebtc

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

AngusP avatar May 18 '23 22:05 AngusP

Maybe @xphade would be interested in this issue. Emulating Lightning with FakeWallet should work well by now!

callebtc avatar Jun 29 '23 10:06 callebtc

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.

xphade avatar Jul 04 '23 21:07 xphade

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 !!!)

dyKiU avatar Aug 03 '23 07:08 dyKiU

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

dyKiU avatar Aug 28 '23 19:08 dyKiU

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

dni avatar Aug 29 '23 05:08 dni

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.

dyKiU avatar Aug 29 '23 07:08 dyKiU

i would rather use the lib directly https://github.com/cashubtc/cashu/pull/297 like here with the bolt11 lib

dni avatar Aug 29 '23 08:08 dni