wind-network/windexer

Add Unit Tests for Account Processor Filter Logic

Ouverte

#13 ouverte le 16 mars 2025

 (0 commentaire) (0 réaction) (0 personne assignée)Rust (5 forks)auto 404
enhancementgood first issuetesting

Métriques du dépôt

Stars
 (14 étoiles)
Métriques de merge PR
 (Métriques PR en attente)

Description

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.

Guide contributeur