aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorJon Atack <jon@atack.com>2021-03-01 21:35:28 +0100
committerJon Atack <jon@atack.com>2021-03-16 19:52:31 +0100
commit6423c8175fad3163c10ffdb49e0df48e4e4931f1 (patch)
treefe0ad5daa524b4802c6e2d60bcb80043d245d876 /src/test
parent1b6c463e033f861561d1a46ccf7eec069bbac09f (diff)
p2p, refactor: pass and use uint16_t CService::port as uint16_t
Diffstat (limited to 'src/test')
-rw-r--r--src/test/addrman_tests.cpp2
-rw-r--r--src/test/fuzz/netbase_dns_lookup.cpp2
-rw-r--r--src/test/fuzz/socks5.cpp2
-rw-r--r--src/test/fuzz/string.cpp2
-rw-r--r--src/test/net_tests.cpp2
-rw-r--r--src/test/netbase_tests.cpp18
6 files changed, 14 insertions, 14 deletions
diff --git a/src/test/addrman_tests.cpp b/src/test/addrman_tests.cpp
index 37ff8a9afe..d438537606 100644
--- a/src/test/addrman_tests.cpp
+++ b/src/test/addrman_tests.cpp
@@ -100,7 +100,7 @@ static CNetAddr ResolveIP(const std::string& ip)
return addr;
}
-static CService ResolveService(const std::string& ip, const int port = 0)
+static CService ResolveService(const std::string& ip, uint16_t port = 0)
{
CService serv;
BOOST_CHECK_MESSAGE(Lookup(ip, serv, port, false), strprintf("failed to resolve: %s:%i", ip, port));
diff --git a/src/test/fuzz/netbase_dns_lookup.cpp b/src/test/fuzz/netbase_dns_lookup.cpp
index 7be8b13743..cf2fa33744 100644
--- a/src/test/fuzz/netbase_dns_lookup.cpp
+++ b/src/test/fuzz/netbase_dns_lookup.cpp
@@ -18,7 +18,7 @@ FUZZ_TARGET(netbase_dns_lookup)
const std::string name = fuzzed_data_provider.ConsumeRandomLengthString(512);
const unsigned int max_results = fuzzed_data_provider.ConsumeIntegral<unsigned int>();
const bool allow_lookup = fuzzed_data_provider.ConsumeBool();
- const int default_port = fuzzed_data_provider.ConsumeIntegral<int>();
+ const uint16_t default_port = fuzzed_data_provider.ConsumeIntegral<uint16_t>();
auto fuzzed_dns_lookup_function = [&](const std::string&, bool) {
std::vector<CNetAddr> resolved_addresses;
diff --git a/src/test/fuzz/socks5.cpp b/src/test/fuzz/socks5.cpp
index e5cc4cabe5..d7b32ef46f 100644
--- a/src/test/fuzz/socks5.cpp
+++ b/src/test/fuzz/socks5.cpp
@@ -38,7 +38,7 @@ FUZZ_TARGET_INIT(socks5, initialize_socks5)
// This Socks5(...) fuzzing harness would have caught CVE-2017-18350 within
// a few seconds of fuzzing.
(void)Socks5(fuzzed_data_provider.ConsumeRandomLengthString(512),
- fuzzed_data_provider.ConsumeIntegral<int>(),
+ fuzzed_data_provider.ConsumeIntegral<uint16_t>(),
fuzzed_data_provider.ConsumeBool() ? &proxy_credentials : nullptr,
fuzzed_sock);
}
diff --git a/src/test/fuzz/string.cpp b/src/test/fuzz/string.cpp
index 93b4948a2f..835b59f05c 100644
--- a/src/test/fuzz/string.cpp
+++ b/src/test/fuzz/string.cpp
@@ -82,7 +82,7 @@ FUZZ_TARGET(string)
#ifndef WIN32
(void)ShellEscape(random_string_1);
#endif // WIN32
- int port_out;
+ uint16_t port_out;
std::string host_out;
SplitHostPort(random_string_1, port_out, host_out);
(void)TimingResistantEqual(random_string_1, random_string_2);
diff --git a/src/test/net_tests.cpp b/src/test/net_tests.cpp
index 167242a971..3af49c46f8 100644
--- a/src/test/net_tests.cpp
+++ b/src/test/net_tests.cpp
@@ -91,7 +91,7 @@ BOOST_FIXTURE_TEST_SUITE(net_tests, BasicTestingSetup)
BOOST_AUTO_TEST_CASE(cnode_listen_port)
{
// test default
- uint16_t port = GetListenPort();
+ uint16_t port{GetListenPort()};
BOOST_CHECK(port == Params().GetDefaultPort());
// test set port
uint16_t altPort = 12345;
diff --git a/src/test/netbase_tests.cpp b/src/test/netbase_tests.cpp
index 66ad7bb5ea..545fca1a33 100644
--- a/src/test/netbase_tests.cpp
+++ b/src/test/netbase_tests.cpp
@@ -83,31 +83,31 @@ BOOST_AUTO_TEST_CASE(netbase_properties)
}
-bool static TestSplitHost(std::string test, std::string host, int port)
+bool static TestSplitHost(const std::string& test, const std::string& host, uint16_t port)
{
std::string hostOut;
- int portOut = -1;
+ uint16_t portOut{0};
SplitHostPort(test, portOut, hostOut);
return hostOut == host && port == portOut;
}
BOOST_AUTO_TEST_CASE(netbase_splithost)
{
- BOOST_CHECK(TestSplitHost("www.bitcoincore.org", "www.bitcoincore.org", -1));
- BOOST_CHECK(TestSplitHost("[www.bitcoincore.org]", "www.bitcoincore.org", -1));
+ BOOST_CHECK(TestSplitHost("www.bitcoincore.org", "www.bitcoincore.org", 0));
+ BOOST_CHECK(TestSplitHost("[www.bitcoincore.org]", "www.bitcoincore.org", 0));
BOOST_CHECK(TestSplitHost("www.bitcoincore.org:80", "www.bitcoincore.org", 80));
BOOST_CHECK(TestSplitHost("[www.bitcoincore.org]:80", "www.bitcoincore.org", 80));
- BOOST_CHECK(TestSplitHost("127.0.0.1", "127.0.0.1", -1));
+ BOOST_CHECK(TestSplitHost("127.0.0.1", "127.0.0.1", 0));
BOOST_CHECK(TestSplitHost("127.0.0.1:8333", "127.0.0.1", 8333));
- BOOST_CHECK(TestSplitHost("[127.0.0.1]", "127.0.0.1", -1));
+ BOOST_CHECK(TestSplitHost("[127.0.0.1]", "127.0.0.1", 0));
BOOST_CHECK(TestSplitHost("[127.0.0.1]:8333", "127.0.0.1", 8333));
- BOOST_CHECK(TestSplitHost("::ffff:127.0.0.1", "::ffff:127.0.0.1", -1));
+ BOOST_CHECK(TestSplitHost("::ffff:127.0.0.1", "::ffff:127.0.0.1", 0));
BOOST_CHECK(TestSplitHost("[::ffff:127.0.0.1]:8333", "::ffff:127.0.0.1", 8333));
BOOST_CHECK(TestSplitHost("[::]:8333", "::", 8333));
- BOOST_CHECK(TestSplitHost("::8333", "::8333", -1));
+ BOOST_CHECK(TestSplitHost("::8333", "::8333", 0));
BOOST_CHECK(TestSplitHost(":8333", "", 8333));
BOOST_CHECK(TestSplitHost("[]:8333", "", 8333));
- BOOST_CHECK(TestSplitHost("", "", -1));
+ BOOST_CHECK(TestSplitHost("", "", 0));
}
bool static TestParse(std::string src, std::string canon)