lnprototest
lnprototest copied to clipboard
Lightning BOLT Protocol Test Framework
lnprototest is a set of test helpers written in Python3, designed to make it easy to write new tests when you propose changes to the lightning network protocol, as well as test existing implementations.
Install requirements
To install the necessary dependences
pip3 install poetry
poetry shell
poetry install
Well, now we can run the test
Running test
The simplest way to run is with the "dummy" runner:
make check
Here are some other useful pytest options:
-n8to run 8-way parallel.-xto stop on the first failure.--pdbto enter the debugger on first failure.--traceto enter the debugger on every test.-k footo only run tests with 'foo' in their name.tests/test_bolt1-01-init.pyto only run tests in that file.tests/test_bolt1-01-init.py::test_initto only run that test.--log-cli-level={LEVEL_NAME}to enable the logging during the test execution.
Running Against A Real Node.
The more useful way to run is to use an existing implementation. So far, core-lightning is supported. You will need:
bitcoindinstalled, and in your path.lightningdcompiled with--enable-developer. By default the source directory should be../lightningrelative to this directory, otherwise useexport LIGHTNING_SRC=dirname.- Install any python requirements by
pip3 install -r lnprototest/clightning/requirements.txt.
Then you can run
make check PYTEST_ARGS='--runner=lnprototest.clightning.Runner'
or directly:
pytest --runner=lnprototest.clightning.Runner
Further Work
If you want to write new tests or new backends, see HACKING.md.
Let's keep the sats flowing!
Rusty.