Skip to content

Conversation

@mpaya5
Copy link
Contributor

@mpaya5 mpaya5 commented Sep 29, 2025

Fixes https://linear.app/genlayer-labs/issue/DXP-683/separate-re-group-unit-tests
Depends on https://linear.app/genlayer-labs/issue/DXP-695/solve-unit-tests / #1328

Summary

Reorganized unit tests to follow Clean Architecture and DDD principles, properly separating true unit tests from integration tests that were misplaced in the unit test directory.

Important Note: While this PR shows changes in both tests/unit/ and tests/integration/ folders, we're only reorganizing unit tests. The changes in integration/ are because 7 files in tests/unit/ were actually integration tests (they required mocking external dependencies like databases and APIs) and needed to be moved to their correct location.

Changes

🏗️ New Structure

  • Domain Layer (tests/unit/domain/): Pure business logic tests
  • Application Layer (tests/unit/application/): Use case and service tests
  • Integration Tests (tests/integration/): Moved misplaced tests requiring external dependencies

📦 Files Reorganized

Moved to Domain Layer (4 files):

  • consensus/unit/domain/consensus/ (VRF algorithm, test helpers)
  • test_types.pyunit/domain/types/test_domain_types.py

Moved to Application Layer (3 files):

  • test_create_nodes.pyunit/application/node_management/
  • test_providers.pyunit/application/node_management/test_provider_validation.py
  • test_validators_init.pyunit/application/initialization/

Moved to Integration Tests (7 files):

  • RPC/API tests → integration/infrastructure/rpc/
  • Database tests → integration/infrastructure/database/
  • Endpoint tests → integration/presentation/endpoints/

🗑️ Cleanup

  • Removed obsolete test_endpoint_generator*.py files
  • Cleaned up empty directories

Results

Metric Before After
Tests in root unit/ 14 0 ✅
Clear separation Mixed Domain/Application/Integration ✅
Architecture Module-based Layer-based (Clean Architecture) ✅

Benefits

  • Faster feedback: True unit tests isolated from infrastructure
  • Clear boundaries: Tests organized by architectural layer
  • Better maintainability: Easy to find and add tests
  • DDD alignment: Tests grouped by business capability

Testing

# Run only domain tests (pure business logic)
pytest tests/unit/domain/

# Run only application tests (use cases)
pytest tests/unit/application/

# Run integration tests separately
pytest tests/integration/

Breaking Changes

None. All tests maintain their functionality, just reorganized for better structure.

Summary by CodeRabbit

  • Tests
    • Added extensive new integration and unit tests for RPC, simulator sessions, validator initialization, and VRF behavior; removed legacy VRF tests.
  • Refactor
    • Unified validator handling under a centralized validators manager across RPC, simulator, and initialization flows.
  • Bug Fixes
    • Ensure fresher database reads and a standardized mock response format.
  • Chores
    • Updated CI compose/env setup and added explicit image tags for test runs.

coderabbitai[bot]

This comment was marked as resolved.

@kstroobants kstroobants self-assigned this Oct 15, 2025
coderabbitai[bot]

This comment was marked as resolved.

@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
23.4% Coverage on New Code (required ≥ 80%)
C Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants