RapidCheck property-based testing for Bitcoin Cash Node
RapidCheck performs random testing of program properties. A specification of the program is given in the form of properties which functions should satisfy, and RapidCheck tests that the properties hold in a large number of randomly generated cases.
If an exception is found, RapidCheck tries to find the smallest case, for some definition of smallest, for which the property is still false and displays it as a counter-example. For example, if the input is an integer, RapidCheck tries to find the smallest integer for which the property is false.
The following instructions have been tested with Linux Debian and macOS.
Clone the RapidCheck source code and cd into the repository.
shell git clone https://github.com/emil-e/rapidcheck.git cd rapidcheck
shell mkdir build cd build cmake -GNinja .. -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DRC_ENABLE_BOOST_TEST=ON ninja sudo ninja install/strip
Configure Bitcoin Cash Node with RapidCheck.
cdto the directory of your local Bitcoin Cash Node repository, create a build directory and run cmake:
shell mkdir build cd build cmake -GNinja .. -DENABLE_PROPERTY_BASED_TESTS=ON
In the output you should see something similar to:
shell [...] -- Found Rapidcheck: /usr/local/include -- Found Rapidcheck: /usr/local/lib/librapidcheck.a [...]
Build Bitcoin Cash Node with RapidCheck.
Now you can run
ninja checkto build and run the unit tests, including the property-based tests. You can also build and run a single test by using
That's it! You are now running property-based tests in Bitcoin Cash Node.