From c52a4c26fbcae3354ed14ce2e7c6e6fa5dc0877f Mon Sep 17 00:00:00 2001 From: callebtc <93376500+callebtc@users.noreply.github.com> Date: Fri, 12 Jul 2024 18:04:56 +0200 Subject: [PATCH] More information (#581) --- CONTRIBUTING.md | 58 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 488cd8e..6e5a3d0 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,6 +2,62 @@ Please contribute to Nutshell! You can open issues if you find bugs and pull requests for improvements. +## Contributing +Pick an issue you would like to work on. Those with the tag `good first issue` are great for getting started. When you open a pull request, make sure that you've run tests and formatting locally before you push code. + +## Setting up your environment + +We use [Poetry](https://python-poetry.org/) as a dependency and environment manager. Currently, Nutshell supports Python `3.10.4` which you can install using `pyenv` (see README.md). To install all dependencies, run `poetry install`. After install, you can activate the shell with `poetry shell`. Now you can execute `cashu --help` to use the wallet or `mint` to run the mint. + +### Precommit hook +To run the formatter and mypy (linter) before you push code, you can install the very useful pre-commit hook which will check your code every time you push with git. + +```bash +poetry run pre-commit install +``` + +## Debugging + +For more expressive debug logging, you can enable debug logs or trace-level logs (even more expressive). + +``` +DEBUG=TRUE +LOG_LEVEL=TRACE +``` + ## Testing -We are using the `black` formatter and `mypy --ignore-missing` in the CI. To make sure that your tests succeed, please run `make format` before you push code. +To run the tests, run `make test` or `pytest tests` in the poetry environment. + +### Lightning regtest + +There are many tests that also run in regtest, a simulated Lightning network environment. To run the regtest, clone [this repository](https://github.com/callebtc/cashu-regtest) and run `./start.sh`. This will start your regtest environment with several Lightning node implementations. + +You can choose one of the nodes as a backend for nutshell using the `.env` variable: +``` +# Choose one from: +# LNbitsWallet, LndRestWallet, CLNRestWallet, CoreLightningRestWallet + +MINT_BACKEND_BOLT11_SAT=FakeWallet +``` + +The Nutshell settings to connect to the provided nodes are given below + +``` +# regtest +MINT_LND_REST_ENDPOINT=https://localhost:8081 +MINT_LND_REST_CERT="../cashu-regtest-enviroment/data/lnd-3/tls.cert" +MINT_LND_REST_MACAROON="../cashu-regtest-enviroment/data/lnd-3/data/chain/bitcoin/regtest/admin.macaroon" + + +MINT_CLNREST_URL=https://localhost:3010 +MINT_CLNREST_RUNE="../cashu-regtest-enviroment/data/clightning-2/rune" +MINT_CLNREST_CERT="../cashu-regtest-enviroment/data/clightning-2/regtest/ca.pem" + +MINT_CORELIGHTNING_REST_URL=https://localhost:3001 +MINT_CORELIGHTNING_REST_MACAROON=../cashu-regtest-enviroment/data/clightning-2-rest/access.macaroon +MINT_CORELIGHTNING_REST_CERT=../cashu-regtest-enviroment/data/clightning-2-rest/certificate.pem +``` + +## Formatting +We use [Ruff](https://docs.astral.sh/ruff/formatter/) for formatting. To make sure that your tests succeed, please run `make format` before you push code. You can find the Ruff parameters in `pyproject.toml`.