diff options
author | brunoerg <brunoely.gc@gmail.com> | 2022-10-11 13:37:45 -0300 |
---|---|---|
committer | brunoerg <brunoely.gc@gmail.com> | 2023-05-26 13:41:07 -0300 |
commit | 5c832c3820253affc65c0ed490e26e5b0a4d5c9b (patch) | |
tree | 3b57a22231de464f33b256cf21c9c300482ca499 /src/test/addrman_tests.cpp | |
parent | 34bcdfc6a65de906c65edccdd96fe15219081cd2 (diff) | |
download | bitcoin-5c832c3820253affc65c0ed490e26e5b0a4d5c9b.tar.xz |
p2p, refactor: return `std::optional<CNetAddr>` in `LookupHost`
Diffstat (limited to 'src/test/addrman_tests.cpp')
-rw-r--r-- | src/test/addrman_tests.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/test/addrman_tests.cpp b/src/test/addrman_tests.cpp index 95dbaa449b..328e7f81a0 100644 --- a/src/test/addrman_tests.cpp +++ b/src/test/addrman_tests.cpp @@ -33,9 +33,9 @@ static int32_t GetCheckRatio(const NodeContext& node_ctx) static CNetAddr ResolveIP(const std::string& ip) { - CNetAddr addr; - BOOST_CHECK_MESSAGE(LookupHost(ip, addr, false), strprintf("failed to resolve: %s", ip)); - return addr; + const std::optional<CNetAddr> addr{LookupHost(ip, false)}; + BOOST_CHECK_MESSAGE(addr.has_value(), strprintf("failed to resolve: %s", ip)); + return addr.value_or(CNetAddr{}); } static CService ResolveService(const std::string& ip, uint16_t port = 0) @@ -1012,9 +1012,9 @@ static CDataStream MakeCorruptPeersDat() const std::optional<CService> serv{Lookup("252.1.1.1", 7777, false)}; BOOST_REQUIRE(serv.has_value()); CAddress addr = CAddress(serv.value(), NODE_NONE); - CNetAddr resolved; - BOOST_REQUIRE(LookupHost("252.2.2.2", resolved, false)); - AddrInfo info = AddrInfo(addr, resolved); + std::optional<CNetAddr> resolved{LookupHost("252.2.2.2", false)}; + BOOST_REQUIRE(resolved.has_value()); + AddrInfo info = AddrInfo(addr, resolved.value()); s << info; return s; |