只有hello包实现多跳,还没加入业务数据
具体的还要看opencode和gpt记录接着优化
This commit is contained in:
59
sim/tests/test_channel_not_saturated.py
Normal file
59
sim/tests/test_channel_not_saturated.py
Normal file
@@ -0,0 +1,59 @@
|
||||
"""
|
||||
Test: Channel Not Saturated
|
||||
|
||||
Assert:
|
||||
- utilization < 0.7
|
||||
|
||||
This verifies that the channel is not congested.
|
||||
"""
|
||||
|
||||
import pytest
|
||||
import random
|
||||
|
||||
from sim.main import run_simulation
|
||||
from sim import config
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def seed():
|
||||
return 42
|
||||
|
||||
|
||||
def test_channel_not_saturated(seed):
|
||||
"""Test that channel utilization is below saturation threshold."""
|
||||
results = run_simulation(num_nodes=12, area_size=800, sim_time=200, seed=seed)
|
||||
|
||||
metrics = results["metrics"]
|
||||
utilization = metrics.get("channel_utilization", 0)
|
||||
|
||||
print(f"Channel utilization: {utilization}%")
|
||||
|
||||
# Channel should not be saturated (< 70%)
|
||||
assert utilization < 70, f"Channel saturated: {utilization}%"
|
||||
|
||||
|
||||
def test_channel_utilization_healthy_range(seed):
|
||||
"""Test that channel utilization is in healthy range."""
|
||||
results = run_simulation(num_nodes=12, area_size=800, sim_time=200, seed=seed)
|
||||
|
||||
metrics = results["metrics"]
|
||||
utilization = metrics.get("channel_utilization", 0)
|
||||
|
||||
print(f"Channel utilization: {utilization}%")
|
||||
|
||||
# Get network state
|
||||
if utilization < 30:
|
||||
state = "HEALTHY"
|
||||
elif utilization < 60:
|
||||
state = "ACCEPTABLE"
|
||||
else:
|
||||
state = "CONGESTED"
|
||||
|
||||
print(f"Network state: {state}")
|
||||
|
||||
# Just verify we can calculate it
|
||||
assert utilization >= 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
pytest.main([__file__, "-v", "-s"])
|
||||
Reference in New Issue
Block a user