tests.rs

Overview

This file provides a comprehensive suite of tests and supporting functions for verifying the functionality and integration of the msquic-based QUIC transport implementation. It includes utilities to initialize logging, generate test credentials, and run various asynchronous integration and unit tests. The tests cover connection establishment, TLS credential validation, message sending and receiving, and low-level stream reading behavior. The file leverages both the msquic crate and the higher-level transport abstractions defined elsewhere in the project to validate inter-component behavior.

Detailed Explanations

Static Variables

Functions

init_logs()

Initializes the logging subsystem for test runs.

get_test_cred() -> Credential

Generates or loads a self-signed test TLS credential using OpenSSL CLI.

Module: unit_tests

Contains multiple asynchronous and synchronous tests validating the transport layer and utility functions.

Async Test: test_msquic_transport()

Struct: CertTest

Async Test: test_cert_rejection()

Async Test: test_example_raw_msquick_async()

Struct: MockAsyncReader

Function: create_transport_message(payload: &[u8]) -> Vec<u8>

Async Tests for read_message_from_stream

These tests validate the behavior of the read_message_from_stream function under various conditions:

Synchronous Test: test_cert()

Important Implementation Details and Algorithms

Interaction with Other Parts

Visual Diagram of the File Structure and Main Functions

flowchart TD
init_logs --> get_test_cred
get_test_cred --> test_msquic_transport
test_msquic_transport --> CertTest
CertTest --> test_cert_rejection
test_example_raw_msquick_async --> MockAsyncReader
MockAsyncReader --> create_transport_message
create_transport_message --> test_read_complete_message_in_one_chunk
create_transport_message --> test_read_message_in_multiple_chunks
create_transport_message --> test_read_empty_message
create_transport_message --> test_zero_reads
test_cert
classDef testfill fill:#f9f,stroke:#333,stroke-width:1px,color:#000
class init_logs,get_test_cred,test_msquic_transport,CertTest,test_cert_rejection,test_example_raw_msquick_async,MockAsyncReader,create_transport_message,test_read_complete_message_in_one_chunk,test_read_message_in_multiple_chunks,test_read_empty_message,test_zero_reads,test_cert testfill

Notation of Main Entities in Diagram