Initial import: ICE-NET research docs and Rust workspace (v0.4)
Some checks failed
rust-ci / checks (push) Has been cancelled
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)
This commit is contained in:
commit
2e61688eb3
141 changed files with 13993 additions and 0 deletions
41
workspace/crates/icenet-core/tests/types.rs
Normal file
41
workspace/crates/icenet-core/tests/types.rs
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
use icenet_core::{LinkKind, NodeId, ServiceId, TrafficClass};
|
||||
|
||||
#[test]
|
||||
fn slow_radio_is_not_allowed_for_bulk() {
|
||||
assert!(TrafficClass::Text.allows_slow_radio());
|
||||
assert!(TrafficClass::Control.allows_slow_radio());
|
||||
assert!(!TrafficClass::Bulk.allows_slow_radio());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn service_id_is_not_limited_to_tcp_ports() {
|
||||
assert!(ServiceId(77_777).0 > 65_535);
|
||||
assert_eq!(NodeId(42), NodeId(42));
|
||||
assert!(LinkKind::FastWireless.demo_bps() > LinkKind::SlowRadio.demo_bps());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn transfer_time_uses_ceiling_and_a_nonzero_minimum() {
|
||||
assert_eq!(LinkKind::SlowRadio.transfer_ms(1), 8);
|
||||
assert_eq!(LinkKind::Wired.transfer_ms(1), 1);
|
||||
assert_eq!(LinkKind::FastWireless.transfer_ms(0), 1);
|
||||
assert_eq!(LinkKind::SlowRadio.transfer_ms(1_000), 8_000);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn class_is_derived_from_size_not_only_from_the_label() {
|
||||
use TrafficClass::{Bulk, Control, Text};
|
||||
assert_eq!(
|
||||
Control.effective_for(TrafficClass::CONTROL_MAX_BYTES),
|
||||
Control
|
||||
);
|
||||
assert_eq!(
|
||||
Control.effective_for(TrafficClass::CONTROL_MAX_BYTES + 1),
|
||||
Text
|
||||
);
|
||||
assert_eq!(Text.effective_for(TrafficClass::TEXT_MAX_BYTES), Text);
|
||||
assert_eq!(Text.effective_for(TrafficClass::TEXT_MAX_BYTES + 1), Bulk);
|
||||
assert_eq!(Control.effective_for(5_000_000), Bulk);
|
||||
// A Bulk label never shrinks, however small the payload is.
|
||||
assert_eq!(Bulk.effective_for(1), Bulk);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue