diff options
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/addrman_tests.cpp | 51 | ||||
-rw-r--r-- | src/test/blockchain_tests.cpp | 5 | ||||
-rw-r--r-- | src/test/denialofservice_tests.cpp | 3 | ||||
-rw-r--r-- | src/test/key_tests.cpp | 3 | ||||
-rw-r--r-- | src/test/net_tests.cpp | 3 | ||||
-rw-r--r-- | src/test/settings_tests.cpp | 3 | ||||
-rw-r--r-- | src/test/timedata_tests.cpp | 3 | ||||
-rw-r--r-- | src/test/util/setup_common.cpp | 1 | ||||
-rw-r--r-- | src/test/util/setup_common.h | 1 | ||||
-rw-r--r-- | src/test/util_tests.cpp | 2 | ||||
-rw-r--r-- | src/test/util_threadnames_tests.cpp | 5 |
11 files changed, 45 insertions, 35 deletions
diff --git a/src/test/addrman_tests.cpp b/src/test/addrman_tests.cpp index 07cebeb35a..dfa8a6df21 100644 --- a/src/test/addrman_tests.cpp +++ b/src/test/addrman_tests.cpp @@ -6,6 +6,7 @@ #include <string> #include <boost/test/unit_test.hpp> #include <util/asmap.h> +#include <util/string.h> #include <test/data/asmap.raw.h> #include <hash.h> @@ -266,7 +267,7 @@ BOOST_AUTO_TEST_CASE(addrman_new_collisions) BOOST_CHECK_EQUAL(addrman.size(), 0U); for (unsigned int i = 1; i < 18; i++) { - CService addr = ResolveService("250.1.1." + std::to_string(i)); + CService addr = ResolveService("250.1.1." + ToString(i)); BOOST_CHECK(addrman.Add(CAddress(addr, NODE_NONE), source)); //Test: No collision in new table yet. @@ -292,7 +293,7 @@ BOOST_AUTO_TEST_CASE(addrman_tried_collisions) BOOST_CHECK_EQUAL(addrman.size(), 0U); for (unsigned int i = 1; i < 80; i++) { - CService addr = ResolveService("250.1.1." + std::to_string(i)); + CService addr = ResolveService("250.1.1." + ToString(i)); BOOST_CHECK(addrman.Add(CAddress(addr, NODE_NONE), source)); addrman.Good(CAddress(addr, NODE_NONE)); @@ -425,7 +426,7 @@ BOOST_AUTO_TEST_CASE(addrman_getaddr) for (unsigned int i = 1; i < (8 * 256); i++) { int octet1 = i % 256; int octet2 = i >> 8 % 256; - std::string strAddr = std::to_string(octet1) + "." + std::to_string(octet2) + ".1.23"; + std::string strAddr = ToString(octet1) + "." + ToString(octet2) + ".1.23"; CAddress addr = CAddress(ResolveService(strAddr), NODE_NONE); // Ensure that for all addrs in addrman, isTerrible == false. @@ -477,8 +478,8 @@ BOOST_AUTO_TEST_CASE(caddrinfo_get_tried_bucket_legacy) std::set<int> buckets; for (int i = 0; i < 255; i++) { CAddrInfo infoi = CAddrInfo( - CAddress(ResolveService("250.1.1." + std::to_string(i)), NODE_NONE), - ResolveIP("250.1.1." + std::to_string(i))); + CAddress(ResolveService("250.1.1." + ToString(i)), NODE_NONE), + ResolveIP("250.1.1." + ToString(i))); int bucket = infoi.GetTriedBucket(nKey1, asmap); buckets.insert(bucket); } @@ -489,8 +490,8 @@ BOOST_AUTO_TEST_CASE(caddrinfo_get_tried_bucket_legacy) buckets.clear(); for (int j = 0; j < 255; j++) { CAddrInfo infoj = CAddrInfo( - CAddress(ResolveService("250." + std::to_string(j) + ".1.1"), NODE_NONE), - ResolveIP("250." + std::to_string(j) + ".1.1")); + CAddress(ResolveService("250." + ToString(j) + ".1.1"), NODE_NONE), + ResolveIP("250." + ToString(j) + ".1.1")); int bucket = infoj.GetTriedBucket(nKey1, asmap); buckets.insert(bucket); } @@ -531,8 +532,8 @@ BOOST_AUTO_TEST_CASE(caddrinfo_get_new_bucket_legacy) std::set<int> buckets; for (int i = 0; i < 255; i++) { CAddrInfo infoi = CAddrInfo( - CAddress(ResolveService("250.1.1." + std::to_string(i)), NODE_NONE), - ResolveIP("250.1.1." + std::to_string(i))); + CAddress(ResolveService("250.1.1." + ToString(i)), NODE_NONE), + ResolveIP("250.1.1." + ToString(i))); int bucket = infoi.GetNewBucket(nKey1, asmap); buckets.insert(bucket); } @@ -544,7 +545,7 @@ BOOST_AUTO_TEST_CASE(caddrinfo_get_new_bucket_legacy) for (int j = 0; j < 4 * 255; j++) { CAddrInfo infoj = CAddrInfo(CAddress( ResolveService( - std::to_string(250 + (j / 255)) + "." + std::to_string(j % 256) + ".1.1"), NODE_NONE), + ToString(250 + (j / 255)) + "." + ToString(j % 256) + ".1.1"), NODE_NONE), ResolveIP("251.4.1.1")); int bucket = infoj.GetNewBucket(nKey1, asmap); buckets.insert(bucket); @@ -557,7 +558,7 @@ BOOST_AUTO_TEST_CASE(caddrinfo_get_new_bucket_legacy) for (int p = 0; p < 255; p++) { CAddrInfo infoj = CAddrInfo( CAddress(ResolveService("250.1.1.1"), NODE_NONE), - ResolveIP("250." + std::to_string(p) + ".1.1")); + ResolveIP("250." + ToString(p) + ".1.1")); int bucket = infoj.GetNewBucket(nKey1, asmap); buckets.insert(bucket); } @@ -610,8 +611,8 @@ BOOST_AUTO_TEST_CASE(caddrinfo_get_tried_bucket) std::set<int> buckets; for (int j = 0; j < 255; j++) { CAddrInfo infoj = CAddrInfo( - CAddress(ResolveService("101." + std::to_string(j) + ".1.1"), NODE_NONE), - ResolveIP("101." + std::to_string(j) + ".1.1")); + CAddress(ResolveService("101." + ToString(j) + ".1.1"), NODE_NONE), + ResolveIP("101." + ToString(j) + ".1.1")); int bucket = infoj.GetTriedBucket(nKey1, asmap); buckets.insert(bucket); } @@ -622,8 +623,8 @@ BOOST_AUTO_TEST_CASE(caddrinfo_get_tried_bucket) buckets.clear(); for (int j = 0; j < 255; j++) { CAddrInfo infoj = CAddrInfo( - CAddress(ResolveService("250." + std::to_string(j) + ".1.1"), NODE_NONE), - ResolveIP("250." + std::to_string(j) + ".1.1")); + CAddress(ResolveService("250." + ToString(j) + ".1.1"), NODE_NONE), + ResolveIP("250." + ToString(j) + ".1.1")); int bucket = infoj.GetTriedBucket(nKey1, asmap); buckets.insert(bucket); } @@ -664,8 +665,8 @@ BOOST_AUTO_TEST_CASE(caddrinfo_get_new_bucket) std::set<int> buckets; for (int i = 0; i < 255; i++) { CAddrInfo infoi = CAddrInfo( - CAddress(ResolveService("250.1.1." + std::to_string(i)), NODE_NONE), - ResolveIP("250.1.1." + std::to_string(i))); + CAddress(ResolveService("250.1.1." + ToString(i)), NODE_NONE), + ResolveIP("250.1.1." + ToString(i))); int bucket = infoi.GetNewBucket(nKey1, asmap); buckets.insert(bucket); } @@ -677,7 +678,7 @@ BOOST_AUTO_TEST_CASE(caddrinfo_get_new_bucket) for (int j = 0; j < 4 * 255; j++) { CAddrInfo infoj = CAddrInfo(CAddress( ResolveService( - std::to_string(250 + (j / 255)) + "." + std::to_string(j % 256) + ".1.1"), NODE_NONE), + ToString(250 + (j / 255)) + "." + ToString(j % 256) + ".1.1"), NODE_NONE), ResolveIP("251.4.1.1")); int bucket = infoj.GetNewBucket(nKey1, asmap); buckets.insert(bucket); @@ -690,7 +691,7 @@ BOOST_AUTO_TEST_CASE(caddrinfo_get_new_bucket) for (int p = 0; p < 255; p++) { CAddrInfo infoj = CAddrInfo( CAddress(ResolveService("250.1.1.1"), NODE_NONE), - ResolveIP("101." + std::to_string(p) + ".1.1")); + ResolveIP("101." + ToString(p) + ".1.1")); int bucket = infoj.GetNewBucket(nKey1, asmap); buckets.insert(bucket); } @@ -702,7 +703,7 @@ BOOST_AUTO_TEST_CASE(caddrinfo_get_new_bucket) for (int p = 0; p < 255; p++) { CAddrInfo infoj = CAddrInfo( CAddress(ResolveService("250.1.1.1"), NODE_NONE), - ResolveIP("250." + std::to_string(p) + ".1.1")); + ResolveIP("250." + ToString(p) + ".1.1")); int bucket = infoj.GetNewBucket(nKey1, asmap); buckets.insert(bucket); } @@ -791,7 +792,7 @@ BOOST_AUTO_TEST_CASE(addrman_selecttriedcollision) // Add twenty two addresses. CNetAddr source = ResolveIP("252.2.2.2"); for (unsigned int i = 1; i < 23; i++) { - CService addr = ResolveService("250.1.1."+std::to_string(i)); + CService addr = ResolveService("250.1.1."+ToString(i)); BOOST_CHECK(addrman.Add(CAddress(addr, NODE_NONE), source)); addrman.Good(addr); @@ -802,7 +803,7 @@ BOOST_AUTO_TEST_CASE(addrman_selecttriedcollision) // Ensure Good handles duplicates well. for (unsigned int i = 1; i < 23; i++) { - CService addr = ResolveService("250.1.1."+std::to_string(i)); + CService addr = ResolveService("250.1.1."+ToString(i)); addrman.Good(addr); BOOST_CHECK(addrman.size() == 22); @@ -818,7 +819,7 @@ BOOST_AUTO_TEST_CASE(addrman_noevict) // Add twenty two addresses. CNetAddr source = ResolveIP("252.2.2.2"); for (unsigned int i = 1; i < 23; i++) { - CService addr = ResolveService("250.1.1."+std::to_string(i)); + CService addr = ResolveService("250.1.1."+ToString(i)); BOOST_CHECK(addrman.Add(CAddress(addr, NODE_NONE), source)); addrman.Good(addr); @@ -841,7 +842,7 @@ BOOST_AUTO_TEST_CASE(addrman_noevict) // Lets create two collisions. for (unsigned int i = 24; i < 33; i++) { - CService addr = ResolveService("250.1.1."+std::to_string(i)); + CService addr = ResolveService("250.1.1."+ToString(i)); BOOST_CHECK(addrman.Add(CAddress(addr, NODE_NONE), source)); addrman.Good(addr); @@ -879,7 +880,7 @@ BOOST_AUTO_TEST_CASE(addrman_evictionworks) // Add twenty two addresses. CNetAddr source = ResolveIP("252.2.2.2"); for (unsigned int i = 1; i < 23; i++) { - CService addr = ResolveService("250.1.1."+std::to_string(i)); + CService addr = ResolveService("250.1.1."+ToString(i)); BOOST_CHECK(addrman.Add(CAddress(addr, NODE_NONE), source)); addrman.Good(addr); diff --git a/src/test/blockchain_tests.cpp b/src/test/blockchain_tests.cpp index 3b4c480f72..aa704642bf 100644 --- a/src/test/blockchain_tests.cpp +++ b/src/test/blockchain_tests.cpp @@ -8,6 +8,7 @@ #include <chain.h> #include <rpc/blockchain.h> +#include <util/string.h> #include <test/util/setup_common.h> /* Equality between doubles is imprecise. Comparison should be done @@ -30,8 +31,8 @@ static CBlockIndex* CreateBlockIndexWithNbits(uint32_t nbits) static void RejectDifficultyMismatch(double difficulty, double expected_difficulty) { BOOST_CHECK_MESSAGE( DoubleEquals(difficulty, expected_difficulty, 0.00001), - "Difficulty was " + std::to_string(difficulty) - + " but was expected to be " + std::to_string(expected_difficulty)); + "Difficulty was " + ToString(difficulty) + + " but was expected to be " + ToString(expected_difficulty)); } /* Given a BlockIndex with the provided nbits, diff --git a/src/test/denialofservice_tests.cpp b/src/test/denialofservice_tests.cpp index 73bce6f789..7310498eb6 100644 --- a/src/test/denialofservice_tests.cpp +++ b/src/test/denialofservice_tests.cpp @@ -13,6 +13,7 @@ #include <script/standard.h> #include <serialize.h> #include <util/memory.h> +#include <util/string.h> #include <util/system.h> #include <util/time.h> #include <validation.h> @@ -313,7 +314,7 @@ BOOST_AUTO_TEST_CASE(DoS_banscore) BOOST_CHECK(peerLogic->SendMessages(&dummyNode1)); } BOOST_CHECK(banman->IsBanned(addr1)); - gArgs.ForceSetArg("-banscore", std::to_string(DEFAULT_BANSCORE_THRESHOLD)); + gArgs.ForceSetArg("-banscore", ToString(DEFAULT_BANSCORE_THRESHOLD)); bool dummy; peerLogic->FinalizeNode(dummyNode1.GetId(), dummy); diff --git a/src/test/key_tests.cpp b/src/test/key_tests.cpp index 85dc961bea..034b7938f9 100644 --- a/src/test/key_tests.cpp +++ b/src/test/key_tests.cpp @@ -8,6 +8,7 @@ #include <uint256.h> #include <util/system.h> #include <util/strencodings.h> +#include <util/string.h> #include <test/util/setup_common.h> #include <string> @@ -176,7 +177,7 @@ BOOST_AUTO_TEST_CASE(key_signature_tests) bool found_small = false; for (int i = 0; i < 256; ++i) { sig.clear(); - std::string msg = "A message to be signed" + std::to_string(i); + std::string msg = "A message to be signed" + ToString(i); msg_hash = Hash(msg.begin(), msg.end()); BOOST_CHECK(key.Sign(msg_hash, sig)); found = sig[3] == 0x20; diff --git a/src/test/net_tests.cpp b/src/test/net_tests.cpp index cb1ef5dcf3..9b5a86fef2 100644 --- a/src/test/net_tests.cpp +++ b/src/test/net_tests.cpp @@ -15,6 +15,7 @@ #include <chainparams.h> #include <util/memory.h> #include <util/system.h> +#include <util/string.h> #include <memory> @@ -85,7 +86,7 @@ BOOST_AUTO_TEST_CASE(cnode_listen_port) BOOST_CHECK(port == Params().GetDefaultPort()); // test set port unsigned short altPort = 12345; - BOOST_CHECK(gArgs.SoftSetArg("-port", std::to_string(altPort))); + BOOST_CHECK(gArgs.SoftSetArg("-port", ToString(altPort))); port = GetListenPort(); BOOST_CHECK(port == altPort); } diff --git a/src/test/settings_tests.cpp b/src/test/settings_tests.cpp index 45644834a5..10b161aa80 100644 --- a/src/test/settings_tests.cpp +++ b/src/test/settings_tests.cpp @@ -11,6 +11,7 @@ #include <boost/test/unit_test.hpp> #include <univalue.h> #include <util/strencodings.h> +#include <util/string.h> #include <vector> BOOST_FIXTURE_TEST_SUITE(settings_tests, BasicTestingSetup) @@ -114,7 +115,7 @@ BOOST_FIXTURE_TEST_CASE(Merge, MergeTestingSetup) std::vector<util::SettingsValue>& dest) { if (action == SET || action == SECTION_SET) { for (int i = 0; i < 2; ++i) { - dest.push_back(value_prefix + std::to_string(++value_suffix)); + dest.push_back(value_prefix + ToString(++value_suffix)); desc += " " + name_prefix + name + "=" + dest.back().get_str(); } } else if (action == NEGATE || action == SECTION_NEGATE) { diff --git a/src/test/timedata_tests.cpp b/src/test/timedata_tests.cpp index 19bd0d142f..29b43e9bec 100644 --- a/src/test/timedata_tests.cpp +++ b/src/test/timedata_tests.cpp @@ -5,6 +5,7 @@ #include <netaddress.h> #include <noui.h> +#include <util/string.h> #include <test/util/logging.h> #include <test/util/setup_common.h> #include <timedata.h> @@ -46,7 +47,7 @@ static void MultiAddTimeData(int n, int64_t offset) static int cnt = 0; for (int i = 0; i < n; ++i) { CNetAddr addr; - addr.SetInternal(std::to_string(++cnt)); + addr.SetInternal(ToString(++cnt)); AddTimeData(addr, offset); } } diff --git a/src/test/util/setup_common.cpp b/src/test/util/setup_common.cpp index e19a96eafc..d684b97787 100644 --- a/src/test/util/setup_common.cpp +++ b/src/test/util/setup_common.cpp @@ -24,6 +24,7 @@ #include <txdb.h> #include <util/memory.h> #include <util/strencodings.h> +#include <util/string.h> #include <util/time.h> #include <util/translation.h> #include <validation.h> diff --git a/src/test/util/setup_common.h b/src/test/util/setup_common.h index 56ad62eb24..0930309c3a 100644 --- a/src/test/util/setup_common.h +++ b/src/test/util/setup_common.h @@ -13,6 +13,7 @@ #include <random.h> #include <scheduler.h> #include <txmempool.h> +#include <util/string.h> #include <type_traits> diff --git a/src/test/util_tests.cpp b/src/test/util_tests.cpp index eb0d31fbdc..ab437d12a1 100644 --- a/src/test/util_tests.cpp +++ b/src/test/util_tests.cpp @@ -894,7 +894,7 @@ struct ArgsMergeTestingSetup : public BasicTestingSetup { if (action == SECTION_SET || action == SECTION_NEGATE) prefix = section + "."; if (action == SET || action == SECTION_SET) { for (int i = 0; i < 2; ++i) { - values.push_back(prefix + name + "=" + value_prefix + std::to_string(++suffix)); + values.push_back(prefix + name + "=" + value_prefix + ToString(++suffix)); } } if (action == NEGATE || action == SECTION_NEGATE) { diff --git a/src/test/util_threadnames_tests.cpp b/src/test/util_threadnames_tests.cpp index 78dbf848bb..cee4e0ce3c 100644 --- a/src/test/util_threadnames_tests.cpp +++ b/src/test/util_threadnames_tests.cpp @@ -2,6 +2,7 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. +#include <util/string.h> #include <util/threadnames.h> #include <test/util/setup_common.h> @@ -32,7 +33,7 @@ std::set<std::string> RenameEnMasse(int num_threads) std::mutex lock; auto RenameThisThread = [&](int i) { - util::ThreadRename(TEST_THREAD_NAME_BASE + std::to_string(i)); + util::ThreadRename(TEST_THREAD_NAME_BASE + ToString(i)); std::lock_guard<std::mutex> guard(lock); names.insert(util::ThreadGetInternalName()); }; @@ -65,7 +66,7 @@ BOOST_AUTO_TEST_CASE(util_threadnames_test_rename_threaded) // Names "test_thread.[n]" should exist for n = [0, 99] for (int i = 0; i < 100; ++i) { - BOOST_CHECK(names.find(TEST_THREAD_NAME_BASE + std::to_string(i)) != names.end()); + BOOST_CHECK(names.find(TEST_THREAD_NAME_BASE + ToString(i)) != names.end()); } } |