mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-03 09:56:38 -05:00
Assert eviction at >= 29 candidates. Assert non-eviction at <= 20 candidates.
This commit is contained in:
parent
685c428de0
commit
fee88237e0
1 changed files with 14 additions and 0 deletions
|
@ -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. [...]"
|
||||
|
|
Loading…
Add table
Reference in a new issue