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
36
workspace/crates/icenet-wire/tests/frames.rs
Normal file
36
workspace/crates/icenet-wire/tests/frames.rs
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
use icenet_core::{ServiceId, TrafficClass};
|
||||
use icenet_wire::{Frame, FrameError, MAX_PAYLOAD_BYTES, decode, encode};
|
||||
|
||||
#[test]
|
||||
fn frame_round_trip() {
|
||||
let frame = Frame {
|
||||
class: TrafficClass::Text,
|
||||
service: ServiceId(77_777),
|
||||
payload: b"hello".to_vec(),
|
||||
};
|
||||
let packed = encode(&frame).expect("valid frame");
|
||||
assert_eq!(decode(&packed), Ok(frame));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rejects_invalid_lengths_and_invalid_classes() {
|
||||
assert_eq!(decode(b"hi"), Err(FrameError::Truncated));
|
||||
let mut frame = encode(&Frame {
|
||||
class: TrafficClass::Control,
|
||||
service: ServiceId(1),
|
||||
payload: vec![],
|
||||
})
|
||||
.unwrap();
|
||||
frame[3] = 255;
|
||||
assert_eq!(decode(&frame), Err(FrameError::InvalidClass));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn refuses_oversized_payload() {
|
||||
let frame = Frame {
|
||||
class: TrafficClass::Bulk,
|
||||
service: ServiceId(1),
|
||||
payload: vec![0; MAX_PAYLOAD_BYTES + 1],
|
||||
};
|
||||
assert_eq!(encode(&frame), Err(FrameError::TooLarge));
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue