diff options
author | practicalswift <practicalswift@users.noreply.github.com> | 2020-12-15 15:23:44 +0000 |
---|---|---|
committer | practicalswift <practicalswift@users.noreply.github.com> | 2020-12-16 12:00:15 +0000 |
commit | fee88237e03c21bf81f21098e6b89ecfa5327cee (patch) | |
tree | 16299238e6b798babf4074706bc59d161798f1a0 | |
parent | 685c428de0fb63ca6ec1419bb112f07d27bcdf14 (diff) |
Assert eviction at >= 29 candidates. Assert non-eviction at <= 20 candidates.
-rw-r--r-- | src/test/net_tests.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/test/net_tests.cpp b/src/test/net_tests.cpp index 282f5ea5bf..8281921dce 100644 --- a/src/test/net_tests.cpp +++ b/src/test/net_tests.cpp @@ -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. [...]" |