v0.2.8-pre.007-fix.001

This commit is contained in:
2026-08-23 16:11:44 +02:00
parent 56b9ce6abc
commit 3b64d1e0ec
5 changed files with 221 additions and 13 deletions

View File

@@ -1,5 +1,5 @@
// file: crates/ksp-onchain-transport-lib/unit_tests/ws_session.rs
// version: 8
// version: 9
use futures_util::SinkExt; // rust-rules: trait-import
use futures_util::StreamExt; // rust-rules: trait-import
@@ -186,6 +186,7 @@ async fn yield_runtime_steps() {
for _ in 0..16 {
tokio::task::yield_now().await;
}
return;
}
#[tokio::test(flavor = "current_thread")]
@@ -451,6 +452,7 @@ async fn helius_heartbeat_sends_ping_at_sixty_seconds_and_rearms() {
});
let session = crate::HeliusLaserStreamWsSession::connect(helius_local_endpoint(url.as_str())).await.expect("Helius fixture session must connect");
tokio::time::pause();
yield_runtime_steps().await;
tokio::time::advance(std::time::Duration::from_secs(59)).await;
yield_runtime_steps().await;
assert!(matches!(ping_rx.try_recv(), std::result::Result::Err(tokio::sync::mpsc::error::TryRecvError::Empty)));
@@ -520,11 +522,13 @@ async fn helius_explicit_close_cancels_heartbeat_before_deadline() {
});
let session = crate::HeliusLaserStreamWsSession::connect(helius_local_endpoint(url.as_str())).await.expect("Helius close fixture session must connect");
tokio::time::pause();
yield_runtime_steps().await;
tokio::time::advance(std::time::Duration::from_secs(30)).await;
yield_runtime_steps().await;
assert!(matches!(ping_rx.try_recv(), std::result::Result::Err(tokio::sync::mpsc::error::TryRecvError::Empty)));
session.close().await.expect("Helius close fixture session must close before heartbeat deadline");
yield_runtime_steps().await;
assert!(matches!(ping_rx.try_recv(), std::result::Result::Err(tokio::sync::mpsc::error::TryRecvError::Empty)));
assert!(!matches!(ping_rx.try_recv(), std::result::Result::Ok(())));
tokio::time::resume();
server.await.expect("Helius close fixture server must complete");
}