只有hello包实现多跳,还没加入业务数据
具体的还要看opencode和gpt记录接着优化
This commit is contained in:
49
sim/tests/test_multihop_exists.py
Normal file
49
sim/tests/test_multihop_exists.py
Normal file
@@ -0,0 +1,49 @@
|
||||
"""
|
||||
Test: Multihop Exists
|
||||
|
||||
Assert:
|
||||
- max_hop >= 2
|
||||
|
||||
This verifies that multi-hop routing is actually being used.
|
||||
"""
|
||||
|
||||
import pytest
|
||||
import random
|
||||
|
||||
from sim.main import run_simulation
|
||||
from sim import config
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def seed():
|
||||
return 42
|
||||
|
||||
|
||||
def test_multihop_exists(seed):
|
||||
"""Test that multi-hop routing is formed (hop >= 2)."""
|
||||
results = run_simulation(num_nodes=12, area_size=800, sim_time=200, seed=seed)
|
||||
|
||||
metrics = results["metrics"]
|
||||
max_hop = metrics.get("max_hop", 0)
|
||||
|
||||
print(f"Max hop: {max_hop}")
|
||||
print(f"Hop distribution: {metrics.get('hop_histogram', {})}")
|
||||
|
||||
assert max_hop >= 2, f"Multi-hop not formed: max_hop={max_hop}"
|
||||
|
||||
|
||||
def test_multihop_with_hop_histogram(seed):
|
||||
"""Test hop distribution shows multiple hops."""
|
||||
results = run_simulation(num_nodes=12, area_size=800, sim_time=300, seed=seed)
|
||||
|
||||
metrics = results["metrics"]
|
||||
hop_histogram = metrics.get("hop_histogram", {})
|
||||
|
||||
print(f"Hop histogram: {hop_histogram}")
|
||||
|
||||
# Should have at least 2 different hop counts
|
||||
assert len(hop_histogram) >= 1, "No hop distribution data"
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
pytest.main([__file__, "-v", "-s"])
|
||||
Reference in New Issue
Block a user