Skip to content

Latest commit

 

History

History
84 lines (62 loc) · 2.6 KB

Development.md

File metadata and controls

84 lines (62 loc) · 2.6 KB

Development

Developing the library requires only a working rust environment. Integration testing and code coverage report generation require docker and docker-compose.

Running tests

In the main directory, you can run cargo test --all-features to run all the unit tests.

Running integration tests (requires docker)

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

Running fuzz tests

Some fuzz testing are implemented, check the documentation for details.

Generating code coverage report

Start by building the docker image using:

docker build . -t rust-dlc-test

Code coverage for unit tests

From the main folder run:

./scripts/generate_test_coverage.sh

This will generate a coverage report in coverage/index.html.

Code coverage for dlc-manager integration tests

From the main folder run:

./scripts/generate_integration_test_coverage.sh

The coverage report will be available at integration_coverage/index.html.

Benchmarking and profiling

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.

Benchmarking (requires rust nightly)

Some benchmarks are available for the dlc manager. To run them:

cargo +nightly bench  --features=unstable

Profiling (requires docker-compose)

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