diff --git a/src/test/arith_uint256_tests.cpp b/src/test/arith_uint256_tests.cpp --- a/src/test/arith_uint256_tests.cpp +++ b/src/test/arith_uint256_tests.cpp @@ -21,7 +21,7 @@ BOOST_FIXTURE_TEST_SUITE(arith_uint256_tests, BasicTestingSetup) /// Convert vector to arith_uint256, via uint256 blob -inline arith_uint256 arith_uint256V(const std::vector &vch) { +static inline arith_uint256 arith_uint256V(const std::vector &vch) { return UintToArith256(uint256(vch)); } @@ -64,7 +64,7 @@ arith_uint256V(std::vector(MaxArray, MaxArray + 32)); const arith_uint256 HalfL = (OneL << 255); -std::string ArrayToString(const uint8_t A[], unsigned int width) { +static std::string ArrayToString(const uint8_t A[], unsigned int width) { std::stringstream Stream; Stream << std::hex; for (unsigned int i = 0; i < width; ++i) { @@ -138,8 +138,9 @@ BOOST_CHECK(tmpL == ~MaxL); } -void shiftArrayRight(uint8_t *to, const uint8_t *from, unsigned int arrayLength, - unsigned int bitsToShift) { +static void shiftArrayRight(uint8_t *to, const uint8_t *from, + unsigned int arrayLength, + unsigned int bitsToShift) { for (unsigned int T = 0; T < arrayLength; ++T) { unsigned int F = (T + bitsToShift / 8); if (F < arrayLength) { @@ -153,8 +154,8 @@ } } -void shiftArrayLeft(uint8_t *to, const uint8_t *from, unsigned int arrayLength, - unsigned int bitsToShift) { +static void shiftArrayLeft(uint8_t *to, const uint8_t *from, + unsigned int arrayLength, unsigned int bitsToShift) { for (unsigned int T = 0; T < arrayLength; ++T) { if (T >= bitsToShift / 8) { unsigned int F = T - bitsToShift / 8; @@ -427,7 +428,7 @@ BOOST_CHECK_THROW(R2L / ZeroL, uint_error); } -bool almostEqual(double d1, double d2) { +static bool almostEqual(double d1, double d2) { return fabs(d1 - d2) <= 4 * fabs(d1) * std::numeric_limits::epsilon(); } diff --git a/src/test/bip32_tests.cpp b/src/test/bip32_tests.cpp --- a/src/test/bip32_tests.cpp +++ b/src/test/bip32_tests.cpp @@ -94,7 +94,7 @@ 0); // clang-format on -void RunTest(const TestVector &test) { +static void RunTest(const TestVector &test) { std::vector seed = ParseHex(test.strHexMaster); CExtKey key; CExtPubKey pubkey; diff --git a/src/test/coins_tests.cpp b/src/test/coins_tests.cpp --- a/src/test/coins_tests.cpp +++ b/src/test/coins_tests.cpp @@ -580,7 +580,8 @@ } } -size_t InsertCoinMapEntry(CCoinsMap &map, const Amount value, char flags) { +static size_t InsertCoinMapEntry(CCoinsMap &map, const Amount value, + char flags) { if (value == ABSENT) { assert(flags == NO_ENTRY); return 0; @@ -631,9 +632,9 @@ CCoinsViewCacheTest cache{&base}; }; -void CheckAccessCoin(const Amount base_value, const Amount cache_value, - const Amount expected_value, char cache_flags, - char expected_flags) { +static void CheckAccessCoin(const Amount base_value, const Amount cache_value, + const Amount expected_value, char cache_flags, + char expected_flags) { SingleEntryCacheTest test(base_value, cache_value, cache_flags); test.cache.AccessCoin(OUTPOINT); test.cache.SelfTest(); @@ -682,9 +683,9 @@ CheckAccessCoin(VALUE1, VALUE2, VALUE2, DIRTY | FRESH, DIRTY | FRESH); } -void CheckSpendCoin(Amount base_value, Amount cache_value, - Amount expected_value, char cache_flags, - char expected_flags) { +static void CheckSpendCoin(Amount base_value, Amount cache_value, + Amount expected_value, char cache_flags, + char expected_flags) { SingleEntryCacheTest test(base_value, cache_value, cache_flags); test.cache.SpendCoin(OUTPOINT); test.cache.SelfTest(); @@ -734,9 +735,10 @@ CheckSpendCoin(VALUE1, VALUE2, ABSENT, DIRTY | FRESH, NO_ENTRY); } -void CheckAddCoinBase(Amount base_value, Amount cache_value, - Amount modify_value, Amount expected_value, - char cache_flags, char expected_flags, bool coinbase) { +static void CheckAddCoinBase(Amount base_value, Amount cache_value, + Amount modify_value, Amount expected_value, + char cache_flags, char expected_flags, + bool coinbase) { SingleEntryCacheTest test(base_value, cache_value, cache_flags); Amount result_value; @@ -762,7 +764,7 @@ // This wrapper lets the coin_add test below be shorter and less repetitive, // while still verifying that the CoinsViewCache::AddCoin implementation ignores // base values. -template void CheckAddCoin(Args &&... args) { +template static void CheckAddCoin(Args &&... args) { for (Amount base_value : {ABSENT, PRUNED, VALUE1}) { CheckAddCoinBase(base_value, std::forward(args)...); } diff --git a/src/test/crypto_tests.cpp b/src/test/crypto_tests.cpp --- a/src/test/crypto_tests.cpp +++ b/src/test/crypto_tests.cpp @@ -26,7 +26,7 @@ BOOST_FIXTURE_TEST_SUITE(crypto_tests, BasicTestingSetup) template -void TestVector(const Hasher &h, const In &in, const Out &out) { +static void TestVector(const Hasher &h, const In &in, const Out &out) { Out hash; BOOST_CHECK(out.size() == h.OUTPUT_SIZE); hash.resize(out.size()); @@ -58,35 +58,35 @@ } } -void TestSHA1(const std::string &in, const std::string &hexout) { +static void TestSHA1(const std::string &in, const std::string &hexout) { TestVector(CSHA1(), in, ParseHex(hexout)); } -void TestSHA256(const std::string &in, const std::string &hexout) { +static void TestSHA256(const std::string &in, const std::string &hexout) { TestVector(CSHA256(), in, ParseHex(hexout)); } -void TestSHA512(const std::string &in, const std::string &hexout) { +static void TestSHA512(const std::string &in, const std::string &hexout) { TestVector(CSHA512(), in, ParseHex(hexout)); } -void TestRIPEMD160(const std::string &in, const std::string &hexout) { +static void TestRIPEMD160(const std::string &in, const std::string &hexout) { TestVector(CRIPEMD160(), in, ParseHex(hexout)); } -void TestHMACSHA256(const std::string &hexkey, const std::string &hexin, - const std::string &hexout) { +static void TestHMACSHA256(const std::string &hexkey, const std::string &hexin, + const std::string &hexout) { std::vector key = ParseHex(hexkey); TestVector(CHMAC_SHA256(&key[0], key.size()), ParseHex(hexin), ParseHex(hexout)); } -void TestHMACSHA512(const std::string &hexkey, const std::string &hexin, - const std::string &hexout) { +static void TestHMACSHA512(const std::string &hexkey, const std::string &hexin, + const std::string &hexout) { std::vector key = ParseHex(hexkey); TestVector(CHMAC_SHA512(&key[0], key.size()), ParseHex(hexin), ParseHex(hexout)); } -void TestAES128(const std::string &hexkey, const std::string &hexin, - const std::string &hexout) { +static void TestAES128(const std::string &hexkey, const std::string &hexin, + const std::string &hexout) { std::vector key = ParseHex(hexkey); std::vector in = ParseHex(hexin); std::vector correctout = ParseHex(hexout); @@ -105,8 +105,8 @@ BOOST_CHECK_EQUAL(HexStr(buf2), HexStr(in)); } -void TestAES256(const std::string &hexkey, const std::string &hexin, - const std::string &hexout) { +static void TestAES256(const std::string &hexkey, const std::string &hexin, + const std::string &hexout) { std::vector key = ParseHex(hexkey); std::vector in = ParseHex(hexin); std::vector correctout = ParseHex(hexout); @@ -124,9 +124,9 @@ BOOST_CHECK(buf == in); } -void TestAES128CBC(const std::string &hexkey, const std::string &hexiv, - bool pad, const std::string &hexin, - const std::string &hexout) { +static void TestAES128CBC(const std::string &hexkey, const std::string &hexiv, + bool pad, const std::string &hexin, + const std::string &hexout) { std::vector key = ParseHex(hexkey); std::vector iv = ParseHex(hexiv); std::vector in = ParseHex(hexin); @@ -169,9 +169,9 @@ } } -void TestAES256CBC(const std::string &hexkey, const std::string &hexiv, - bool pad, const std::string &hexin, - const std::string &hexout) { +static void TestAES256CBC(const std::string &hexkey, const std::string &hexiv, + bool pad, const std::string &hexin, + const std::string &hexout) { std::vector key = ParseHex(hexkey); std::vector iv = ParseHex(hexiv); std::vector in = ParseHex(hexin); @@ -214,8 +214,8 @@ } } -void TestChaCha20(const std::string &hexkey, uint64_t nonce, uint64_t seek, - const std::string &hexout) { +static void TestChaCha20(const std::string &hexkey, uint64_t nonce, + uint64_t seek, const std::string &hexout) { std::vector key = ParseHex(hexkey); ChaCha20 rng(key.data(), key.size()); rng.SetIV(nonce); @@ -227,7 +227,7 @@ BOOST_CHECK(out == outres); } -std::string LongTestString(void) { +static std::string LongTestString(void) { std::string ret; for (int i = 0; i < 200000; i++) { ret += uint8_t(i); diff --git a/src/test/cuckoocache_tests.cpp b/src/test/cuckoocache_tests.cpp --- a/src/test/cuckoocache_tests.cpp +++ b/src/test/cuckoocache_tests.cpp @@ -48,7 +48,8 @@ * This helper returns the hit rate when megabytes*load worth of entries are * inserted into a megabytes sized cache */ -template double test_cache(size_t megabytes, double load) { +template +static double test_cache(size_t megabytes, double load) { SeedInsecureRand(true); std::vector hashes; Cache set{}; @@ -98,7 +99,7 @@ * how you measure around load 1.0 as after load 1.0 your normalized hit rate * becomes effectively perfect, ignoring freshness. */ -double normalize_hit_rate(double hits, double load) { +static double normalize_hit_rate(double hits, double load) { return hits * std::max(load, 1.0); } @@ -120,7 +121,7 @@ /** This helper checks that erased elements are preferentially inserted onto and * that the hit rate of "fresher" keys is reasonable*/ -template void test_cache_erase(size_t megabytes) { +template static void test_cache_erase(size_t megabytes) { double load = 1; SeedInsecureRand(true); std::vector hashes; @@ -189,7 +190,8 @@ megabytes); } -template void test_cache_erase_parallel(size_t megabytes) { +template +static void test_cache_erase_parallel(size_t megabytes) { double load = 1; SeedInsecureRand(true); std::vector hashes; @@ -282,7 +284,7 @@ CuckooCache::cache>(megabytes); } -template void test_cache_generations() { +template static void test_cache_generations() { // This test checks that for a simulation of network activity, the fresh hit // rate is never below 99%, and the number of times that it is worse than // 99.9% are less than 1% of the time. diff --git a/src/test/dbwrapper_tests.cpp b/src/test/dbwrapper_tests.cpp --- a/src/test/dbwrapper_tests.cpp +++ b/src/test/dbwrapper_tests.cpp @@ -12,7 +12,7 @@ #include // Test if a string consists entirely of null characters -bool is_null_key(const std::vector &key) { +static bool is_null_key(const std::vector &key) { bool isnull = true; for (unsigned int i = 0; i < key.size(); i++) diff --git a/src/test/denialofservice_tests.cpp b/src/test/denialofservice_tests.cpp --- a/src/test/denialofservice_tests.cpp +++ b/src/test/denialofservice_tests.cpp @@ -33,7 +33,7 @@ }; extern std::map mapOrphanTransactions; -CService ip(uint32_t i) { +static CService ip(uint32_t i) { struct in_addr s; s.s_addr = i; return CService(CNetAddr(s), Params().GetDefaultPort()); @@ -310,7 +310,7 @@ peerLogic->FinalizeNode(config, dummyNode.GetId(), dummy); } -CTransactionRef RandomOrphan() { +static CTransactionRef RandomOrphan() { std::map::iterator it; LOCK(cs_main); it = mapOrphanTransactions.lower_bound(InsecureRand256()); diff --git a/src/test/miner_tests.cpp b/src/test/miner_tests.cpp --- a/src/test/miner_tests.cpp +++ b/src/test/miner_tests.cpp @@ -66,14 +66,14 @@ {2, 0xbbbeb305}, {2, 0xfe1c810a}, }; -CBlockIndex CreateBlockIndex(int nHeight) { +static CBlockIndex CreateBlockIndex(int nHeight) { CBlockIndex index; index.nHeight = nHeight; index.pprev = chainActive.Tip(); return index; } -bool TestSequenceLocks(const CTransaction &tx, int flags) { +static bool TestSequenceLocks(const CTransaction &tx, int flags) { LOCK(g_mempool.cs); return CheckSequenceLocks(tx, flags); } @@ -82,8 +82,8 @@ // Implemented as an additional function, rather than a separate test case, to // allow reusing the blockchain created in CreateNewBlock_validity. // Note that this test assumes blockprioritypercentage is 0. -void TestPackageSelection(Config &config, CScript scriptPubKey, - std::vector &txFirst) { +static void TestPackageSelection(Config &config, CScript scriptPubKey, + std::vector &txFirst) { // Test the ancestor feerate transaction selection. TestMemPoolEntryHelper entry; diff --git a/src/test/multisig_tests.cpp b/src/test/multisig_tests.cpp --- a/src/test/multisig_tests.cpp +++ b/src/test/multisig_tests.cpp @@ -20,9 +20,9 @@ BOOST_FIXTURE_TEST_SUITE(multisig_tests, BasicTestingSetup) -CScript sign_multisig(const CScript &scriptPubKey, - const std::vector &keys, - const CMutableTransaction &tx, int whichIn) { +static CScript sign_multisig(const CScript &scriptPubKey, + const std::vector &keys, + const CMutableTransaction &tx, int whichIn) { uint256 hash = SignatureHash(scriptPubKey, CTransaction(tx), whichIn, SigHashType(), Amount::zero()); diff --git a/src/test/net_tests.cpp b/src/test/net_tests.cpp --- a/src/test/net_tests.cpp +++ b/src/test/net_tests.cpp @@ -72,7 +72,7 @@ uint64_t nMaxBlockSize; }; -CDataStream AddrmanToStream(CAddrManSerializationMock &_addrman) { +static CDataStream AddrmanToStream(CAddrManSerializationMock &_addrman) { CDataStream ssPeersIn(SER_DISK, CLIENT_VERSION); ssPeersIn << FLATDATA(Params().DiskMagic()); ssPeersIn << _addrman; diff --git a/src/test/script_tests.cpp b/src/test/script_tests.cpp --- a/src/test/script_tests.cpp +++ b/src/test/script_tests.cpp @@ -93,7 +93,7 @@ {SCRIPT_ERR_MOD_BY_ZERO, "MOD_BY_ZERO"}, }; -const char *FormatScriptError(ScriptError_t err) { +static const char *FormatScriptError(ScriptError_t err) { for (size_t i = 0; i < ARRAYLEN(script_errors); ++i) { if (script_errors[i].err == err) { return script_errors[i].name; @@ -105,7 +105,7 @@ return ""; } -ScriptError_t ParseScriptError(const std::string &name) { +static ScriptError_t ParseScriptError(const std::string &name) { for (size_t i = 0; i < ARRAYLEN(script_errors); ++i) { if (script_errors[i].name == name) { return script_errors[i].err; @@ -1883,9 +1883,9 @@ BOOST_CHECK_MESSAGE(err == SCRIPT_ERR_OK, ScriptErrorString(err)); } -CScript sign_multisig(const CScript &scriptPubKey, - const std::vector &keys, - const CTransaction &transaction) { +static CScript sign_multisig(const CScript &scriptPubKey, + const std::vector &keys, + const CTransaction &transaction) { uint256 hash = SignatureHash(scriptPubKey, transaction, 0, SigHashType(), Amount::zero()); @@ -1907,8 +1907,8 @@ return result; } -CScript sign_multisig(const CScript &scriptPubKey, const CKey &key, - const CTransaction &transaction) { +static CScript sign_multisig(const CScript &scriptPubKey, const CKey &key, + const CTransaction &transaction) { std::vector keys; keys.push_back(key); return sign_multisig(scriptPubKey, keys, transaction); diff --git a/src/test/sigopcount_tests.cpp b/src/test/sigopcount_tests.cpp --- a/src/test/sigopcount_tests.cpp +++ b/src/test/sigopcount_tests.cpp @@ -114,8 +114,8 @@ * Verifies script execution of the zeroth scriptPubKey of tx output and zeroth * scriptSig of tx input. */ -ScriptError VerifyWithFlag(const CTransaction &output, - const CMutableTransaction &input, int flags) { +static ScriptError VerifyWithFlag(const CTransaction &output, + const CMutableTransaction &input, int flags) { ScriptError error; CTransaction inputi(input); bool ret = VerifyScript( @@ -131,9 +131,9 @@ * such that spendingTx spends output zero of creationTx. Also inserts * creationTx's output into the coins view. */ -void BuildTxs(CMutableTransaction &spendingTx, CCoinsViewCache &coins, - CMutableTransaction &creationTx, const CScript &scriptPubKey, - const CScript &scriptSig) { +static void BuildTxs(CMutableTransaction &spendingTx, CCoinsViewCache &coins, + CMutableTransaction &creationTx, + const CScript &scriptPubKey, const CScript &scriptSig) { creationTx.nVersion = 1; creationTx.vin.resize(1); creationTx.vin[0].prevout = COutPoint(); diff --git a/src/test/test_bitcoin_fuzzy.cpp b/src/test/test_bitcoin_fuzzy.cpp --- a/src/test/test_bitcoin_fuzzy.cpp +++ b/src/test/test_bitcoin_fuzzy.cpp @@ -46,7 +46,7 @@ TEST_ID_END }; -bool read_stdin(std::vector &data) { +static bool read_stdin(std::vector &data) { char buffer[1024]; ssize_t length = 0; while ((length = read(STDIN_FILENO, buffer, 1024)) > 0) { diff --git a/src/test/transaction_tests.cpp b/src/test/transaction_tests.cpp --- a/src/test/transaction_tests.cpp +++ b/src/test/transaction_tests.cpp @@ -335,9 +335,11 @@ (50 + 21 + 22) * CENT); } -void CreateCreditAndSpend(const CKeyStore &keystore, const CScript &outscript, - CTransactionRef &output, CMutableTransaction &input, - bool success = true) { +static void CreateCreditAndSpend(const CKeyStore &keystore, + const CScript &outscript, + CTransactionRef &output, + CMutableTransaction &input, + bool success = true) { CMutableTransaction outputm; outputm.nVersion = 1; outputm.vin.resize(1); @@ -373,8 +375,9 @@ BOOST_CHECK(input.vout[0] == inputm.vout[0]); } -void CheckWithFlag(const CTransactionRef &output, - const CMutableTransaction &input, int flags, bool success) { +static void CheckWithFlag(const CTransactionRef &output, + const CMutableTransaction &input, int flags, + bool success) { ScriptError error; CTransaction inputi(input); bool ret = VerifyScript( @@ -399,7 +402,7 @@ return result; } -void ReplaceRedeemScript(CScript &script, const CScript &redeemScript) { +static void ReplaceRedeemScript(CScript &script, const CScript &redeemScript) { std::vector stack; EvalScript(stack, script, SCRIPT_VERIFY_STRICTENC, BaseSignatureChecker()); BOOST_CHECK(stack.size() > 0); diff --git a/src/test/txvalidationcache_tests.cpp b/src/test/txvalidationcache_tests.cpp --- a/src/test/txvalidationcache_tests.cpp +++ b/src/test/txvalidationcache_tests.cpp @@ -102,9 +102,10 @@ // should fail. // Capture this interaction with the upgraded_nop argument: set it when // evaluating any script flag that is implemented as an upgraded NOP code. -void ValidateCheckInputsForAllFlags(const CTransaction &tx, - uint32_t failing_flags, bool add_to_cache, - bool upgraded_nop) { +static void ValidateCheckInputsForAllFlags(const CTransaction &tx, + uint32_t failing_flags, + bool add_to_cache, + bool upgraded_nop) { PrecomputedTransactionData txdata(tx); // If we add many more flags, this loop can get too expensive, but we can // rewrite in the future to randomly pick a set of flags to evaluate. diff --git a/src/test/uint256_tests.cpp b/src/test/uint256_tests.cpp --- a/src/test/uint256_tests.cpp +++ b/src/test/uint256_tests.cpp @@ -53,7 +53,7 @@ const uint256 MaxL = uint256(std::vector(MaxArray, MaxArray + 32)); const uint160 MaxS = uint160(std::vector(MaxArray, MaxArray + 20)); -std::string ArrayToString(const uint8_t A[], unsigned int width) { +static std::string ArrayToString(const uint8_t A[], unsigned int width) { std::stringstream Stream; Stream << std::hex; for (unsigned int i = 0; i < width; ++i) {