File tree Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,13 @@ class CAddrManSerializationMock : public CAddrMan
17
17
{
18
18
public:
19
19
virtual void Serialize (CDataStream& s, int nType, int nVersionDummy) const = 0;
20
+
21
+ // ! Ensure that bucket placement is always the same for testing purposes.
22
+ void MakeDeterministic ()
23
+ {
24
+ nKey.SetNull ();
25
+ seed_insecure_rand (true );
26
+ }
20
27
};
21
28
22
29
class CAddrManUncorrupted : public CAddrManSerializationMock
@@ -65,6 +72,7 @@ BOOST_FIXTURE_TEST_SUITE(net_tests, BasicTestingSetup)
65
72
BOOST_AUTO_TEST_CASE(caddrdb_read)
66
73
{
67
74
CAddrManUncorrupted addrmanUncorrupted;
75
+ addrmanUncorrupted.MakeDeterministic ();
68
76
69
77
CService addr1 = CService (" 250.7.1.1" , 8333 );
70
78
CService addr2 = CService (" 250.7.2.2" , 9999 );
@@ -106,6 +114,7 @@ BOOST_AUTO_TEST_CASE(caddrdb_read)
106
114
BOOST_AUTO_TEST_CASE (caddrdb_read_corrupted)
107
115
{
108
116
CAddrManCorrupted addrmanCorrupted;
117
+ addrmanCorrupted.MakeDeterministic ();
109
118
110
119
// Test that the de-serialization of corrupted addrman throws an exception.
111
120
CDataStream ssPeers1 = AddrmanToStream (addrmanCorrupted);
You can’t perform that action at this time.
0 commit comments