This pull request is a proof of concept for introducting property based testing into Bitcoin Core
In QuickCheck the programmer writes assertions about logical properties that a function should fulfill. Then QuickCheck attempts to generate a test case that falsifies these assertions. Once such a test case is found, QuickCheck tries to reduce it to a minimal failing subset by removing or simplifying input data that are not needed to make the test fail.
This has been very useful for a Bitcoin library I’ve been working on and thought it would be worthwhile to develop a POC for Bitcoin Core. The property based library I am using for C++ is called rapidcheck. Here are the docs.
This pull request currently contains two properties, one testing CKey
generation and the other testing serialization symmetry for CKey
and CBitcoinSecret
. These are rather trivial properties, but useful for illustrating the power of property based testing if there was a bug inside of Core.
I want to solicit some feedback from developers if this is something that would actually be merged into Core. Eventually we could have a large library of generators that would allow us to quickly prototype, test, and reason about the behavior of new code added to Core. Here is an example of a library of generators (in Scala) that could give you a little more of an idea of what I am talking about.
Thoughts?