Skip to content

Commit ed9ba8a

Browse files
committed
[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.
1 parent e8e7392 commit ed9ba8a

File tree

2 files changed

+2
-8
lines changed

2 files changed

+2
-8
lines changed

src/addrdb.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -244,12 +244,7 @@ bool CAddrDB::Read(CAddrMan& addr)
244244

245245
bool CAddrDB::Read(CAddrMan& addr, CDataStream& ssPeers)
246246
{
247-
bool ret = DeserializeDB(ssPeers, addr, false);
248-
if (!ret) {
249-
// Ensure addrman is left in a clean state
250-
addr.Clear();
251-
}
252-
return ret;
247+
return DeserializeDB(ssPeers, addr, false);
253248
}
254249

255250
void DumpAnchors(const fs::path& anchors_db_path, const std::vector<CAddress>& anchors)

src/test/addrman_tests.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1083,13 +1083,12 @@ BOOST_AUTO_TEST_CASE(caddrdb_read_corrupted)
10831083
BOOST_CHECK(addrman1.size() == 1);
10841084
BOOST_CHECK(exceptionThrown);
10851085

1086-
// Test that CAddrDB::Read leaves addrman in a clean state if de-serialization fails.
1086+
// Test that CAddrDB::Read fails if peers.dat is corrupt
10871087
CDataStream ssPeers2 = AddrmanToStream(addrmanCorrupted);
10881088

10891089
CAddrMan addrman2(/* deterministic */ false, /* consistency_check_ratio */ 100);
10901090
BOOST_CHECK(addrman2.size() == 0);
10911091
BOOST_CHECK(!CAddrDB::Read(addrman2, ssPeers2));
1092-
BOOST_CHECK(addrman2.size() == 0);
10931092
}
10941093

10951094

0 commit comments

Comments
 (0)