merge bitcoin#23492: tidy up addrman unit tests

This commit is contained in:
Kittywhiskers Van Gogh 2021-11-12 12:10:10 +01:00
parent aba0ebd400
commit 5b5dd39f45
No known key found for this signature in database
GPG Key ID: 30CD0C065E5C4AAD

View File

@ -88,7 +88,8 @@ static CService ResolveService(const std::string& ip, uint16_t port = 0)
}
static std::vector<bool> FromBytes(const unsigned char* source, int vector_size) {
static std::vector<bool> FromBytes(const unsigned char* source, int vector_size)
{
std::vector<bool> result(vector_size);
for (int byte_i = 0; byte_i < vector_size / 8; ++byte_i) {
unsigned char cur_byte = source[byte_i];
@ -690,7 +691,6 @@ BOOST_AUTO_TEST_CASE(caddrinfo_get_new_bucket)
// Test: IP addresses in the different source /16 prefixes sometimes map to NO MORE
// than 1 bucket.
BOOST_CHECK(buckets.size() == 1);
}
BOOST_AUTO_TEST_CASE(addrman_serialization)
@ -828,7 +828,6 @@ BOOST_AUTO_TEST_CASE(addrman_selecttriedcollision)
BOOST_CHECK(addrman.size() == 22);
BOOST_CHECK(addrman.SelectTriedCollision().first.ToString() == "[::]:0");
}
}
BOOST_AUTO_TEST_CASE(addrman_noevict)
@ -946,9 +945,7 @@ static CDataStream AddrmanToStream(const AddrMan& addrman)
CDataStream ssPeersIn(SER_DISK, CLIENT_VERSION);
ssPeersIn << Params().MessageStart();
ssPeersIn << addrman;
std::string str = ssPeersIn.str();
std::vector<unsigned char> vchData(str.begin(), str.end());
return CDataStream(vchData, SER_DISK, CLIENT_VERSION);
return ssPeersIn;
}
BOOST_AUTO_TEST_CASE(load_addrman)
@ -1020,9 +1017,7 @@ static CDataStream MakeCorruptPeersDat()
AddrInfo info = AddrInfo(addr, resolved);
s << info;
std::string str = s.str();
std::vector<unsigned char> vchData(str.begin(), str.end());
return CDataStream(vchData, SER_DISK, CLIENT_VERSION);
return s;
}
BOOST_AUTO_TEST_CASE(load_addrman_corrupted)