-
Notifications
You must be signed in to change notification settings - Fork 37.7k
Integration of property based testing into Bitcoin Core #12775
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Strong concept ACK Very nice work! |
@Christewart I noticed that
Do you think it might be better to reference directly from "bitcoin" instead? If so, should MarcoFalke's "rapidcheck" project be added to the "bitcoin" project to facilitate this? |
@Christewart In |
We don't plan to get rid of the boost unit test framework any time soon. |
@randolf I'm not sure if it is too much of a concern right now who hosts the package. If we want to move it under the bitcoin project in the future i have no problem with that. Marco was kind enough to help me out with the setup which is why his repo is currently referenced. |
@randolf Ideally it should reference the proper upstream, but since they don't have any releases that might not work. |
Indeed. @randolf In general: please don't comment on boost usage of PRs in reviews if it concerns libraries that are already used in other parts of our code (such as boost test), only if it concerns using new boost libaries (such as lexical cast and whatnot.) |
src/test/gen/crypto_gen.cpp
Outdated
@@ -0,0 +1,23 @@ | |||
#include "test/gen/crypto_gen.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This and the .h are missing a copyright header:
// Copyright (c) 2018 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
src/test/key_properties.cpp
Outdated
@@ -0,0 +1,53 @@ | |||
// Copyright (c) 2012-2016 The Bitcoin Core developers | |||
// Distributed under the MIT software license, see the accompanying | |||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can just be:
// Copyright (c) 2018 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
$(package)_sha256_hash=9640926223c00af45bce4c7df8b756b5458a89b2ba74cfe3e404467f13ce26df | ||
|
||
define $(package)_config_cmds | ||
cmake -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=true . |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like we'll need some documentation about installing/having cmake available
Extracting rapidcheck...
/Users/xxx/GitHub/bitcoin/depends/sources/rapidcheck-10fc0cb.tar.gz: OK
Preprocessing rapidcheck...
Configuring rapidcheck...
/bin/sh: cmake: command not found
Testing 900a441 on macOS 10.13.4: After installing
Did a
You could add rapidcheck under the "Options used to compile and link:" at the end of
|
Could you set |
f90378c
to
a6df7f8
Compare
@fanquake I fixed the issue with |
f9866ef
to
4f7c64f
Compare
one build is still failing from a timeout issue it appears? I don't think it is related to this pr? |
Probably a good time to move this forward and finally get it in now that 0.17 is branched off. |
update copyright headers attempt to fix linting errors Fixing issue with make check classifying generator files as actual unit tests Wrapping gen files in ENABLE_PROPERTY_TESTS macro Make macro better
4f7c64f
to
b2f49bd
Compare
@laanwj Rebased |
RAPIDCHECK_LIBS=-lrapidcheck | ||
fi | ||
AC_SUBST(RAPIDCHECK_LIBS) | ||
AM_CONDITIONAL([ENABLE_PROPERTY_TESTS], [test x$enable_property_tests = xyes]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think something should be logged to the output depending on whether rapidcheck is used or not, currently there is nothing in configure output that suggests this
oh, just noticed in travis that without specifying explicit --with-rapidcheck
there is:
checking rapidcheck.h usability... no
checking rapidcheck.h presence... no
checking for rapidcheck.h... no
|
||
define $(package)_build_cmds | ||
$(MAKE) && \ | ||
mkdir -p $($(package)_staging_dir)$(host_prefix)/include && \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indeed, this is necessary because rapidcheck has no make install
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an open PR on the repo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that the PR is merged, should this be switched over?
I'm surprised that debian/ubuntu doesn't package |
it is not enabled in travis.yml though, is that intentional? |
ACK tested both without and with rapidcheck, and can confirm that the tests run in the latter case:
|
Frankly I haven't got that far. It's not intentional, just extra work that I don't have time to do ATM :-). |
@Christewart If you’re currently short on time, I can take this over.
…On Fri, 31 Aug 2018 at 19:57, Chris Stewart ***@***.***> wrote:
it is not enabled in travis.yml though, is that intentional?
Frankly I haven't got that far. It's not intentional, just extra work that
I don't have time to do ATM :-).
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#12775 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AA0t8vbkQrtybajNY4SDN2fDlhmUMWgNks5uWSSxgaJpZM4S58ml>
.
|
It's fine, doesn't have to be done in this PR. |
Enabling this on travis should just be setting RAPIDCHECK=1 in |
#include <rapidcheck/gen/Container.h> | ||
|
||
/** Generates 1 to 20 keys for OP_CHECKMULTISIG */ | ||
rc::Gen<std::vector<CKey>> MultisigKeys() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MultisigKeys()
seems unused? Is that intentional?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should be more careful about adding unused code like this under the expectation that it will be used in the future. YAGNI + concerns about maintaining an informative record in the code history.
…in Core b2f49bd Integration of property based testing into Bitcoin Core (Chris Stewart) Pull request description: This PR is a subset of the changes in bitcoin#8469. It's meant to be easier to review. This PR contains all of the build instructions needed for travis to pass. It includes one property call `key_properties.cpp` along with a generator file called `crypto_gen.{h,cpp}`. Tree-SHA512: 895c9d9273dcd29f696b1de8dfe1ee843095831bf1f68472844181278850bec36b20f0ba7e51e796112c5cc75cd24759f9f1771906503bbf3af16f627e18c6c9
@@ -8,6 +8,7 @@ TEST_SRCDIR = test | |||
TEST_BINARY=test/test_bitcoin$(EXEEXT) | |||
|
|||
JSON_TEST_FILES = \ | |||
test/data/script_tests.json \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this change required?
cp -a include/* $($(package)_staging_dir)$(host_prefix)/include/ && \ | ||
cp -a extras/boost_test/include/rapidcheck/* $($(package)_staging_dir)$(host_prefix)/include/rapidcheck/ && \ | ||
mkdir -p $($(package)_staging_dir)$(host_prefix)/lib && \ | ||
cp -a librapidcheck.a $($(package)_staging_dir)$(host_prefix)/lib/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might want to update to the latest rapidcheck and use the make install target?
Summary: This is an initial integration of the rapidcheck property based tests. The original test has been slightly modified to adapt to our codebase. The feature has been added to CMake and the documentation updated accordingly. Note that as opposed to autotools, which enables the test automatically if `rapidcheck` is installed, it is disabled by default with cmake and requires a flag to be set by the user. Backport of core [[bitcoin/bitcoin#12775 | PR12775]], [[bitcoin/bitcoin#16622 | PR16622]] and [[bitcoin/bitcoin#16645 | PR16645]]. Test Plan: Read the doc and install rapidcheck. ../configure Ensure that rapidcheck is used by looking at the summary. make check Ensure there is no regression: cmake -GNinja .. ninja check cmake -GNinja .. -DENABLE_PROPERTY_BASED_TESTS=ON Check in the output that `rapidcheck` is enabled by searching for a couple lines similar to: ``` -- Found Rapidcheck: /usr/local/include -- Found Rapidcheck: /usr/local/lib/librapidcheck.a ``` ninja check Assuming you are running a 64-bit Linux machine: cd depends RAPIDCHECK=1 make build-linux64 Check the `rapidcheck` package is built. cd .. && mkdir buildLinux64 && cd buildLinux64 cmake -GNinja .. \ -DCMAKE_TOOLCHAIN_FILE=../cmake/platforms/Linux64.cmake \ -DENABLE_PROPERTY_BASED_TESTS=ON Check the `rapidcheck` lib found is the one from the `depends`. ninja check Reviewers: #bitcoin_abc, jasonbcox Reviewed By: #bitcoin_abc, jasonbcox Subscribers: jasonbcox Differential Revision: https://reviews.bitcoinabc.org/D5323
Summary: This is an initial integration of the rapidcheck property based tests. The original test has been slightly modified to adapt to our codebase. The feature has been added to CMake and the documentation updated accordingly. Note that as opposed to autotools, which enables the test automatically if `rapidcheck` is installed, it is disabled by default with cmake and requires a flag to be set by the user. Backport of core [[bitcoin/bitcoin#12775 | PR12775]], [[bitcoin/bitcoin#16622 | PR16622]] and [[bitcoin/bitcoin#16645 | PR16645]]. Test Plan: Read the doc and install rapidcheck. ../configure Ensure that rapidcheck is used by looking at the summary. make check Ensure there is no regression: cmake -GNinja .. ninja check cmake -GNinja .. -DENABLE_PROPERTY_BASED_TESTS=ON Check in the output that `rapidcheck` is enabled by searching for a couple lines similar to: ``` -- Found Rapidcheck: /usr/local/include -- Found Rapidcheck: /usr/local/lib/librapidcheck.a ``` ninja check Assuming you are running a 64-bit Linux machine: cd depends RAPIDCHECK=1 make build-linux64 Check the `rapidcheck` package is built. cd .. && mkdir buildLinux64 && cd buildLinux64 cmake -GNinja .. \ -DCMAKE_TOOLCHAIN_FILE=../cmake/platforms/Linux64.cmake \ -DENABLE_PROPERTY_BASED_TESTS=ON Check the `rapidcheck` lib found is the one from the `depends`. ninja check Reviewers: #bitcoin_abc, jasonbcox Reviewed By: #bitcoin_abc, jasonbcox Subscribers: jasonbcox Differential Revision: https://reviews.bitcoinabc.org/D5323
Summary: This is an initial integration of the rapidcheck property based tests. The original test has been slightly modified to adapt to our codebase. The feature has been added to CMake and the documentation updated accordingly. Note that as opposed to autotools, which enables the test automatically if `rapidcheck` is installed, it is disabled by default with cmake and requires a flag to be set by the user. Backport of core [[bitcoin/bitcoin#12775 | PR12775]], [[bitcoin/bitcoin#16622 | PR16622]] and [[bitcoin/bitcoin#16645 | PR16645]]. Test Plan: Read the doc and install rapidcheck. ../configure Ensure that rapidcheck is used by looking at the summary. make check Ensure there is no regression: cmake -GNinja .. ninja check cmake -GNinja .. -DENABLE_PROPERTY_BASED_TESTS=ON Check in the output that `rapidcheck` is enabled by searching for a couple lines similar to: ``` -- Found Rapidcheck: /usr/local/include -- Found Rapidcheck: /usr/local/lib/librapidcheck.a ``` ninja check Assuming you are running a 64-bit Linux machine: cd depends RAPIDCHECK=1 make build-linux64 Check the `rapidcheck` package is built. cd .. && mkdir buildLinux64 && cd buildLinux64 cmake -GNinja .. \ -DCMAKE_TOOLCHAIN_FILE=../cmake/platforms/Linux64.cmake \ -DENABLE_PROPERTY_BASED_TESTS=ON Check the `rapidcheck` lib found is the one from the `depends`. ninja check Reviewers: #bitcoin_abc, jasonbcox Reviewed By: #bitcoin_abc, jasonbcox Subscribers: jasonbcox Differential Revision: https://reviews.bitcoinabc.org/D5323
This PR is a subset of the changes in #8469. It's meant to be easier to review. This PR contains all of the build instructions needed for travis to pass. It includes one property call
key_properties.cpp
along with a generator file calledcrypto_gen.{h,cpp}
.