Skip to content

Kad — Expand integration and fuzz test coverage beyond helper-unit tests

Summary

The emulebb-build-tests harness already covers Kad helper logic for: - FastKad - SafeKad - KadPublishGuard - NodesDatSupport

And already covers the packet parser seam (BBUG_001–006 regression tests).

What is still missing (AUD_KAD_014): - Routing-table churn after simulated network change - Bootstrap queue behavior (import, probation, promotion) - Buddy/callback edge cases - Live-response quality scoring (FEAT-003) - Fuzz coverage for Kad packet and tag parsing

Proposed Test Categories

Integration Tests (deterministic)

Scenario What to verify
nodes.dat import from well-formed file Contacts appear in routing table
nodes.dat import from malformed file Import rejected, routing table unchanged
Network change (simulated IP change) Grace period engaged, no stale nodes.dat write
Bootstrap queue: probation → promotion Same-IP contact promoted after N successful verifications
Buddy request with RequireCrypt=true Correct error surfaced (BUG-005 regression)

Fuzz Targets

Target Parser
Kad UDP packet KademliaUDPListener::ProcessPacket()
Kad tag parsing All tag read paths in kademlia/io/DataIO.cpp
nodes.dat blob NodesDatSupport::InspectNodesDatFile()

Tools

  • Integration tests: extend existing emulebb-build-tests harness.
  • Fuzz targets: LLVM libFuzzer via clang (available in LLVM 22.1.0). Alternatively, MSVC ASan fuzzer mode.

Acceptance Criteria

  • [ ] At least 3 new Kad integration test scenarios added
  • [ ] At least 1 fuzz target for Kad UDP packet parsing
  • [ ] All new tests pass in the CI baseline workflow
  • [ ] Coverage of BUG-005 regression (Kad + RequireCrypt)

Prerequisite

CI-001 (CMake — fuzz targets require a CMake build configuration) CI-006 (ASan — fuzz + ASan is the standard combination)