Remove non-determinism which is breaking net_tests #8069
This commit is contained in:
@@ -18,6 +18,13 @@ class CAddrManSerializationMock : public CAddrMan
|
||||
{
|
||||
public:
|
||||
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
|
||||
@@ -70,6 +77,7 @@ BOOST_FIXTURE_TEST_SUITE(net_tests, BasicTestingSetup)
|
||||
BOOST_AUTO_TEST_CASE(caddrdb_read)
|
||||
{
|
||||
CAddrManUncorrupted addrmanUncorrupted;
|
||||
addrmanUncorrupted.MakeDeterministic();
|
||||
|
||||
CService addr1, addr2, addr3;
|
||||
Lookup("250.7.1.1", addr1, 8333, false);
|
||||
@@ -114,6 +122,7 @@ BOOST_AUTO_TEST_CASE(caddrdb_read)
|
||||
BOOST_AUTO_TEST_CASE(caddrdb_read_corrupted)
|
||||
{
|
||||
CAddrManCorrupted addrmanCorrupted;
|
||||
addrmanCorrupted.MakeDeterministic();
|
||||
|
||||
// Test that the de-serialization of corrupted addrman throws an exception.
|
||||
CDataStream ssPeers1 = AddrmanToStream(addrmanCorrupted);
|
||||
|
||||
Reference in New Issue
Block a user