Some checks failed
rust-ci / checks (push) Has been cancelled
- Rust workspace: 7 library crates, icenetd CLI, icenet-city (Slint GUI) - Sim: fix false Delivered after a route cut, derive traffic class from payload size, per-link airtime slots (link capacity, queueing) - Docs: single docs/STATUS.md for all figures, remove v0.2/egui leftovers, drop unimplemented seed claims, uncheck store-and-forward - License: LGPL-3.0-or-later (LICENSE, LICENSES/GPL-3.0.txt)
79 lines
2 KiB
Rust
79 lines
2 KiB
Rust
//! Size limits: a payload label cannot smuggle bulk data onto a slow radio.
|
|
use icenet_core::{LinkKind, NodeId, TrafficClass};
|
|
use icenet_routing::{Link, choose_path};
|
|
|
|
fn slow_pair() -> ([NodeId; 2], [Link; 1]) {
|
|
let nodes = [NodeId(1), NodeId(2)];
|
|
let links = [Link {
|
|
a: nodes[0],
|
|
b: nodes[1],
|
|
kind: LinkKind::SlowRadio,
|
|
enabled: true,
|
|
}];
|
|
(nodes, links)
|
|
}
|
|
|
|
#[test]
|
|
fn oversized_text_is_treated_as_bulk_and_refused_on_slow_radio() {
|
|
let (nodes, links) = slow_pair();
|
|
let at_limit = TrafficClass::TEXT_MAX_BYTES;
|
|
assert!(
|
|
choose_path(
|
|
&nodes,
|
|
&links,
|
|
nodes[0],
|
|
nodes[1],
|
|
TrafficClass::Text,
|
|
at_limit
|
|
)
|
|
.is_some()
|
|
);
|
|
assert!(
|
|
choose_path(
|
|
&nodes,
|
|
&links,
|
|
nodes[0],
|
|
nodes[1],
|
|
TrafficClass::Text,
|
|
at_limit + 1
|
|
)
|
|
.is_none()
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn oversized_control_is_treated_as_text_then_bulk() {
|
|
let (nodes, links) = slow_pair();
|
|
let control = TrafficClass::Control;
|
|
let just_over = TrafficClass::CONTROL_MAX_BYTES + 1;
|
|
assert!(choose_path(&nodes, &links, nodes[0], nodes[1], control, just_over).is_some());
|
|
assert!(choose_path(&nodes, &links, nodes[0], nodes[1], control, 1_000_000).is_none());
|
|
}
|
|
|
|
#[test]
|
|
fn path_reports_the_index_of_every_link_it_uses() {
|
|
let nodes = [NodeId(1), NodeId(2), NodeId(3)];
|
|
let links = [
|
|
Link {
|
|
a: nodes[0],
|
|
b: nodes[1],
|
|
kind: LinkKind::SlowRadio,
|
|
enabled: false,
|
|
},
|
|
Link {
|
|
a: nodes[0],
|
|
b: nodes[1],
|
|
kind: LinkKind::Wired,
|
|
enabled: true,
|
|
},
|
|
Link {
|
|
a: nodes[1],
|
|
b: nodes[2],
|
|
kind: LinkKind::Wired,
|
|
enabled: true,
|
|
},
|
|
];
|
|
let path =
|
|
choose_path(&nodes, &links, nodes[0], nodes[2], TrafficClass::Text, 10).expect("connected");
|
|
assert_eq!(path.links, [1, 2]);
|
|
}
|