test: speed up and simplify peer_eviction_test

This speeds up the test significantly, which helps when
running it repeatedly.

Suggest reviewing the diff with:

colorMoved = dimmed-zebra
colorMovedWs = allow-indentation-change
This commit is contained in:
Jon Atack 2021-04-19 15:08:25 +02:00
parent 1cde800523
commit 519e76bb64
No known key found for this signature in database
GPG Key ID: 4F5721B3D0E3921D

View File

@ -15,11 +15,6 @@
BOOST_FIXTURE_TEST_SUITE(net_peer_eviction_tests, BasicTestingSetup) BOOST_FIXTURE_TEST_SUITE(net_peer_eviction_tests, BasicTestingSetup)
namespace {
constexpr int NODE_EVICTION_TEST_ROUNDS{10};
constexpr int NODE_EVICTION_TEST_UP_TO_N_NODES{200};
} // namespace
std::vector<NodeEvictionCandidate> GetRandomNodeEvictionCandidates(const int n_candidates, FastRandomContext& random_context) std::vector<NodeEvictionCandidate> GetRandomNodeEvictionCandidates(const int n_candidates, FastRandomContext& random_context)
{ {
std::vector<NodeEvictionCandidate> candidates; std::vector<NodeEvictionCandidate> candidates;
@ -257,8 +252,7 @@ BOOST_AUTO_TEST_CASE(peer_eviction_test)
{ {
FastRandomContext random_context{true}; FastRandomContext random_context{true};
for (int i = 0; i < NODE_EVICTION_TEST_ROUNDS; ++i) { for (int number_of_nodes = 0; number_of_nodes < 200; ++number_of_nodes) {
for (int number_of_nodes = 0; number_of_nodes < NODE_EVICTION_TEST_UP_TO_N_NODES; ++number_of_nodes) {
// Four nodes with the highest keyed netgroup values should be // Four nodes with the highest keyed netgroup values should be
// protected from eviction. // protected from eviction.
BOOST_CHECK(!IsEvicted( BOOST_CHECK(!IsEvicted(
@ -343,6 +337,5 @@ BOOST_AUTO_TEST_CASE(peer_eviction_test)
// * "Identify the network group with the most connections and youngest member. [...]" // * "Identify the network group with the most connections and youngest member. [...]"
} }
} }
}
BOOST_AUTO_TEST_SUITE_END() BOOST_AUTO_TEST_SUITE_END()