Changeset View
Changeset View
Standalone View
Standalone View
src/test/fuzz/integer.cpp
// Copyright (c) 2019 The Bitcoin Core developers | // Copyright (c) 2019 The Bitcoin Core developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#include <amount.h> | #include <amount.h> | ||||
#include <arith_uint256.h> | #include <arith_uint256.h> | ||||
#include <chainparams.h> | #include <chainparams.h> | ||||
#include <compressor.h> | #include <compressor.h> | ||||
#include <config.h> | #include <config.h> | ||||
#include <consensus/merkle.h> | #include <consensus/merkle.h> | ||||
#include <core_io.h> | #include <core_io.h> | ||||
#include <crypto/common.h> | #include <crypto/common.h> | ||||
#include <crypto/siphash.h> | #include <crypto/siphash.h> | ||||
#include <ctime> | |||||
#include <key_io.h> | #include <key_io.h> | ||||
#include <memusage.h> | #include <memusage.h> | ||||
#include <netbase.h> | #include <netbase.h> | ||||
#include <policy/settings.h> | #include <policy/settings.h> | ||||
#include <pow/pow.h> | #include <pow/pow.h> | ||||
#include <protocol.h> | #include <protocol.h> | ||||
#include <pubkey.h> | #include <pubkey.h> | ||||
#include <rpc/util.h> | #include <rpc/util.h> | ||||
#include <script/signingprovider.h> | #include <script/signingprovider.h> | ||||
#include <script/standard.h> | #include <script/standard.h> | ||||
#include <serialize.h> | #include <serialize.h> | ||||
#include <streams.h> | #include <streams.h> | ||||
#include <uint256.h> | #include <uint256.h> | ||||
#include <util/moneystr.h> | #include <util/moneystr.h> | ||||
#include <util/strencodings.h> | #include <util/strencodings.h> | ||||
#include <util/string.h> | #include <util/string.h> | ||||
#include <util/system.h> | #include <util/system.h> | ||||
#include <util/time.h> | #include <util/time.h> | ||||
#include <version.h> | #include <version.h> | ||||
#include <test/fuzz/FuzzedDataProvider.h> | #include <test/fuzz/FuzzedDataProvider.h> | ||||
#include <test/fuzz/fuzz.h> | #include <test/fuzz/fuzz.h> | ||||
#include <cassert> | #include <cassert> | ||||
#include <chrono> | |||||
#include <limits> | #include <limits> | ||||
#include <vector> | #include <vector> | ||||
void initialize() { | void initialize() { | ||||
SelectParams(CBaseChainParams::REGTEST); | SelectParams(CBaseChainParams::REGTEST); | ||||
} | } | ||||
void test_one_input(const std::vector<uint8_t> &buffer) { | void test_one_input(const std::vector<uint8_t> &buffer) { | ||||
▲ Show 20 Lines • Show All 88 Lines • ▼ Show 20 Lines | void test_one_input(const std::vector<uint8_t> &buffer) { | ||||
// std::numeric_limits<int64_t>::min() | // std::numeric_limits<int64_t>::min() | ||||
if (i64 != std::numeric_limits<int64_t>::min()) { | if (i64 != std::numeric_limits<int64_t>::min()) { | ||||
Amount parsed_money; | Amount parsed_money; | ||||
if (ParseMoney(ValueFromAmount(i64 * SATOSHI).getValStr(), | if (ParseMoney(ValueFromAmount(i64 * SATOSHI).getValStr(), | ||||
parsed_money)) { | parsed_money)) { | ||||
assert(parsed_money == i64 * SATOSHI); | assert(parsed_money == i64 * SATOSHI); | ||||
} | } | ||||
} | } | ||||
const std::chrono::seconds seconds{i64}; | |||||
assert(count_seconds(seconds) == i64); | |||||
const arith_uint256 au256 = UintToArith256(u256); | const arith_uint256 au256 = UintToArith256(u256); | ||||
assert(ArithToUint256(au256) == u256); | assert(ArithToUint256(au256) == u256); | ||||
assert(uint256S(au256.GetHex()) == u256); | assert(uint256S(au256.GetHex()) == u256); | ||||
(void)au256.bits(); | (void)au256.bits(); | ||||
(void)au256.GetCompact(/* fNegative= */ false); | (void)au256.GetCompact(/* fNegative= */ false); | ||||
(void)au256.GetCompact(/* fNegative= */ true); | (void)au256.GetCompact(/* fNegative= */ true); | ||||
(void)au256.getdouble(); | (void)au256.getdouble(); | ||||
▲ Show 20 Lines • Show All 91 Lines • Show Last 20 Lines |