mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-07-03 12:11:52 +02:00
Assert eviction at >= 29 candidates. Assert non-eviction at <= 20 candidates.
This commit is contained in:
@ -893,6 +893,20 @@ BOOST_AUTO_TEST_CASE(node_eviction_test)
|
||||
},
|
||||
{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19}, random_context));
|
||||
|
||||
// An eviction is expected given >= 29 random eviction candidates. The eviction logic protects at most
|
||||
// four peers by net group, eight by lowest ping time, four by last time of novel tx, up to eight non-tx-relay
|
||||
// peers by last novel block time, and four more peers by last novel block time.
|
||||
if (number_of_nodes >= 29) {
|
||||
BOOST_CHECK(SelectNodeToEvict(GetRandomNodeEvictionCandidates(number_of_nodes, random_context)));
|
||||
}
|
||||
|
||||
// No eviction is expected given <= 20 random eviction candidates. The eviction logic protects at least
|
||||
// four peers by net group, eight by lowest ping time, four by last time of novel tx and four peers by last
|
||||
// novel block time.
|
||||
if (number_of_nodes <= 20) {
|
||||
BOOST_CHECK(!SelectNodeToEvict(GetRandomNodeEvictionCandidates(number_of_nodes, random_context)));
|
||||
}
|
||||
|
||||
// Cases left to test:
|
||||
// * "Protect the half of the remaining nodes which have been connected the longest. [...]"
|
||||
// * "Pick out up to 1/4 peers that are localhost, sorted by longest uptime. [...]"
|
||||
|
Reference in New Issue
Block a user