mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-15 14:22:37 -03:00
faec28252c
-BEGIN VERIFY SCRIPT- # Move files for f in $(git ls-files src/test/lib/); do git mv $f src/test/util/; done git mv src/test/setup_common.cpp src/test/util/ git mv src/test/setup_common.h src/test/util/ # Replace Windows paths sed -i -e 's|\\setup_common|\\util\\setup_common|g' $(git grep -l '\\setup_common') sed -i -e 's|src\\test\\lib\\|src\\test\\util\\|g' build_msvc/test_bitcoin/test_bitcoin.vcxproj # Everything else sed -i -e 's|/setup_common|/util/setup_common|g' $(git grep -l 'setup_common') sed -i -e 's|test/lib/|test/util/|g' $(git grep -l 'test/lib/') # Fix include guard sed -i -e 's|BITCOIN_TEST_SETUP_COMMON_H|BITCOIN_TEST_UTIL_SETUP_COMMON_H|g' ./src/test/util/setup_common.h sed -i -e 's|BITCOIN_TEST_LIB_|BITCOIN_TEST_UTIL_|g' $(git grep -l 'BITCOIN_TEST_LIB_') -END VERIFY SCRIPT-
48 lines
1.4 KiB
C++
48 lines
1.4 KiB
C++
// 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()
|