v0.3.5-pre.002

This commit is contained in:
2026-08-31 10:36:10 +02:00
parent 75e8030b07
commit 0dd722ffca
8 changed files with 516 additions and 90 deletions

View File

@@ -0,0 +1,52 @@
// file: crates/ksp-interface-lib/unit_tests/slot_lifecycle.rs
// version: 1
#[test]
fn slot_lifecycle_stages_are_distinct_copy_and_complete_for_the_admitted_family() {
fn assert_copy<T: Copy>() {}
assert_copy::<crate::SlotLifecycleStage>();
let stages = [
crate::SlotLifecycleStage::Processed,
crate::SlotLifecycleStage::FirstShredReceived,
crate::SlotLifecycleStage::Completed,
crate::SlotLifecycleStage::CreatedBank,
crate::SlotLifecycleStage::Dead,
crate::SlotLifecycleStage::OptimisticallyConfirmed,
crate::SlotLifecycleStage::Rooted,
];
for (index, stage) in stages.iter().enumerate() {
for other in stages.iter().skip(index + 1) {
assert_ne!(stage, other);
}
}
}
#[test]
fn slot_lifecycle_event_preserves_full_u64_slot_and_stage() {
fn assert_copy<T: Copy>() {}
assert_copy::<crate::SlotLifecycleEvent>();
let event = crate::SlotLifecycleEvent::new(u64::MAX, crate::SlotLifecycleStage::Rooted);
assert_eq!(event.slot(), u64::MAX);
assert_eq!(event.stage(), crate::SlotLifecycleStage::Rooted);
let copied = event;
assert_eq!(event, copied);
}
#[test]
fn slot_lifecycle_debug_is_bounded_and_contains_only_shared_fields() {
let event = crate::SlotLifecycleEvent::new(42, crate::SlotLifecycleStage::OptimisticallyConfirmed);
let debug = std::format!("{event:?}");
assert!(debug.len() <= 128);
assert!(debug.contains("slot: 42"));
assert!(debug.contains("OptimisticallyConfirmed"));
assert!(!debug.contains("provider"));
assert!(!debug.contains("yellowstone"));
assert!(!debug.contains("websocket"));
}