Skip to content

Test suite audit: broken tests, stale assertions, and coverage gaps #15

Description

@ayushsingh82

Went through the repo to get oriented (ran the local setup, pytest tests/unit/, and checked coverage) and found a few things worth flagging before sending PRs.

Findings

1. tests/unit/test_streak_calculation.py currently fails to even collect, and appears to have never run successfully:

  • 4 syntax errors — missing closing parens on int(datetime(...).timestamp() calls (lines 139, 179, 225-226, 272)
  • Every test depends on a clean_db fixture that doesn't exist anywhere in the repo — there's no conftest.py at all
  • Several tests call sample_address() and current_time() as functions, but those are already-resolved pytest fixture values (a str and an int) — calling them raises TypeError
  • Tests pass change_time= to log_status_change(), a keyword argument that function doesn't accept (database.py always stamps datetime.now() internally)

2. tests/unit/test_subgraph_fetch.py::test_queries_network_subgraph_for_active_indexers fails today:

  • Asserts mock_post.assert_called_once(), but retrieveActiveIndexers() now also queries the ENS subgraph (2 calls total) — looks like a pre-ENS-resolution assertion that was never updated.

3. No CI test gate. .github/workflows/ only has docker.yml and release.yml — nothing runs pytest on push/PR, which is presumably how 1 & 2 went unnoticed.

4. Coverage gaps, once the suite can actually run:

  • generate_dashboard.py sits at ~20% coverage (841/1049 lines), including the three-pass checkEligibility() logic the CLAUDE.md calls out as the critical path
  • frontend/src/lib/status.js (pure eligibility-status domain logic, ~107 lines) has zero test coverage — no JS test framework is configured anywhere in frontend/package.json

Proposed sequence

  1. Fix test_streak_calculation.py (add a real conftest.py + clean_db fixture, fix the syntax/API-mismatch bugs) and the stale test_subgraph_fetch.py assertion — straight bug fixes, no design decisions involved.
  2. Add a lightweight Vitest setup (Vite-native, no conflict with the existing build pipeline) and unit tests for status.js.
  3. Targeted coverage for checkEligibility() / write_dashboard_data() in generate_dashboard.py.
  4. Once 1-3 land: propose a CI workflow that actually runs pytest + the new Vitest suite, so this doesn't silently regress again.

Happy to send PRs for 1 and 2 — wanted to flag the scope first since this touches a few areas. Let me know if you'd rather I take a different angle, or if any of this is already known/in progress.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions