wind-network/windexer

Add Unit Tests for Account Processor Filter Logic

Offen

#13 geöffnet am 16.03.2025

 (0 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)Rust (5 Forks)auto 404
enhancementgood first issuetesting

Repository-Metriken

Stars
 (14 Sterne)
PR-Merge-Metriken
 (PR-Metriken ausstehend)

Beschreibung

The account processor's filter logic in account.rs lacks comprehensive unit tests, making it difficult to verify its correctness for various filter configurations.


Problem

The process_account_update function contains filter logic with multiple paths based on account selection criteria. However:

  • These different paths and edge cases are not fully covered by unit tests.
  • Changes to the filtering logic risk breaking functionality without proper test coverage.

Required Changes

  1. Create unit tests in crates/windexer-geyser/src/processor/account.rs to cover:

    • Wildcard filters ("*")
    • Specific account filters
    • Owner filters
    • Combinations of account and owner filters
    • Edge cases, such as:
      • Empty filters
      • Invalid accounts
  2. Documentation:

    • Add comments for each test case explaining what it is testing and why.

Implementation Hints

  1. Use the Rust #[test] attribute to define unit tests.
  2. Mock any required dependencies or inputs for the process_account_update function.
  3. Example test structure:
    #[test]
    fn test_wildcard_filter() {
        let result = process_account_update("*", /* other params */);
        assert!(result.is_ok());
        // Add additional assertions for expected behavior
    }
    
  4. Write separate tests for each filter type and edge case.

Acceptance Criteria

  • Unit tests added for all filter types (*, specific accounts, owners, combinations).
  • Edge cases (e.g., empty filters, invalid accounts) are covered.
  • Each test is documented with clear explanations.
  • Tests pass successfully without modifying existing functionality.

Contributor Guide