aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Newbery <john@johnnewbery.com>2021-08-05 13:51:52 +0100
committerJohn Newbery <john@johnnewbery.com>2021-08-18 14:00:52 +0100
commited9ba8af08f857bda3ce2f77413317374c22d7b4 (patch)
tree4ee650b69fdb99c1fa4d97c2d5c9b6c0ed07c197 /src
parente8e7392311edf44278d76743bebe902d4ac94662 (diff)
[tests] Remove CAddrMan.Clear() call from CAddrDB::Read()
`bool CAddrDB::Read(CAddrMan& addr, CDataStream& ssPeers)` is _only_ called from the tests, and the call to addr.Clear() only exists so that a test that Clear() is called passes. Remove that test and the call.
Diffstat (limited to 'src')
-rw-r--r--src/addrdb.cpp7
-rw-r--r--src/test/addrman_tests.cpp3
2 files changed, 2 insertions, 8 deletions
diff --git a/src/addrdb.cpp b/src/addrdb.cpp
index c3e224ee83..a5383be7cf 100644
--- a/src/addrdb.cpp
+++ b/src/addrdb.cpp
@@ -244,12 +244,7 @@ bool CAddrDB::Read(CAddrMan& addr)
bool CAddrDB::Read(CAddrMan& addr, CDataStream& ssPeers)
{
- bool ret = DeserializeDB(ssPeers, addr, false);
- if (!ret) {
- // Ensure addrman is left in a clean state
- addr.Clear();
- }
- return ret;
+ return DeserializeDB(ssPeers, addr, false);
}
void DumpAnchors(const fs::path& anchors_db_path, const std::vector<CAddress>& anchors)
diff --git a/src/test/addrman_tests.cpp b/src/test/addrman_tests.cpp
index c52baa4e8b..255b5076e7 100644
--- a/src/test/addrman_tests.cpp
+++ b/src/test/addrman_tests.cpp
@@ -1083,13 +1083,12 @@ BOOST_AUTO_TEST_CASE(caddrdb_read_corrupted)
BOOST_CHECK(addrman1.size() == 1);
BOOST_CHECK(exceptionThrown);
- // Test that CAddrDB::Read leaves addrman in a clean state if de-serialization fails.
+ // Test that CAddrDB::Read fails if peers.dat is corrupt
CDataStream ssPeers2 = AddrmanToStream(addrmanCorrupted);
CAddrMan addrman2(/* deterministic */ false, /* consistency_check_ratio */ 100);
BOOST_CHECK(addrman2.size() == 0);
BOOST_CHECK(!CAddrDB::Read(addrman2, ssPeers2));
- BOOST_CHECK(addrman2.size() == 0);
}