v29.4-roots.1 · Commit 3: [PATCH 03/13] policy: restore conservative relay and network controls
src/test/net_peer_eviction_tests.cpp
Before: src/test/net_peer_eviction_tests.cpp · After: src/test/net_peer_eviction_tests.cpp
File metadata
index d9e1c2332e840ef51b081f6edb2a744912fed574..70c3340a041d4fe46cadf9e7497e4f5aba9859ed 100644
Download original patch · Release notes
Diff rows 1–24 of 24. Line numbers refer to the original before/after files.
+ Added− RemovedUnmarked lines are context.
Scroll the code area horizontally to read long lines. Before is on the left; after is on the right. Unified view fits narrow screens more easily.
src/test/net_peer_eviction_tests.cpp
CHANGED
|
@@ -573,7 +573,7 @@ BOOST_AUTO_TEST_CASE(peer_protection_test)
|
|
| 573 |
bool IsEvicted(std::vector<NodeEvictionCandidate> candidates, const std::unordered_set<NodeId>& node_ids, FastRandomContext& random_context)
|
| 574 |
{
|
| 575 |
std::shuffle(candidates.begin(), candidates.end(), random_context);
|
| 576 |
-
const std::optional<NodeId> evicted_node_id = SelectNodeToEvict(std::move(candidates));
|
| 577 |
if (!evicted_node_id) {
|
| 578 |
return false;
|
| 579 |
}
|
|
@@ -666,14 +666,14 @@ BOOST_AUTO_TEST_CASE(peer_eviction_test)
|
|
| 666 |
// four peers by net group, eight by lowest ping time, four by last time of novel tx, up to eight non-tx-relay
|
| 667 |
// peers by last novel block time, and four more peers by last novel block time.
|
| 668 |
if (number_of_nodes >= 29) {
|
| 669 |
-
BOOST_CHECK(SelectNodeToEvict(GetRandomNodeEvictionCandidates(number_of_nodes, random_context)));
|
| 670 |
}
|
| 671 |
|
| 672 |
// No eviction is expected given <= 20 random eviction candidates. The eviction logic protects at least
|
| 673 |
// four peers by net group, eight by lowest ping time, four by last time of novel tx and four peers by last
|
| 674 |
// novel block time.
|
| 675 |
if (number_of_nodes <= 20) {
|
| 676 |
-
BOOST_CHECK(!SelectNodeToEvict(GetRandomNodeEvictionCandidates(number_of_nodes, random_context)));
|
| 677 |
}
|
| 678 |
|
| 679 |
// Cases left to test:
|
|
|
|
| 573 |
bool IsEvicted(std::vector<NodeEvictionCandidate> candidates, const std::unordered_set<NodeId>& node_ids, FastRandomContext& random_context)
|
| 574 |
{
|
| 575 |
std::shuffle(candidates.begin(), candidates.end(), random_context);
|
| 576 |
+
const std::optional<NodeId> evicted_node_id = SelectNodeToEvict(std::move(candidates), /*force=*/false);
|
| 577 |
if (!evicted_node_id) {
|
| 578 |
return false;
|
| 579 |
}
|
|
|
|
| 666 |
// four peers by net group, eight by lowest ping time, four by last time of novel tx, up to eight non-tx-relay
|
| 667 |
// peers by last novel block time, and four more peers by last novel block time.
|
| 668 |
if (number_of_nodes >= 29) {
|
| 669 |
+
BOOST_CHECK(SelectNodeToEvict(GetRandomNodeEvictionCandidates(number_of_nodes, random_context), /*force=*/false));
|
| 670 |
}
|
| 671 |
|
| 672 |
// No eviction is expected given <= 20 random eviction candidates. The eviction logic protects at least
|
| 673 |
// four peers by net group, eight by lowest ping time, four by last time of novel tx and four peers by last
|
| 674 |
// novel block time.
|
| 675 |
if (number_of_nodes <= 20) {
|
| 676 |
+
BOOST_CHECK(!SelectNodeToEvict(GetRandomNodeEvictionCandidates(number_of_nodes, random_context), /*force=*/false));
|
| 677 |
}
|
| 678 |
|
| 679 |
// Cases left to test:
|