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 @@ -19,6 +19,13 @@ class CAddrManSerializationMock : public CAddrMan
1919{
2020public:
2121 virtual void Serialize (CDataStream& s, int nType, int nVersionDummy) const = 0;
22+
23+ // ! Ensure that bucket placement is always the same for testing purposes.
24+ void MakeDeterministic ()
25+ {
26+ nKey.SetNull ();
27+ SeedInsecureRand (true );
28+ }
2229};
2330
2431class CAddrManUncorrupted : public CAddrManSerializationMock
@@ -67,6 +74,7 @@ BOOST_FIXTURE_TEST_SUITE(net_tests, BasicTestingSetup)
6774BOOST_AUTO_TEST_CASE(caddrdb_read)
6875{
6976 CAddrManUncorrupted addrmanUncorrupted;
77+ addrmanUncorrupted.MakeDeterministic ();
7078
7179 CService addr1 = CService (" 250.7.1.1" , 8333 );
7280 CService addr2 = CService (" 250.7.2.2" , 9999 );
@@ -108,6 +116,7 @@ BOOST_AUTO_TEST_CASE(caddrdb_read)
108116BOOST_AUTO_TEST_CASE (caddrdb_read_corrupted)
109117{
110118 CAddrManCorrupted addrmanCorrupted;
119+ addrmanCorrupted.MakeDeterministic ();
111120
112121 // Test that the de-serialization of corrupted addrman throws an exception.
113122 CDataStream ssPeers1 = AddrmanToStream (addrmanCorrupted);
You can’t perform that action at this time.
0 commit comments