cc1de1d6d6710f1426a957806661e7f3461a7cb5 poller: unspend coins before spending new (jp1ac4)
1e7653e08a3778446ff677bb147df68b734a31fd tests: add function to wait while condition holds (jp1ac4)
Pull request description:
This change ensures that the spend txid of a coin is updated directly to another value in case a conflicting spend is detected.
The previous order caused the spend txid to first be cleared, which would misleadingly make the coin appear as confirmed
rather than spending.
I've added a new utils function for the functional tests that is a slight generalisation of `wait_for` with an additional condition that must always be met while waiting.
`wait_for` now calls this new function with the condition being one that is always true.
ACKs for top commit:
darosior:
ACK cc1de1d6d6710f1426a957806661e7f3461a7cb5
Tree-SHA512: e3f00804a63b0e94bc1b2cbee03cac63dd6e2555ca6d301589b356b2baf8e0cf27362e1dda44018d1d8282e300b187079fcf61f5d2754263b9e8b08cd34be06e
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.