The eviction logic is one of the most important parts in our code base: a bug in the eviction logic could allow for attacker triggered network partitioning.
Unfortunately the eviction logic is currently not tested properly.
The unit tests and fuzz tests don’t cover the eviction logic at all.
The functional tests cover some parts of the eviction logic but the coverage is spotty/incomplete.
Unfortunately CConnman::AttemptToEvictConnection
is currently somewhat tricky to test.
To solve this I suggest simplifying CConnman::AttemptToEvictConnection()
by introducing a new function …
0[[nodiscard]] Optional<NodeEvictionCandidate> SelectNodeToEvict(std::vector<NodeEvictionCandidate> vEvictionCandidates)
… which would be called from the now much simplified CConnman::AttemptToEvictConnection
.
SelectNodeToEvict
would contain all eviction selection logic and could thus be tested trivially.