Changeset View
Changeset View
Standalone View
Standalone View
src/test/addrman_tests.cpp
Show First 20 Lines • Show All 458 Lines • ▼ Show 20 Lines | BOOST_AUTO_TEST_CASE(caddrinfo_get_new_bucket) { | ||||
// Test: Make sure the buckets are what we expect | // Test: Make sure the buckets are what we expect | ||||
BOOST_CHECK_EQUAL(info1.GetNewBucket(nKey1), 786); | BOOST_CHECK_EQUAL(info1.GetNewBucket(nKey1), 786); | ||||
BOOST_CHECK_EQUAL(info1.GetNewBucket(nKey1, source1), 786); | BOOST_CHECK_EQUAL(info1.GetNewBucket(nKey1, source1), 786); | ||||
// Test: Make sure key actually randomizes bucket placement. A fail on | // Test: Make sure key actually randomizes bucket placement. A fail on | ||||
// this test could be a security issue. | // this test could be a security issue. | ||||
BOOST_CHECK(info1.GetNewBucket(nKey1) != info1.GetNewBucket(nKey2)); | BOOST_CHECK(info1.GetNewBucket(nKey1) != info1.GetNewBucket(nKey2)); | ||||
// Test: Ports should not effect bucket placement in the addr | // Test: Ports should not affect bucket placement in the addr | ||||
CAddrInfo info2 = CAddrInfo(addr2, source1); | CAddrInfo info2 = CAddrInfo(addr2, source1); | ||||
BOOST_CHECK(info1.GetKey() != info2.GetKey()); | BOOST_CHECK(info1.GetKey() != info2.GetKey()); | ||||
BOOST_CHECK_EQUAL(info1.GetNewBucket(nKey1), info2.GetNewBucket(nKey1)); | BOOST_CHECK_EQUAL(info1.GetNewBucket(nKey1), info2.GetNewBucket(nKey1)); | ||||
std::set<int> buckets; | std::set<int> buckets; | ||||
for (int i = 0; i < 255; i++) { | for (int i = 0; i < 255; i++) { | ||||
CAddrInfo infoi = CAddrInfo( | CAddrInfo infoi = CAddrInfo( | ||||
CAddress(ResolveService("250.1.1." + std::to_string(i)), NODE_NONE), | CAddress(ResolveService("250.1.1." + std::to_string(i)), NODE_NONE), | ||||
▲ Show 20 Lines • Show All 174 Lines • Show Last 20 Lines |