Changeset View
Changeset View
Standalone View
Standalone View
src/test/addrman_tests.cpp
Show All 16 Lines | public: | ||||
CAddrManTest() { state = 1; } | CAddrManTest() { state = 1; } | ||||
//! Ensure that bucket placement is always the same for testing purposes. | //! Ensure that bucket placement is always the same for testing purposes. | ||||
void MakeDeterministic() { | void MakeDeterministic() { | ||||
nKey.SetNull(); | nKey.SetNull(); | ||||
insecure_rand = FastRandomContext(true); | insecure_rand = FastRandomContext(true); | ||||
} | } | ||||
int RandomInt(int nMax) { | int RandomInt(int nMax) override { | ||||
state = (CHashWriter(SER_GETHASH, 0) << state).GetHash().GetCheapHash(); | state = (CHashWriter(SER_GETHASH, 0) << state).GetHash().GetCheapHash(); | ||||
return (unsigned int)(state % nMax); | return (unsigned int)(state % nMax); | ||||
} | } | ||||
CAddrInfo *Find(const CNetAddr &addr, int *pnId = nullptr) { | CAddrInfo *Find(const CNetAddr &addr, int *pnId = nullptr) { | ||||
return CAddrMan::Find(addr, pnId); | return CAddrMan::Find(addr, pnId); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 481 Lines • Show Last 20 Lines |