ant-quic 0.27.2

QUIC transport protocol with advanced NAT traversal for P2P networks
Documentation
// Copyright 2024 Saorsa Labs Ltd.
//
// This Saorsa Network Software is licensed under the General Public License (GPL), version 3.
// Please see the file LICENSE-GPL, or visit <http://www.gnu.org/licenses/> for the full text.
//
// Full details available at https://saorsalabs.com/licenses


// Temporary test file to verify NAT traversal functionality without metrics
// This will be integrated into the main test suite after metrics removal

#[cfg(test)]
mod nat_traversal_functional_tests {
    use crate::{
        // v0.13.0: NatTraversalRole removed - all nodes are symmetric P2P
        nat_traversal_api::NatTraversalEndpoint,
        candidate_discovery::CandidateAddress,
        transport_parameters::PreferredAddress,
    };
    use std::net::{IpAddr, Ipv4Addr, SocketAddr};
    use std::time::Duration;

    #[tokio::test]
    async fn test_nat_traversal_discovers_candidates_without_metrics() {
        // Create NAT traversal endpoint (v0.13.0: no role parameter)
        let endpoint = NatTraversalEndpoint::new(
            vec![], // bootstrap peers
        ).await.expect("Failed to create endpoint");

        // Add some test candidates
        let candidates = vec![
            CandidateAddress {
                addr: SocketAddr::new(IpAddr::V4(Ipv4Addr::new(192, 168, 1, 100)), 9000),
                priority: 100,
                source: crate::candidate_discovery::CandidateSource::Local,
            },
            CandidateAddress {
                addr: SocketAddr::new(IpAddr::V4(Ipv4Addr::new(10, 0, 0, 50)), 9001),
                priority: 90,
                source: crate::candidate_discovery::CandidateSource::Local,
            },
        ];

        // Verify we can add candidates without relying on stats
        for candidate in &candidates {
            // In real implementation, this would add to internal state
            // For now, we're just verifying the API works
        }

        // Verify functionality without checking counters
        // The actual implementation would check internal state
        // assert!(endpoint.has_candidates()); // This method would need to be added
    }

    #[tokio::test]
    async fn test_connection_establishment_without_metrics() {
        // Test that connections can be established without relying on success counters
        let client_endpoint = NatTraversalEndpoint::new(
            vec![], // bootstrap peers
        ).await.expect("Failed to create client endpoint");

        let server_endpoint = NatTraversalEndpoint::new(
            vec![], // bootstrap peers
        ).await.expect("Failed to create server endpoint");

        // In a real test, we would:
        // 1. Exchange candidates
        // 2. Attempt connection
        // 3. Verify connection state (not stats)
        
        // For now, this demonstrates the test pattern
    }

    #[tokio::test]
    async fn test_hole_punching_success_without_metrics() {
        // Test hole punching by verifying actual connectivity, not attempt counters
        
        // This would:
        // 1. Set up two endpoints behind NAT
        // 2. Perform hole punching
        // 3. Verify by sending actual data through the punched hole
        // 4. No assertions on hole_punch_attempts or hole_punch_successes
    }
}