diff --git a/cmake/modules/FindRapidcheck.cmake b/cmake/modules/FindRapidcheck.cmake deleted file mode 100644 --- a/cmake/modules/FindRapidcheck.cmake +++ /dev/null @@ -1,49 +0,0 @@ -# Copyright (c) 2020 The Bitcoin developers -# Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. - -# .rst: -# FindRapidcheck -# -------------- -# -# Find the Rapidcheck library. The following conponents are -# available:: -# rapidcheck -# -# This will define the following variables:: -# -# Rapidcheck_FOUND - True if the Rapidcheck library is found. -# Rapidcheck_INCLUDE_DIRS - List of the header include directories. -# Rapidcheck_LIBRARIES - List of the libraries. -# -# And the following imported targets:: -# -# Rapidcheck::rapidcheck - -find_path(Rapidcheck_INCLUDE_DIR - NAMES rapidcheck.h - PATH_SUFFIXES rapidcheck -) - -set(Rapidcheck_INCLUDE_DIRS "${Rapidcheck_INCLUDE_DIR}") -mark_as_advanced(Rapidcheck_INCLUDE_DIR) - -# TODO: extract a version number. -# For now rapidcheck does not provide such a version number, and has no release. -# See https://github.com/emil-e/rapidcheck/issues/235 for reference. - -if(Rapidcheck_INCLUDE_DIR) - include(ExternalLibraryHelper) - find_component(Rapidcheck rapidcheck - NAMES rapidcheck - PATH_SUFFIXES rapidcheck - INCLUDE_DIRS ${Rapidcheck_INCLUDE_DIRS} - ) -endif() - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(Rapidcheck - REQUIRED_VARS - Rapidcheck_INCLUDE_DIR - HANDLE_COMPONENTS -) diff --git a/configure.ac b/configure.ac --- a/configure.ac +++ b/configure.ac @@ -140,12 +140,6 @@ [use_gui_tests=$enableval], [use_gui_tests=$use_tests]) -AC_ARG_WITH([rapidcheck], - [AS_HELP_STRING([--with-rapidcheck], - [enable RapidCheck property-based tests (default is yes if librapidcheck is found)])], - [use_rapidcheck=$withval], - [use_rapidcheck=auto]) - AC_ARG_ENABLE(bench, AS_HELP_STRING([--disable-bench],[do not compile benchmarks (default is to compile)]), [use_bench=$enableval], @@ -1113,22 +1107,6 @@ ]) CXXFLAGS="${save_CXXFLAGS}" -dnl RapidCheck property-based testing - -enable_property_tests=no -if test "x$use_rapidcheck" = xauto; then - AC_CHECK_HEADERS([rapidcheck.h], [enable_property_tests=yes]) -elif test "x$use_rapidcheck" != xno; then - enable_property_tests=yes -fi - -RAPIDCHECK_LIBS= -if test "x$enable_property_tests" = xyes; then - RAPIDCHECK_LIBS=-lrapidcheck -fi -AC_SUBST(RAPIDCHECK_LIBS) -AM_CONDITIONAL([ENABLE_PROPERTY_TESTS], [test x$enable_property_tests = xyes]) - dnl univalue check need_bundled_univalue=yes @@ -1484,7 +1462,6 @@ echo " with zmq = $use_zmq" echo " with test = $use_tests" if test x$use_tests != xno; then - echo " with prop = $enable_property_tests" echo " with fuzz = $enable_fuzz" fi echo " with bench = $use_bench" diff --git a/contrib/devtools/build_depends.sh b/contrib/devtools/build_depends.sh --- a/contrib/devtools/build_depends.sh +++ b/contrib/devtools/build_depends.sh @@ -31,6 +31,6 @@ popd -RAPIDCHECK=1 make build-all +make build-all popd diff --git a/contrib/teamcity/builds/build-linux64.sh b/contrib/teamcity/builds/build-linux64.sh --- a/contrib/teamcity/builds/build-linux64.sh +++ b/contrib/teamcity/builds/build-linux64.sh @@ -12,7 +12,6 @@ # Build, run unit tests and functional tests. CMAKE_FLAGS=( "-DCMAKE_TOOLCHAIN_FILE=${CMAKE_PLATFORMS_DIR}/Linux64.cmake" - "-DENABLE_PROPERTY_BASED_TESTS=ON" ) build_with_cmake --junit diff --git a/depends/Makefile b/depends/Makefile --- a/depends/Makefile +++ b/depends/Makefile @@ -11,7 +11,6 @@ NO_QT ?= NO_PROTOBUF ?= NO_QR ?= -RAPIDCHECK ?= NO_WALLET ?= NO_ZMQ ?= NO_UPNP ?= @@ -109,7 +108,6 @@ zmq_packages_$(NO_ZMQ) = $(zmq_packages) protobuf_packages_$(NO_PROTOBUF) = $(protobuf_packages) -rapidcheck_packages_$(RAPIDCHECK) = $(rapidcheck_packages) jemalloc_packages_$(NO_JEMALLOC) = $(jemalloc_packages) @@ -125,10 +123,6 @@ packages += $(zmq_packages) endif -ifeq ($(rapidcheck_packages_),) -packages += $(rapidcheck_packages) -endif - ifneq ($(jemalloc_packages_),) packages += $(jemalloc_packages) endif diff --git a/depends/README.md b/depends/README.md --- a/depends/README.md +++ b/depends/README.md @@ -91,7 +91,6 @@ NO_UPNP: Don't download/build/cache packages needed for enabling upnp NO_JEMALLOC: Don't download/build/cache jemalloc DEBUG: disable some optimizations and enable more runtime checking - RAPIDCHECK: build rapidcheck (experimental, requires cmake) NO_PROTOBUF: Don't download/build/cache protobuf (used for BIP70 support) HOST_ID_SALT: Optional salt to use when generating host package ids BUILD_ID_SALT: Optional salt to use when generating build package ids diff --git a/depends/packages/packages.mk b/depends/packages/packages.mk --- a/depends/packages/packages.mk +++ b/depends/packages/packages.mk @@ -9,8 +9,6 @@ qt_linux_packages:=qt expat libxcb xcb_proto libXau xproto freetype fontconfig -rapidcheck_packages = rapidcheck - qt_darwin_packages=qt qt_mingw32_packages=qt diff --git a/depends/packages/rapidcheck.mk b/depends/packages/rapidcheck.mk deleted file mode 100644 --- a/depends/packages/rapidcheck.mk +++ /dev/null @@ -1,21 +0,0 @@ -package=rapidcheck -$(package)_version=d9482c683429fe79122e3dcab14c9655874aeb8e -$(package)_download_path=https://github.com/emil-e/rapidcheck/archive -$(package)_file_name=$($(package)_version).tar.gz -$(package)_sha256_hash=b9ee8955b175fd3c0757ebd887bb075541761af08b0c28391b7c6c0685351f6b - -define $(package)_config_cmds - cmake -DCMAKE_INSTALL_PREFIX=$($(package)_staging_dir)$(host_prefix) -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=true -DRC_ENABLE_BOOST_TEST=ON -B . -endef - -define $(package)_preprocess_cmds - sed -i.old 's/ -Wall//' CMakeLists.txt -endef - -define $(package)_build_cmds - $(MAKE) -j$(JOBS) rapidcheck -endef - -define $(package)_stage_cmds - $(MAKE) rapidcheck install -endef diff --git a/doc/rapidcheck.md b/doc/rapidcheck.md deleted file mode 100644 --- a/doc/rapidcheck.md +++ /dev/null @@ -1,69 +0,0 @@ -# RapidCheck property-based testing for Bitcoin ABC - -## Concept - -Property-based testing is experimentally being added to Bitcoin ABC with -[RapidCheck](https://github.com/emil-e/rapidcheck), a C++ framework for -property-based testing inspired by the Haskell library -[QuickCheck](https://hackage.haskell.org/package/QuickCheck). - -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. - -## Setup - -The following instructions have been tested with Linux Debian and macOS. - -1. Clone the RapidCheck source code and cd into the repository. - - ```shell - git clone https://github.com/emil-e/rapidcheck.git - cd rapidcheck - ``` - -2. Build RapidCheck. - - ```shell - mkdir build - cd build - cmake -GNinja .. -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DRC_ENABLE_BOOST_TEST=ON - ninja - sudo ninja install/strip - ``` - -3. Configure Bitcoin ABC with RapidCheck. - - `cd` to the directory of your local Bitcoin ABC 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 - [...] - ``` - -4. Build Bitcoin ABC with RapidCheck. - - Now you can run `ninja check` to build and run the unit tests, including the - property-based tests. You can also build and run a single test by using - `ninja check-bitcoin-`. - - Example: `ninja check-bitcoin-key_properties` - -That's it! You are now running property-based tests in Bitcoin ABC. diff --git a/src/Makefile.test.include b/src/Makefile.test.include --- a/src/Makefile.test.include +++ b/src/Makefile.test.include @@ -233,15 +233,6 @@ test/work_comparator_tests.cpp \ rpc/test/server_tests.cpp -if ENABLE_PROPERTY_TESTS -BITCOIN_TESTS += \ - test/key_properties.cpp - -BITCOIN_TEST_SUITE += \ - test/gen/crypto_gen.cpp \ - test/gen/crypto_gen.h -endif - if ENABLE_WALLET BITCOIN_TESTS += \ wallet/test/db_tests.cpp \ @@ -271,7 +262,7 @@ $(LIBLEVELDB) $(LIBLEVELDB_SSE42) $(LIBMEMENV) $(BOOST_LIBS) $(BOOST_UNIT_TEST_FRAMEWORK_LIB) $(LIBSECP256K1) $(EVENT_LIBS) $(EVENT_PTHREADS_LIBS) test_test_bitcoin_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) -test_test_bitcoin_LDADD += $(LIBBITCOIN_CONSENSUS) $(BDB_LIBS) $(MINIUPNPC_LIBS) $(RAPIDCHECK_LIBS) +test_test_bitcoin_LDADD += $(LIBBITCOIN_CONSENSUS) $(BDB_LIBS) $(MINIUPNPC_LIBS) test_test_bitcoin_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) -static if ENABLE_ZMQ diff --git a/src/test/CMakeLists.txt b/src/test/CMakeLists.txt --- a/src/test/CMakeLists.txt +++ b/src/test/CMakeLists.txt @@ -2,8 +2,6 @@ project(bitcoin-test) -option(ENABLE_PROPERTY_BASED_TESTS "Enable property based tests" OFF) - # Process json files. file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/data") @@ -73,17 +71,6 @@ ) endif() -if(ENABLE_PROPERTY_BASED_TESTS) - find_package(Rapidcheck REQUIRED) - - set(BITCOIN_PROPERTY_BASED_TEST_FIXTURE - gen/crypto_gen.cpp - ) - set(BITCOIN_PROPERTY_BASED_TESTS - key_properties.cpp - ) -endif() - add_boost_unit_tests_to_suite(bitcoin test_bitcoin fixture.cpp jsonutil.cpp @@ -96,9 +83,6 @@ # Wallet test fixture ${BITCOIN_WALLET_TEST_FIXTURE} - # Properties based test fixture - ${BITCOIN_PROPERTY_BASED_TEST_FIXTURE} - TESTS activation_tests.cpp addrman_tests.cpp @@ -206,15 +190,8 @@ # Wallet tests ${BITCOIN_WALLET_TESTS} - - # Properties based tests - ${BITCOIN_PROPERTY_BASED_TESTS} ) -if(ENABLE_PROPERTY_BASED_TESTS) - target_link_libraries(test_bitcoin Rapidcheck::rapidcheck) -endif() - function(add_boost_test_runners_with_upgrade_activated SUITE EXECUTABLE) set(SUITE_UPGRADE_ACTIVATED "${SUITE}-upgrade-activated") get_target_from_suite(${SUITE_UPGRADE_ACTIVATED} TARGET_UPGRADE_ACTIVATED) diff --git a/src/test/gen/crypto_gen.h b/src/test/gen/crypto_gen.h deleted file mode 100644 --- a/src/test/gen/crypto_gen.h +++ /dev/null @@ -1,51 +0,0 @@ -// 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. -#ifndef BITCOIN_TEST_GEN_CRYPTO_GEN_H -#define BITCOIN_TEST_GEN_CRYPTO_GEN_H - -#include -#include -#include - -#include -#include -#include -#include - -/** Generates 1 to 15 keys for OP_CHECKMULTISIG */ -rc::Gen> MultisigKeys(); - -namespace rc { -/** Generator for a new CKey */ -template <> struct Arbitrary { - static Gen arbitrary() { - return rc::gen::map([](int x) { - CKey key; - key.MakeNewKey(true); - return key; - }); - }; -}; - -/** Generator for a CPrivKey */ -template <> struct Arbitrary { - static Gen arbitrary() { - return gen::map(gen::arbitrary(), - [](const CKey &key) { return key.GetPrivKey(); }); - }; -}; - -/** Generator for a new CPubKey */ -template <> struct Arbitrary { - static Gen arbitrary() { - return gen::map(gen::arbitrary(), - [](const CKey &key) { return key.GetPubKey(); }); - }; -}; -/** Generates a arbitrary uint256 */ -template <> struct Arbitrary { - static Gen arbitrary() { return rc::gen::just(GetRandHash()); }; -}; -} // namespace rc -#endif // BITCOIN_TEST_GEN_CRYPTO_GEN_H diff --git a/src/test/gen/crypto_gen.cpp b/src/test/gen/crypto_gen.cpp deleted file mode 100644 --- a/src/test/gen/crypto_gen.cpp +++ /dev/null @@ -1,15 +0,0 @@ -// 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. -#include - -#include -#include - -/** Generates 1 to 20 keys for OP_CHECKMULTISIG */ -rc::Gen> MultisigKeys() { - return rc::gen::suchThat(rc::gen::arbitrary>(), - [](const std::vector &keys) { - return keys.size() >= 1 && keys.size() <= 15; - }); -}; diff --git a/src/test/key_properties.cpp b/src/test/key_properties.cpp deleted file mode 100644 --- a/src/test/key_properties.cpp +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright (c) 2018-2019 The Bitcoin Core developers -// Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. -#include - -#include -#include - -#include - -#include -#include -#include - -#include -#include - -BOOST_FIXTURE_TEST_SUITE(key_properties, BasicTestingSetup) - -/** Check CKey uniqueness */ -RC_BOOST_PROP(key_uniqueness, (const CKey &key1, const CKey &key2)) { - RC_ASSERT(!(key1 == key2)); -} - -/** Verify that a private key generates the correct public key */ -RC_BOOST_PROP(key_generates_correct_pubkey, (const CKey &key)) { - CPubKey pubKey = key.GetPubKey(); - RC_ASSERT(key.VerifyPubKey(pubKey)); -} - -/** Create a CKey using the 'Set' function must give us the same key */ -RC_BOOST_PROP(key_set_symmetry, (const CKey &key)) { - CKey key1; - key1.Set(key.begin(), key.end(), key.IsCompressed()); - RC_ASSERT(key1 == key); -} - -/** - * Create a CKey, sign a piece of data with ECDSA algorithm, then verify it - * with the public key. - */ -RC_BOOST_PROP(key_sign_symmetry_ecdsa, (const CKey &key, const uint256 &hash)) { - std::vector vchSig; - key.SignECDSA(hash, vchSig, 0); - const CPubKey &pubKey = key.GetPubKey(); - RC_ASSERT(pubKey.VerifyECDSA(hash, vchSig)); -} - -/** - * Create a CKey, sign a piece of data with Schnorr algorithm, then verify it - * with the public key. - */ -RC_BOOST_PROP(key_sign_symmetry_schnorr, - (const CKey &key, const uint256 &hash)) { - std::vector vchSig; - key.SignSchnorr(hash, vchSig, 0); - const CPubKey &pubKey = key.GetPubKey(); - RC_ASSERT(pubKey.VerifySchnorr(hash, vchSig)); -} -BOOST_AUTO_TEST_SUITE_END()