|
|
@ -17,6 +17,13 @@ class CAddrManSerializationMock : public CAddrMan |
|
|
|
{ |
|
|
|
{ |
|
|
|
public: |
|
|
|
public: |
|
|
|
virtual void Serialize(CDataStream& s, int nType, int nVersionDummy) const = 0; |
|
|
|
virtual void Serialize(CDataStream& s, int nType, int nVersionDummy) const = 0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//! Ensure that bucket placement is always the same for testing purposes.
|
|
|
|
|
|
|
|
void MakeDeterministic() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
nKey.SetNull(); |
|
|
|
|
|
|
|
seed_insecure_rand(true); |
|
|
|
|
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
class CAddrManUncorrupted : public CAddrManSerializationMock |
|
|
|
class CAddrManUncorrupted : public CAddrManSerializationMock |
|
|
@ -65,6 +72,7 @@ BOOST_FIXTURE_TEST_SUITE(net_tests, BasicTestingSetup) |
|
|
|
BOOST_AUTO_TEST_CASE(caddrdb_read) |
|
|
|
BOOST_AUTO_TEST_CASE(caddrdb_read) |
|
|
|
{ |
|
|
|
{ |
|
|
|
CAddrManUncorrupted addrmanUncorrupted; |
|
|
|
CAddrManUncorrupted addrmanUncorrupted; |
|
|
|
|
|
|
|
addrmanUncorrupted.MakeDeterministic(); |
|
|
|
|
|
|
|
|
|
|
|
CService addr1 = CService("250.7.1.1", 8333); |
|
|
|
CService addr1 = CService("250.7.1.1", 8333); |
|
|
|
CService addr2 = CService("250.7.2.2", 9999); |
|
|
|
CService addr2 = CService("250.7.2.2", 9999); |
|
|
@ -106,6 +114,7 @@ BOOST_AUTO_TEST_CASE(caddrdb_read) |
|
|
|
BOOST_AUTO_TEST_CASE(caddrdb_read_corrupted) |
|
|
|
BOOST_AUTO_TEST_CASE(caddrdb_read_corrupted) |
|
|
|
{ |
|
|
|
{ |
|
|
|
CAddrManCorrupted addrmanCorrupted; |
|
|
|
CAddrManCorrupted addrmanCorrupted; |
|
|
|
|
|
|
|
addrmanCorrupted.MakeDeterministic(); |
|
|
|
|
|
|
|
|
|
|
|
// Test that the de-serialization of corrupted addrman throws an exception.
|
|
|
|
// Test that the de-serialization of corrupted addrman throws an exception.
|
|
|
|
CDataStream ssPeers1 = AddrmanToStream(addrmanCorrupted); |
|
|
|
CDataStream ssPeers1 = AddrmanToStream(addrmanCorrupted); |
|
|
|