aboutsummaryrefslogtreecommitdiff
path: root/src/addrman.h
diff options
context:
space:
mode:
authorEthan Heilman <Ethan.R.Heilman@gmail.com>2015-12-12 22:34:08 -0500
committerEthanHeilman <ethan.r.heilman@gmail.com>2016-01-27 10:50:58 -0500
commit40c87b6e6961e61d1cccdd248534e99f7a421564 (patch)
tree2923a3410b96ab4c21359b4b639540005e1ef979 /src/addrman.h
parent473ad1bb026986db2569fff278d8957363f758f8 (diff)
Increase test coverage for addrman and addrinfo
Adds several unittests for CAddrMan and CAddrInfo. Increases the accuracy of addrman tests. Removes non-determinism in tests by overriding the random number generator. Extracts testing code from addrman class to test class.
Diffstat (limited to 'src/addrman.h')
-rw-r--r--src/addrman.h13
1 files changed, 5 insertions, 8 deletions
diff --git a/src/addrman.h b/src/addrman.h
index 1123caabfa..26a6dae473 100644
--- a/src/addrman.h
+++ b/src/addrman.h
@@ -175,9 +175,6 @@ private:
//! critical section to protect the inner data structures
mutable CCriticalSection cs;
- //! secret key to randomize bucket select with
- uint256 nKey;
-
//! last used nId
int nIdCount;
@@ -203,6 +200,8 @@ private:
int vvNew[ADDRMAN_NEW_BUCKET_COUNT][ADDRMAN_BUCKET_SIZE];
protected:
+ //! secret key to randomize bucket select with
+ uint256 nKey;
//! Find an entry.
CAddrInfo* Find(const CNetAddr& addr, int *pnId = NULL);
@@ -235,6 +234,9 @@ protected:
//! Select an address to connect to, if newOnly is set to true, only the new table is selected from.
CAddrInfo Select_(bool newOnly);
+ //! Wraps GetRandInt to allow tests to override RandomInt and make it determinismistic.
+ virtual int RandomInt(int nMax);
+
#ifdef DEBUG_ADDRMAN
//! Perform consistency check. Returns an error code or zero.
int Check_();
@@ -569,11 +571,6 @@ public:
Check();
}
}
-
- //! Ensure that bucket placement is always the same for testing purposes.
- void MakeDeterministic(){
- nKey.SetNull(); //Do not use outside of tests.
- }
};