mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-02 09:46:52 -05:00
test: remove rapidcheck integration and tests
This commit is contained in:
parent
08c4994969
commit
9e071b0089
12 changed files with 3 additions and 281 deletions
|
@ -12,7 +12,7 @@ Quick Start
|
||||||
The minimal steps required to build Bitcoin Core with the msbuild toolchain are below. More detailed instructions are contained in the following sections.
|
The minimal steps required to build Bitcoin Core with the msbuild toolchain are below. More detailed instructions are contained in the following sections.
|
||||||
|
|
||||||
```
|
```
|
||||||
vcpkg install --triplet x64-windows-static berkeleydb boost-filesystem boost-multi-index boost-signals2 boost-test boost-thread libevent[thread] rapidcheck zeromq double-conversion
|
vcpkg install --triplet x64-windows-static berkeleydb boost-filesystem boost-multi-index boost-signals2 boost-test boost-thread libevent[thread] zeromq double-conversion
|
||||||
vcpkg integrate install
|
vcpkg integrate install
|
||||||
py -3 build_msvc\msvc-autogen.py
|
py -3 build_msvc\msvc-autogen.py
|
||||||
msbuild /m build_msvc\bitcoin.sln /p:Platform=x64 /p:Configuration=Release /t:build
|
msbuild /m build_msvc\bitcoin.sln /p:Platform=x64 /p:Configuration=Release /t:build
|
||||||
|
@ -35,7 +35,6 @@ The [external dependencies](https://github.com/bitcoin/bitcoin/blob/master/doc/d
|
||||||
- DoubleConversion
|
- DoubleConversion
|
||||||
- libevent
|
- libevent
|
||||||
- Qt5
|
- Qt5
|
||||||
- RapidCheck
|
|
||||||
- ZeroMQ
|
- ZeroMQ
|
||||||
|
|
||||||
Qt
|
Qt
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
berkeleydb boost-filesystem boost-multi-index boost-signals2 boost-test boost-thread libevent[thread] rapidcheck zeromq double-conversion
|
berkeleydb boost-filesystem boost-multi-index boost-signals2 boost-test boost-thread libevent[thread] zeromq double-conversion
|
23
configure.ac
23
configure.ac
|
@ -134,12 +134,6 @@ AC_ARG_ENABLE(gui-tests,
|
||||||
[use_gui_tests=$enableval],
|
[use_gui_tests=$enableval],
|
||||||
[use_gui_tests=$use_tests])
|
[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,
|
AC_ARG_ENABLE(bench,
|
||||||
AS_HELP_STRING([--disable-bench],[do not compile benchmarks (default is to compile)]),
|
AS_HELP_STRING([--disable-bench],[do not compile benchmarks (default is to compile)]),
|
||||||
[use_bench=$enableval],
|
[use_bench=$enableval],
|
||||||
|
@ -1327,22 +1321,6 @@ else
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
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
|
dnl univalue check
|
||||||
|
|
||||||
need_bundled_univalue=yes
|
need_bundled_univalue=yes
|
||||||
|
@ -1679,7 +1657,6 @@ fi
|
||||||
echo " with zmq = $use_zmq"
|
echo " with zmq = $use_zmq"
|
||||||
echo " with test = $use_tests"
|
echo " with test = $use_tests"
|
||||||
if test x$use_tests != xno; then
|
if test x$use_tests != xno; then
|
||||||
echo " with prop = $enable_property_tests"
|
|
||||||
echo " with fuzz = $enable_fuzz"
|
echo " with fuzz = $enable_fuzz"
|
||||||
fi
|
fi
|
||||||
echo " with bench = $use_bench"
|
echo " with bench = $use_bench"
|
||||||
|
|
|
@ -10,7 +10,6 @@ BASE_CACHE ?= $(BASEDIR)/built
|
||||||
SDK_PATH ?= $(BASEDIR)/SDKs
|
SDK_PATH ?= $(BASEDIR)/SDKs
|
||||||
NO_QT ?=
|
NO_QT ?=
|
||||||
NO_QR ?=
|
NO_QR ?=
|
||||||
RAPIDCHECK ?=
|
|
||||||
NO_WALLET ?=
|
NO_WALLET ?=
|
||||||
NO_ZMQ ?=
|
NO_ZMQ ?=
|
||||||
NO_UPNP ?=
|
NO_UPNP ?=
|
||||||
|
@ -109,8 +108,6 @@ wallet_packages_$(NO_WALLET) = $(wallet_packages)
|
||||||
upnp_packages_$(NO_UPNP) = $(upnp_packages)
|
upnp_packages_$(NO_UPNP) = $(upnp_packages)
|
||||||
zmq_packages_$(NO_ZMQ) = $(zmq_packages)
|
zmq_packages_$(NO_ZMQ) = $(zmq_packages)
|
||||||
|
|
||||||
rapidcheck_packages_$(RAPIDCHECK) = $(rapidcheck_packages)
|
|
||||||
|
|
||||||
packages += $($(host_arch)_$(host_os)_packages) $($(host_os)_packages) $(qt_packages_) $(wallet_packages_) $(upnp_packages_)
|
packages += $($(host_arch)_$(host_os)_packages) $($(host_os)_packages) $(qt_packages_) $(wallet_packages_) $(upnp_packages_)
|
||||||
native_packages += $($(host_arch)_$(host_os)_native_packages) $($(host_os)_native_packages)
|
native_packages += $($(host_arch)_$(host_os)_native_packages) $($(host_os)_native_packages)
|
||||||
|
|
||||||
|
@ -118,10 +115,6 @@ ifneq ($(zmq_packages_),)
|
||||||
packages += $(zmq_packages)
|
packages += $(zmq_packages)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(rapidcheck_packages_),)
|
|
||||||
packages += $(rapidcheck_packages)
|
|
||||||
endif
|
|
||||||
|
|
||||||
all_packages = $(packages) $(native_packages)
|
all_packages = $(packages) $(native_packages)
|
||||||
|
|
||||||
meta_depends = Makefile funcs.mk builders/default.mk hosts/default.mk hosts/$(host_os).mk builders/$(build_os).mk
|
meta_depends = Makefile funcs.mk builders/default.mk hosts/default.mk hosts/$(host_os).mk builders/$(build_os).mk
|
||||||
|
|
|
@ -92,7 +92,6 @@ The following can be set when running make: make FOO=bar
|
||||||
NO_WALLET: Don't download/build/cache libs needed to enable the wallet
|
NO_WALLET: Don't download/build/cache libs needed to enable the wallet
|
||||||
NO_UPNP: Don't download/build/cache packages needed for enabling upnp
|
NO_UPNP: Don't download/build/cache packages needed for enabling upnp
|
||||||
DEBUG: disable some optimizations and enable more runtime checking
|
DEBUG: disable some optimizations and enable more runtime checking
|
||||||
RAPIDCHECK: build rapidcheck (experimental, requires cmake)
|
|
||||||
HOST_ID_SALT: Optional salt to use when generating host package ids
|
HOST_ID_SALT: Optional salt to use when generating host package ids
|
||||||
BUILD_ID_SALT: Optional salt to use when generating build package ids
|
BUILD_ID_SALT: Optional salt to use when generating build package ids
|
||||||
|
|
||||||
|
|
|
@ -7,8 +7,6 @@ qrencode_packages = qrencode
|
||||||
qt_linux_packages:=qt expat libxcb xcb_proto libXau xproto freetype fontconfig
|
qt_linux_packages:=qt expat libxcb xcb_proto libXau xproto freetype fontconfig
|
||||||
qt_android_packages=qt
|
qt_android_packages=qt
|
||||||
|
|
||||||
rapidcheck_packages = rapidcheck
|
|
||||||
|
|
||||||
qt_darwin_packages=qt
|
qt_darwin_packages=qt
|
||||||
qt_mingw32_packages=qt
|
qt_mingw32_packages=qt
|
||||||
|
|
||||||
|
|
|
@ -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) rapidcheck
|
|
||||||
endef
|
|
||||||
|
|
||||||
define $(package)_stage_cmds
|
|
||||||
$(MAKE) rapidcheck install
|
|
||||||
endef
|
|
|
@ -1,84 +0,0 @@
|
||||||
# RapidCheck property-based testing for Bitcoin Core
|
|
||||||
|
|
||||||
## Concept
|
|
||||||
|
|
||||||
Property-based testing is experimentally being added to Bitcoin Core 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.
|
|
||||||
|
|
||||||
## Running
|
|
||||||
|
|
||||||
If RapidCheck is installed, Bitcoin Core will automatically run the
|
|
||||||
property-based tests with the unit tests during `make check`, unless the
|
|
||||||
`--without-rapidcheck` flag is passed when configuring.
|
|
||||||
|
|
||||||
For more information, run `./configure --help` and see `--with-rapidcheck` under
|
|
||||||
Optional Packages.
|
|
||||||
|
|
||||||
## 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 (requires CMake to be installed).
|
|
||||||
|
|
||||||
```shell
|
|
||||||
cmake -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=true -DRC_ENABLE_BOOST_TEST=ON $(pwd)
|
|
||||||
make && make install
|
|
||||||
```
|
|
||||||
|
|
||||||
3. Configure Bitcoin Core with RapidCheck.
|
|
||||||
|
|
||||||
`cd` to the directory of your local bitcoin repository and run
|
|
||||||
`./configure`. In the output you should see:
|
|
||||||
|
|
||||||
```shell
|
|
||||||
checking rapidcheck.h usability... yes
|
|
||||||
checking rapidcheck.h presence... yes
|
|
||||||
checking for rapidcheck.h... yes
|
|
||||||
[...]
|
|
||||||
Options used to compile and link:
|
|
||||||
[...]
|
|
||||||
with test = yes
|
|
||||||
with prop = yes
|
|
||||||
```
|
|
||||||
|
|
||||||
4. Build Bitcoin Core with RapidCheck.
|
|
||||||
|
|
||||||
Now you can run `make` and should see the property-based tests compiled with
|
|
||||||
the unit tests:
|
|
||||||
|
|
||||||
```shell
|
|
||||||
Making all in src
|
|
||||||
[...]
|
|
||||||
CXX test/gen/test_bitcoin-crypto_gen.o
|
|
||||||
CXX test/test_bitcoin-key_properties.o
|
|
||||||
```
|
|
||||||
|
|
||||||
5. Run the unit tests with `make check`. The property-based tests will be run
|
|
||||||
with the unit tests.
|
|
||||||
|
|
||||||
```shell
|
|
||||||
Running tests: crypto_tests from test/crypto_tests.cpp
|
|
||||||
[...]
|
|
||||||
Running tests: key_properties from test/key_properties.cpp
|
|
||||||
```
|
|
||||||
|
|
||||||
That's it! You are now running property-based tests in Bitcoin Core.
|
|
|
@ -245,15 +245,6 @@ BITCOIN_TESTS =\
|
||||||
test/validation_flush_tests.cpp \
|
test/validation_flush_tests.cpp \
|
||||||
test/versionbits_tests.cpp
|
test/versionbits_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
|
if ENABLE_WALLET
|
||||||
BITCOIN_TESTS += \
|
BITCOIN_TESTS += \
|
||||||
wallet/test/db_tests.cpp \
|
wallet/test/db_tests.cpp \
|
||||||
|
@ -283,7 +274,7 @@ test_test_bitcoin_LDADD += $(LIBBITCOIN_SERVER) $(LIBBITCOIN_CLI) $(LIBBITCOIN_C
|
||||||
$(LIBLEVELDB) $(LIBLEVELDB_SSE42) $(LIBMEMENV) $(BOOST_LIBS) $(BOOST_UNIT_TEST_FRAMEWORK_LIB) $(LIBSECP256K1) $(EVENT_LIBS) $(EVENT_PTHREADS_LIBS)
|
$(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_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
|
||||||
|
|
||||||
test_test_bitcoin_LDADD += $(BDB_LIBS) $(MINIUPNPC_LIBS) $(RAPIDCHECK_LIBS)
|
test_test_bitcoin_LDADD += $(BDB_LIBS) $(MINIUPNPC_LIBS)
|
||||||
test_test_bitcoin_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) -static
|
test_test_bitcoin_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) -static
|
||||||
|
|
||||||
if ENABLE_ZMQ
|
if ENABLE_ZMQ
|
||||||
|
|
|
@ -1,19 +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 <test/gen/crypto_gen.h>
|
|
||||||
|
|
||||||
#include <key.h>
|
|
||||||
|
|
||||||
#include <rapidcheck/gen/Arbitrary.h>
|
|
||||||
#include <rapidcheck/Gen.h>
|
|
||||||
#include <rapidcheck/gen/Predicate.h>
|
|
||||||
#include <rapidcheck/gen/Container.h>
|
|
||||||
|
|
||||||
/** Generates 1 to 20 keys for OP_CHECKMULTISIG */
|
|
||||||
rc::Gen<std::vector<CKey>> MultisigKeys()
|
|
||||||
{
|
|
||||||
return rc::gen::suchThat(rc::gen::arbitrary<std::vector<CKey>>(), [](const std::vector<CKey>& keys) {
|
|
||||||
return keys.size() >= 1 && keys.size() <= 15;
|
|
||||||
});
|
|
||||||
};
|
|
|
@ -1,63 +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 <key.h>
|
|
||||||
#include <random.h>
|
|
||||||
#include <uint256.h>
|
|
||||||
#include <rapidcheck/gen/Arbitrary.h>
|
|
||||||
#include <rapidcheck/Gen.h>
|
|
||||||
#include <rapidcheck/gen/Create.h>
|
|
||||||
#include <rapidcheck/gen/Numeric.h>
|
|
||||||
|
|
||||||
/** Generates 1 to 15 keys for OP_CHECKMULTISIG */
|
|
||||||
rc::Gen<std::vector<CKey>> MultisigKeys();
|
|
||||||
|
|
||||||
namespace rc
|
|
||||||
{
|
|
||||||
/** Generator for a new CKey */
|
|
||||||
template <>
|
|
||||||
struct Arbitrary<CKey> {
|
|
||||||
static Gen<CKey> arbitrary()
|
|
||||||
{
|
|
||||||
return rc::gen::map<int>([](int x) {
|
|
||||||
CKey key;
|
|
||||||
key.MakeNewKey(true);
|
|
||||||
return key;
|
|
||||||
});
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
/** Generator for a CPrivKey */
|
|
||||||
template <>
|
|
||||||
struct Arbitrary<CPrivKey> {
|
|
||||||
static Gen<CPrivKey> arbitrary()
|
|
||||||
{
|
|
||||||
return gen::map(gen::arbitrary<CKey>(), [](const CKey& key) {
|
|
||||||
return key.GetPrivKey();
|
|
||||||
});
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
/** Generator for a new CPubKey */
|
|
||||||
template <>
|
|
||||||
struct Arbitrary<CPubKey> {
|
|
||||||
static Gen<CPubKey> arbitrary()
|
|
||||||
{
|
|
||||||
return gen::map(gen::arbitrary<CKey>(), [](const CKey& key) {
|
|
||||||
return key.GetPubKey();
|
|
||||||
});
|
|
||||||
};
|
|
||||||
};
|
|
||||||
/** Generates a arbitrary uint256 */
|
|
||||||
template <>
|
|
||||||
struct Arbitrary<uint256> {
|
|
||||||
static Gen<uint256> arbitrary()
|
|
||||||
{
|
|
||||||
return rc::gen::just(GetRandHash());
|
|
||||||
};
|
|
||||||
};
|
|
||||||
} //namespace rc
|
|
||||||
#endif
|
|
|
@ -1,48 +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 <key.h>
|
|
||||||
|
|
||||||
#include <uint256.h>
|
|
||||||
#include <test/util/setup_common.h>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
#include <boost/test/unit_test.hpp>
|
|
||||||
#include <rapidcheck/boost_test.h>
|
|
||||||
#include <rapidcheck/gen/Arbitrary.h>
|
|
||||||
#include <rapidcheck/Gen.h>
|
|
||||||
|
|
||||||
#include <test/gen/crypto_gen.h>
|
|
||||||
|
|
||||||
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, then verify it with the public key */
|
|
||||||
RC_BOOST_PROP(key_sign_symmetry, (const CKey& key, const uint256& hash))
|
|
||||||
{
|
|
||||||
std::vector<unsigned char> vchSig;
|
|
||||||
key.Sign(hash, vchSig, 0);
|
|
||||||
const CPubKey& pubKey = key.GetPubKey();
|
|
||||||
RC_ASSERT(pubKey.Verify(hash, vchSig));
|
|
||||||
}
|
|
||||||
BOOST_AUTO_TEST_SUITE_END()
|
|
Loading…
Add table
Reference in a new issue