v0.2.7-pre.006-fix.001
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
// file: crates/ksp-onchain-transport-lib/src/ws_session.rs
|
||||
// version: 4
|
||||
// version: 5
|
||||
|
||||
use futures_util::SinkExt; // rust-rules: trait-import
|
||||
use futures_util::StreamExt; // rust-rules: trait-import
|
||||
@@ -531,7 +531,7 @@ where
|
||||
return WsActorIoOutcome::Continue;
|
||||
},
|
||||
};
|
||||
let (state_tx, state_rx) = tokio::sync::watch::channel(crate::WsSubscriptionState::Requested);
|
||||
let (state_tx, _) = tokio::sync::watch::channel(crate::WsSubscriptionState::Requested);
|
||||
subscriptions.insert(
|
||||
subscription_id.get(),
|
||||
crate::WsSubscriptionRuntime {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// file: crates/ksp-onchain-transport-lib/unit_tests/ws_session.rs
|
||||
// version: 3
|
||||
// version: 4
|
||||
|
||||
use futures_util::SinkExt; // rust-rules: trait-import
|
||||
use futures_util::StreamExt; // rust-rules: trait-import
|
||||
@@ -493,6 +493,8 @@ async fn websocket_unknown_remote_subscription_notification_is_ignored_without_a
|
||||
send_result(&mut websocket, &subscribe, serde_json::json!(3)).await;
|
||||
send_notification(&mut websocket, "rootNotification", 999, serde_json::json!(100)).await;
|
||||
send_notification(&mut websocket, "rootNotification", 3, serde_json::json!(101)).await;
|
||||
let request = read_request(&mut websocket).await;
|
||||
send_result(&mut websocket, &request, serde_json::json!(true)).await;
|
||||
});
|
||||
let session = crate::WsSession::connect(local_endpoint(url.as_str())).await.expect("client handshake must succeed");
|
||||
let mut subscription = session
|
||||
@@ -504,6 +506,9 @@ async fn websocket_unknown_remote_subscription_notification_is_ignored_without_a
|
||||
let notification = subscription.recv().await.expect("valid notification must exist").expect("valid notification must decode");
|
||||
assert_eq!(notification, serde_json::json!(101));
|
||||
assert_eq!(subscription.state(), crate::WsSubscriptionState::Active);
|
||||
assert_eq!(session.state(), crate::WsSessionState::Active);
|
||||
let result = session.execute_json_rpc("afterUnknownRemote", std::vec::Vec::new()).await.expect("physical session must remain usable");
|
||||
assert_eq!(result, serde_json::json!(true));
|
||||
server.await.expect("local server task must complete");
|
||||
}
|
||||
|
||||
@@ -543,6 +548,8 @@ async fn websocket_typed_notification_decode_failure_fails_only_one_subscription
|
||||
let subscribe = read_request(&mut websocket).await;
|
||||
send_result(&mut websocket, &subscribe, serde_json::json!(8)).await;
|
||||
send_notification(&mut websocket, "rootNotification", 8, serde_json::json!("not-a-slot")).await;
|
||||
let request = read_request(&mut websocket).await;
|
||||
send_result(&mut websocket, &request, serde_json::json!(true)).await;
|
||||
});
|
||||
let session = crate::WsSession::connect(local_endpoint(url.as_str())).await.expect("client handshake must succeed");
|
||||
let mut subscription = session
|
||||
@@ -560,5 +567,7 @@ async fn websocket_typed_notification_decode_failure_fails_only_one_subscription
|
||||
assert_eq!(error.code(), crate::ERROR_CODE_INVALID_RESPONSE);
|
||||
wait_for_subscription_state(&subscription, crate::WsSubscriptionState::Failed).await;
|
||||
assert_eq!(session.state(), crate::WsSessionState::Active);
|
||||
let result = session.execute_json_rpc("afterDecodeFailure", std::vec::Vec::new()).await.expect("physical session must remain usable");
|
||||
assert_eq!(result, serde_json::json!(true));
|
||||
server.await.expect("local server task must complete");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user