Skip to content

Add unit tests for eviction logic #19966

@practicalswift

Description

@practicalswift

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 ...

[[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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions