aboutsummaryrefslogtreecommitdiff
path: root/src/addrman.h
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2016-01-28 13:13:30 +0100
committerWladimir J. van der Laan <laanwj@gmail.com>2016-01-28 13:14:07 +0100
commit326ffed09bfcc209a2efd6a2ebc69edf6bd200b5 (patch)
treecf8f2a9a18a16cabbee7190923541e177c609779 /src/addrman.h
parent1e06bab804a248f08826fe5a199d8431fd4bed02 (diff)
parent40c87b6e6961e61d1cccdd248534e99f7a421564 (diff)
downloadbitcoin-326ffed09bfcc209a2efd6a2ebc69edf6bd200b5.tar.xz
Merge #7212: Adds unittests for CAddrMan and CAddrinfo, removes source of non-determinism.
40c87b6 Increase test coverage for addrman and addrinfo (Ethan Heilman)
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 cccecd1468..4f3de8d7c5 100644
--- a/src/addrman.h
+++ b/src/addrman.h
@@ -176,9 +176,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;
@@ -204,6 +201,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);
@@ -236,6 +235,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_();
@@ -570,11 +572,6 @@ public:
Check();
}
}
-
- //! Ensure that bucket placement is always the same for testing purposes.
- void MakeDeterministic(){
- nKey.SetNull(); //Do not use outside of tests.
- }
};