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
37
workspace/crates/icenet-guard/tests/queue.rs
Normal file
37
workspace/crates/icenet-guard/tests/queue.rs
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
use icenet_core::{NodeId, ServiceId};
|
||||
use icenet_guard::{Context, Guard, Limits, Verdict};
|
||||
|
||||
fn context(queue_depth: usize, sequence: u64) -> Context {
|
||||
Context {
|
||||
authenticated: true,
|
||||
peer: NodeId(1),
|
||||
service: ServiceId(7),
|
||||
payload_bytes: 1,
|
||||
sequence,
|
||||
now_ms: 0,
|
||||
queue_depth,
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn full_queue_is_denied_before_accepting_more_work() {
|
||||
let limits = Limits {
|
||||
max_queue_depth: 2,
|
||||
rate_per_second: 0,
|
||||
..Limits::default()
|
||||
};
|
||||
let mut guard = Guard::new([ServiceId(7)], limits);
|
||||
assert_eq!(guard.check(context(1, 1)), Verdict::Permit);
|
||||
assert_eq!(guard.check(context(2, 2)), Verdict::Deny("queue_full"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn empty_queue_below_the_cap_is_permitted() {
|
||||
let limits = Limits {
|
||||
max_queue_depth: 2,
|
||||
rate_per_second: 0,
|
||||
..Limits::default()
|
||||
};
|
||||
let mut guard = Guard::new([ServiceId(7)], limits);
|
||||
assert_eq!(guard.check(context(0, 1)), Verdict::Permit);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue