Skip to content

Commit fee8823

Browse files
Assert eviction at >= 29 candidates. Assert non-eviction at <= 20 candidates.
1 parent 685c428 commit fee8823

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/test/net_tests.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -893,6 +893,20 @@ BOOST_AUTO_TEST_CASE(node_eviction_test)
893893
},
894894
{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19}, random_context));
895895

896+
// An eviction is expected given >= 29 random eviction candidates. The eviction logic protects at most
897+
// four peers by net group, eight by lowest ping time, four by last time of novel tx, up to eight non-tx-relay
898+
// peers by last novel block time, and four more peers by last novel block time.
899+
if (number_of_nodes >= 29) {
900+
BOOST_CHECK(SelectNodeToEvict(GetRandomNodeEvictionCandidates(number_of_nodes, random_context)));
901+
}
902+
903+
// No eviction is expected given <= 20 random eviction candidates. The eviction logic protects at least
904+
// four peers by net group, eight by lowest ping time, four by last time of novel tx and four peers by last
905+
// novel block time.
906+
if (number_of_nodes <= 20) {
907+
BOOST_CHECK(!SelectNodeToEvict(GetRandomNodeEvictionCandidates(number_of_nodes, random_context)));
908+
}
909+
896910
// Cases left to test:
897911
// * "Protect the half of the remaining nodes which have been connected the longest. [...]"
898912
// * "Pick out up to 1/4 peers that are localhost, sorted by longest uptime. [...]"

0 commit comments

Comments
 (0)