Antoine Poinsot 08223c0ded
Merge #497: Add instructions to build daemon for testing
d337568706c5e6070d05d378392e74d590438f0b Add instructions to build deamon for testing (Novo)

Pull request description:

  @darosior  I tried following the testing instructions and I got an error that indicated that the `target/debug` directory did not exist. This PR adds instructions that specifically ask devs to build the project before testing. I think this will be helpful to others when trying to run the tests.

ACKs for top commit:
  darosior:
    ACK d337568706c5e6070d05d378392e74d590438f0b -- Thank you for improving the documentation.

Tree-SHA512: 9ba9c141de13f30128497734f231df6763713e18d5d0e6f2d92cdd3f3d3ca0490755760ecb0b7375a067365156a781e4d42ce07da337cbda594b39855adc2e69
2023-05-12 10:50:24 +02:00
..
2023-05-11 11:44:57 +02:00

Lianad blackbox tests

Here we test lianad by starting it on a regression testing Bitcoin network, and by then talking to it as an user would, from the outside.

Python scripts are used for the automation, and specifically the pytest framework.

Credits: this test framework was taken and adapted from revaultd, which was itself adapted from C-lightning's test framework.

Building the project for testing

To run the tests, we must build the debug version of lianad. Follow the instructions at doc/BUILD.md but instead of running

$ cargo build --release

Run

$ cargo build

to build the daemon for testing.
The lianad and liana-cli binaries will be in the target/debug directory at the root of the repository.

Test dependencies

Functional tests dependencies can be installed using pip. Use a virtual environment.

# Create a new virtual environment, preferably.
python3 -m venv venv
. venv/bin/activate
# Get the deps
pip install -r tests/requirements.txt

Additionaly you need to have bitcoind installed on your computer, please refer to bitcoincore for installation. You may use a specific bitcoind binary by specifying the BITCOIND_PATH env var.

Running the tests

From the root of the repository:

pytest tests/

Tips and tricks

Logging

We use the Live Logging functionality from pytest. It is configured in (pyproject.toml)[../pyproject.toml] to output INFO-level to the console. If a test fails, the entire DEBUG log is output.

You can override the config at runtime with the --log-cli-level option:

pytest -vvv --log-cli-level=DEBUG -k test_startup

Note that we record all logs from daemons, and we start them with log_level = "debug".

Test lints

Just use black.

More

See the environment variables in test_framework/utils.py.