v0.3.14-pre.003

This commit is contained in:
2026-09-11 21:54:19 +02:00
parent 7bf938c19f
commit 6721a4142a
15 changed files with 872 additions and 22 deletions

View File

@@ -1,5 +1,5 @@
// file: crates/ksp-worker-raw-transaction-ingest-lib/unit_tests/continuity.rs
// version: 2
// version: 3
fn network() -> std::option::Option<ksp_store_lib::RawNetworkId> {
return match ksp_store_lib::RawNetworkId::new("mainnet") {
@@ -239,3 +239,39 @@ fn pre_002_gap_ledger_enforces_open_gap_bound_and_next_id_monotonicity() {
assert!(stale_next.validate_invariants().is_err());
return;
}
#[test]
fn pre_003_websocket_incident_anchor_is_inclusive_monotone_and_bounded() {
let mut anchor = match crate::RawTransactionIngestWebSocketIncidentAnchor::new(100, 1, 0, true, false) {
std::result::Result::Ok(value) => value,
std::result::Result::Err(error) => panic!("unexpected anchor failure: {error}"),
};
assert_eq!(anchor.start_slot(), 100);
assert_eq!(anchor.end_slot(), std::option::Option::None);
assert!(anchor.saw_reconnect());
assert!(!anchor.saw_overflow());
assert!(anchor.extend(2, 1, true, true).is_ok());
assert!(anchor.saw_reconnect());
assert!(anchor.saw_overflow());
assert!(anchor.extend(1, 1, false, false).is_err());
assert!(anchor.close_at(100 + super::MAX_RAW_TRANSACTION_INGEST_REPAIR_RANGE_SLOTS - 1).is_ok());
assert_eq!(anchor.end_slot(), std::option::Option::Some(100 + super::MAX_RAW_TRANSACTION_INGEST_REPAIR_RANGE_SLOTS - 1));
assert!(anchor.extend(3, 1, true, false).is_err());
return;
}
#[test]
fn pre_003_websocket_incident_anchor_rejects_missing_reason_reversal_and_oversize() {
assert!(crate::RawTransactionIngestWebSocketIncidentAnchor::new(100, 0, 0, false, false).is_err());
let mut reversed = match crate::RawTransactionIngestWebSocketIncidentAnchor::new(100, 0, 1, false, true) {
std::result::Result::Ok(value) => value,
std::result::Result::Err(error) => panic!("unexpected overflow anchor failure: {error}"),
};
assert!(reversed.close_at(99).is_err());
let mut oversized = match crate::RawTransactionIngestWebSocketIncidentAnchor::new(100, 1, 0, true, false) {
std::result::Result::Ok(value) => value,
std::result::Result::Err(error) => panic!("unexpected oversize anchor fixture failure: {error}"),
};
assert!(oversized.close_at(100 + super::MAX_RAW_TRANSACTION_INGEST_REPAIR_RANGE_SLOTS).is_err());
return;
}

View File

@@ -1,5 +1,5 @@
// file: crates/ksp-worker-raw-transaction-ingest-lib/unit_tests/runtime_resources.rs
// version: 23
// version: 24
fn grpc_endpoint(cluster: &str) -> std::option::Option<ksp_onchain_transport_lib::YellowstoneGrpcEndpointSettings> {
return grpc_endpoint_with_identity(cluster, "yellowstone-fixture", "fixture-provider");
@@ -3347,3 +3347,73 @@ async fn v0_3_13_pre_011_stop_racing_ready_source_fault_preserves_fault_and_join
assert_eq!(sibling_active.load(std::sync::atomic::Ordering::Acquire), 0);
return;
}
#[test]
fn v0_3_14_pre_003_websocket_reconnect_is_anchored_before_terminal_gap_projection() {
let (sender, receiver) = tokio::sync::watch::channel(crate::RawTransactionIngestProcessingFrontierProjection::empty());
let mut reporter = super::RawTransactionIngestProcessingFrontierReporter::new(sender);
assert!(reporter.observe_settled(100).is_ok());
assert!(reporter.observe_websocket_continuity(crate::RawTransactionIngestSourceState::Active, 0, 0).is_ok());
assert!(reporter.observe_websocket_continuity(crate::RawTransactionIngestSourceState::Reconnecting, 1, 0).is_ok());
let anchor = match reporter.websocket_incident_anchor {
std::option::Option::Some(value) => value,
std::option::Option::None => panic!("reconnect incident anchor missing"),
};
assert_eq!(anchor.start_slot(), 100);
assert_eq!(anchor.end_slot(), std::option::Option::None);
assert!(anchor.saw_reconnect());
assert!(!anchor.saw_overflow());
assert!(reporter.observe_websocket_continuity(crate::RawTransactionIngestSourceState::Active, 1, 0).is_ok());
let bounded = reporter.observe_websocket_post_incident_slot(105);
assert!(matches!(bounded, std::result::Result::Ok(true)));
let anchor = match reporter.websocket_incident_anchor {
std::option::Option::Some(value) => value,
std::option::Option::None => panic!("bounded reconnect incident anchor missing"),
};
assert_eq!(anchor.end_slot(), std::option::Option::Some(105));
let projection = *receiver.borrow();
assert_eq!(projection.source_reconnect_total(), 1);
assert_eq!(projection.source_replay_attempt_total(), 0);
assert_eq!(projection.source_continuity_gap_total(), 1);
return;
}
#[test]
fn v0_3_14_pre_003_websocket_overflow_and_reconnect_storm_share_earliest_anchor() {
let (sender, receiver) = tokio::sync::watch::channel(crate::RawTransactionIngestProcessingFrontierProjection::empty());
let mut reporter = super::RawTransactionIngestProcessingFrontierReporter::new(sender);
assert!(reporter.observe_settled(200).is_ok());
assert!(reporter.observe_websocket_continuity(crate::RawTransactionIngestSourceState::Active, 0, 1).is_ok());
assert!(reporter.observe_websocket_continuity(crate::RawTransactionIngestSourceState::Reconnecting, 1, 2).is_ok());
let anchor = match reporter.websocket_incident_anchor {
std::option::Option::Some(value) => value,
std::option::Option::None => panic!("overflow incident anchor missing"),
};
assert_eq!(anchor.start_slot(), 200);
assert_eq!(anchor.end_slot(), std::option::Option::None);
assert!(anchor.saw_reconnect());
assert!(anchor.saw_overflow());
let projection = *receiver.borrow();
assert_eq!(projection.source_reconnect_total(), 1);
assert_eq!(projection.source_continuity_gap_total(), 3);
let bounded = reporter.observe_websocket_post_incident_slot(201);
assert!(matches!(bounded, std::result::Result::Ok(true)));
return;
}
#[test]
fn v0_3_14_pre_003_websocket_incident_without_observed_slot_is_unbounded_and_counter_regression_fails() {
let (sender, _receiver) = tokio::sync::watch::channel(crate::RawTransactionIngestProcessingFrontierProjection::empty());
let mut reporter = super::RawTransactionIngestProcessingFrontierReporter::new(sender);
let unbounded = reporter.observe_websocket_continuity(crate::RawTransactionIngestSourceState::Reconnecting, 1, 0);
assert!(unbounded.is_err());
let unbounded = match unbounded {
std::result::Result::Ok(()) => return,
std::result::Result::Err(value) => value,
};
assert!(unbounded.context().iter().any(|context| {
return context.value() == "source.websocket_incident_unbounded";
}));
assert!(reporter.observe_websocket_continuity(crate::RawTransactionIngestSourceState::Active, 0, 0).is_err());
return;
}