Developing the library requires only a working rust environment.
Integration testing and code coverage report generation require docker
and docker-compose
.
In the main directory, you can run cargo test --all-features
to run all the unit tests.
In the dlc
or dlc-manager
directory, run ../scripts/start_node.sh
to start a bitcoind instance.
Then run
cargo test --ignored test_name
replacing test_name
with the test you want to run.
For example within the dlc-manager
folder:
cargo test --ignored two_of_five_oracle_numerical_test
Some fuzz testing are implemented, check the documentation for details.
Start by building the docker image using:
docker build . -t rust-dlc-test
From the main folder run:
./scripts/generate_test_coverage.sh
This will generate a coverage report in coverage/index.html
.
From the main folder run:
./scripts/generate_integration_test_coverage.sh
The coverage report will be available at integration_coverage/index.html
.
At the moment the bottlenecks are mainly the adaptor signature verification and signing for numerical outcome DLC with a relatively large number of CETs. However it can sometimes be useful to have a look at benchmarks and do some profiling.
Some benchmarks are available for the dlc manager. To run them:
cargo +nightly bench --features=unstable
To profile integration tests using perf, run the following commands from the project's root folder:
# build the docker image
docker build . -t rust-dlc-test
# start a bitcoind instance
docker-compose run -d bitcoind
# get into the tester container
docker-compose run tester bash
# profile an integration test (change the name of the test with the one you want)
perf record -g ./target/debug/deps/manager_execution_tests-2a19999c47ed3cfb --ignored three_of_three_oracle_numerical_test
# get FlameGraph and generate a flame graph
git clone https://github.com/brendangregg/FlameGraph
perf script | ./FlameGraph/stackcollapse-perf.pl > out.perf-folded
./FlameGraph/flamegraph.pl out.perf-folded > rust-perf.svg
# from another terminal recover the generated svg
docker exec containerid cat /app/rust-perf.svg > ./rust-perf.svg