Skip to content

Focus 3: Test Coverage #33

@rainliu

Description

@rainliu

Focus 3: Test Coverage

Current State

The codebase has growing test coverage, but there's room for improvement:

Category Current Target
Unit tests Partial 80%+ line coverage
Integration tests 28 test files Comprehensive scenarios
Interop tests Chrome, Firefox All major browsers
Fuzz tests Limited Critical parsers

Unit Test Expansion

Priority areas for unit testing:

  1. SDP parsing and generation — Complex edge cases in offer/answer
  2. ICE state machine — All state transitions and error conditions
  3. DTLS handshake — Certificate validation, cipher negotiation
  4. SCTP association — Stream management, congestion control
  5. Interceptor logic — NACK timing, RTCP report generation

Example test structure:

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_ice_state_transitions() {
        // Test all valid state transitions
        // Test invalid transition handling
        // Test event emission
    }

    #[test]
    fn test_nack_timing_accuracy() {
        // Verify NACK generation timing
        // Test RTT-based retransmit intervals
    }
}

Integration Test Expansion

Planned integration test scenarios:

  • Multi-party conferencing (3+ peers)
  • Renegotiation (adding/removing tracks mid-session)
  • Network condition simulation (packet loss, delay, reordering)
  • Long-running sessions (stability over hours)
  • ICE restart scenarios
  • TURN relay failover
  • Simulcast layer switching
  • DataChannel flow control under load

Fuzz Testing

Critical parsers should be fuzz-tested:

// Using cargo-fuzz or libfuzzer
fuzz_target!(|data: &[u8]| {
    let _ = RtpPacket::unmarshal(data);
});

fuzz_target!(|data: &[u8]| {
    let _ = StunMessage::unmarshal(data);
});

Priority fuzz targets:

  • RTP/RTCP packet parsing
  • STUN message parsing
  • SDP parsing
  • SCTP chunk parsing
  • DTLS record parsing

Metadata

Metadata

Assignees

No one assigned

    Labels

    p1high priority

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions