1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
// 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
}
}