Skip to content

test(discovery): improve service.py coverage to 91%#507

Merged
tcoratger merged 1 commit intoleanEthereum:mainfrom
Smartdevs17:test/coverage-discovery-service
Apr 4, 2026
Merged

test(discovery): improve service.py coverage to 91%#507
tcoratger merged 1 commit intoleanEthereum:mainfrom
Smartdevs17:test/coverage-discovery-service

Conversation

@Smartdevs17
Copy link
Copy Markdown
Contributor

@Smartdevs17 Smartdevs17 commented Apr 4, 2026

Summary

Improve coverage for src/lean_spec/subspecs/networking/discovery/service.py from 61% to 91% (target ≥90%).

What's covered

  • find_node() — Kademlia iterative lookup with parallel querying and iterative deepening
  • _query_node() — FINDNODE query with distance handling
  • _ping_node() — Ping and bond with success/failure paths
  • _process_message() / _handle_message() — Message dispatch
  • _handle_findnode() — FINDNODE handler with distance filtering
  • Background loops: _refresh_loop(), _revalidation_loop(), _cleanup_loop() with error resilience
  • _process_discovered_enr() — ENR validation with distance mismatch, invalid ENR, own ENR, and dedup checks
  • _bootstrap() — Bootnode initialization with exception handling
  • _enr_to_entry() — ENR to node entry conversion

Test Results

  • 77 tests passing
  • 91% coverage on service.py (258 statements, 17 missed)
  • All quality checks pass (ruff, typecheck, codespell)

@tcoratger @unnawut

Closes #495

…ew issues

- Remove in-function imports per CLAUDE.md conventions
- Merge duplicate *Extended test classes into primary classes
- Remove redundant/weak tests
- Fix weak assertions (>= 0 → >= 1)
- Add test for bootstrap exception handling
@Smartdevs17 Smartdevs17 changed the title test(discovery): improve service.py coverage to 91% and fix code review issues test(discovery): improve service.py coverage to 91% Apr 4, 2026
@tcoratger tcoratger merged commit dbc2e77 into leanEthereum:main Apr 4, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test: improve coverage for discovery/service.py (61% → 90%+)

2 participants