From 07e2bda5cfe53e2309d14c6c2c7bd718e2a8e053 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20M=C3=BCller?= Date: Sun, 29 Dec 2024 10:17:13 -0800 Subject: [PATCH] Update websocket-util dependency 0.14 This change updates the websocket-util dependency we rely on to version 0.14. The main change over 0.13 is that its tokio-tungstenite dependency, to which we are exposed, is updated from 0.23 to 0.26. To that end, we need to update our tokio-tungstenite dependency in lockstep. --- .github/workflows/publish.yml | 2 +- CHANGELOG.md | 4 +-- Cargo.toml | 6 ++-- src/api/v2/updates.rs | 63 +++++++++++++++++++++++------------ src/data/v2/stream.rs | 34 +++++++++++++------ 5 files changed, 71 insertions(+), 38 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 91d1619..61a0b53 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -49,7 +49,7 @@ jobs: --request POST \ --url https://api.github.com/repos/${{ github.repository }}/releases \ --header "Accept: application/vnd.github+json" \ - --header "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}"\ + --header "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ --header "X-GitHub-Api-Version: 2022-11-28" \ --data "{ \"tag_name\":\"v${version}\", diff --git a/CHANGELOG.md b/CHANGELOG.md index f8c591b..0ea315a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,8 +2,8 @@ Unreleased ---------- - Added `weighted_average` member to `data::v2::bars::Bar` type - Bumped `hyper` dependency to `1.0` -- Bumped `websocket-util` dependency to `0.13` -- Bumped `tokio-tungstenite` dependency to `0.23` +- Bumped `websocket-util` dependency to `0.14` +- Bumped `tokio-tungstenite` dependency to `0.26` 0.29.0 diff --git a/Cargo.toml b/Cargo.toml index 00e1d5f..6fdbaf9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,17 +46,17 @@ thiserror = "1.0.30" tokio = {version = "1.13", default-features = false, features = ["net"]} tracing = {version = "0.1", default-features = false, features = ["attributes", "std"]} tracing-futures = {version = "0.2", default-features = false, features = ["std-future"]} -tungstenite = {package = "tokio-tungstenite", version = "0.23", features = ["connect", "native-tls", "url"]} +tungstenite = {package = "tokio-tungstenite", version = "0.26", features = ["connect", "native-tls", "url"]} url = "2.0" uuid = {version = "1.0", default-features = false, features = ["serde"]} -websocket-util = "0.13" +websocket-util = "0.14" [dev-dependencies] serial_test = {version = "3.0.0", default-features = false} test-log = {version = "0.2.14", default-features = false, features = ["trace"]} tokio = {version = "1.13", default-features = false, features = ["rt-multi-thread", "macros"]} uuid = {version = "1.0", default-features = false, features = ["v4"]} -websocket-util = {version = "0.13", features = ["test"]} +websocket-util = {version = "0.14", features = ["test"]} # A set of unused dependencies that we require to force correct minimum versions # of transitive dependencies, for cases where our dependencies have incorrect diff --git a/src/api/v2/updates.rs b/src/api/v2/updates.rs index 2cfab3a..e9c4491 100644 --- a/src/api/v2/updates.rs +++ b/src/api/v2/updates.rs @@ -438,6 +438,9 @@ mod tests { use test_log::test; + use tungstenite::tungstenite::Bytes; + use tungstenite::tungstenite::Utf8Bytes; + use websocket_util::test::WebSocketStream; use websocket_util::tungstenite::error::ProtocolError; use websocket_util::tungstenite::Message; @@ -563,7 +566,7 @@ mod tests { async fn broken_stream() { async fn test(mut stream: WebSocketStream) -> Result<(), WebSocketError> { let msg = stream.next().await.unwrap()?; - assert_eq!(msg, Message::Text(AUTH_REQ.to_string())); + assert_eq!(msg, Message::Text(Utf8Bytes::from_static(AUTH_REQ))); Ok(()) } @@ -585,14 +588,16 @@ mod tests { // Authentication. assert_eq!( stream.next().await.unwrap()?, - Message::Text(AUTH_REQ.to_string()), + Message::Text(Utf8Bytes::from_static(AUTH_REQ)), ); - stream.send(Message::Text(AUTH_RESP.to_string())).await?; + stream + .send(Message::Text(Utf8Bytes::from_static(AUTH_RESP))) + .await?; // Subscription. assert_eq!( stream.next().await.unwrap()?, - Message::Text(STREAM_REQ.to_string()), + Message::Text(Utf8Bytes::from_static(STREAM_REQ)), ); // Just respond with a Close. stream.send(Message::Close(None)).await?; @@ -615,16 +620,20 @@ mod tests { // Authentication. assert_eq!( stream.next().await.unwrap()?, - Message::Text(AUTH_REQ.to_string()), + Message::Text(Utf8Bytes::from_static(AUTH_REQ)), ); - stream.send(Message::Text(AUTH_RESP.to_string())).await?; + stream + .send(Message::Text(Utf8Bytes::from_static(AUTH_RESP))) + .await?; // Subscription. assert_eq!( stream.next().await.unwrap()?, - Message::Text(STREAM_REQ.to_string()), + Message::Text(Utf8Bytes::from_static(STREAM_REQ)), ); - stream.send(Message::Text(STREAM_RESP.to_string())).await?; + stream + .send(Message::Text(Utf8Bytes::from_static(STREAM_RESP))) + .await?; Ok(()) } @@ -643,12 +652,14 @@ mod tests { // Authentication. assert_eq!( stream.next().await.unwrap()?, - Message::Text(AUTH_REQ.to_string()), + Message::Text(Utf8Bytes::from_static(AUTH_REQ)), ); - stream.send(Message::Text(AUTH_RESP.to_string())).await?; + stream + .send(Message::Text(Utf8Bytes::from_static(AUTH_RESP))) + .await?; stream - .send(Message::Text("{ foobarbaz }".to_string())) + .send(Message::Text(Utf8Bytes::from_static("{ foobarbaz }"))) .await?; Ok(()) } @@ -670,23 +681,27 @@ mod tests { // Authentication. assert_eq!( stream.next().await.unwrap()?, - Message::Text(AUTH_REQ.to_string()), + Message::Text(Utf8Bytes::from_static(AUTH_REQ)), ); - stream.send(Message::Text(AUTH_RESP.to_string())).await?; + stream + .send(Message::Text(Utf8Bytes::from_static(AUTH_RESP))) + .await?; // Subscription. assert_eq!( stream.next().await.unwrap()?, - Message::Text(STREAM_REQ.to_string()), + Message::Text(Utf8Bytes::from_static(STREAM_REQ)), ); - stream.send(Message::Text(STREAM_RESP.to_string())).await?; + stream + .send(Message::Text(Utf8Bytes::from_static(STREAM_RESP))) + .await?; // Wait until the connection was established before sending any // additional messages. let () = receiver.await.unwrap(); stream - .send(Message::Text("{ foobarbaz }".to_string())) + .send(Message::Text(Utf8Bytes::from_static("{ foobarbaz }"))) .await?; stream.send(Message::Close(None)).await?; Ok(()) @@ -710,21 +725,25 @@ mod tests { // Authentication. assert_eq!( stream.next().await.unwrap()?, - Message::Text(AUTH_REQ.to_string()), + Message::Text(Utf8Bytes::from_static(AUTH_REQ)), ); - stream.send(Message::Text(AUTH_RESP.to_string())).await?; + stream + .send(Message::Text(Utf8Bytes::from_static(AUTH_RESP))) + .await?; // Subscription. assert_eq!( stream.next().await.unwrap()?, - Message::Text(STREAM_REQ.to_string()), + Message::Text(Utf8Bytes::from_static(STREAM_REQ)), ); - stream.send(Message::Text(STREAM_RESP.to_string())).await?; + stream + .send(Message::Text(Utf8Bytes::from_static(STREAM_RESP))) + .await?; // Ping. - stream.send(Message::Ping(Vec::new())).await?; + stream.send(Message::Ping(Bytes::new())).await?; // Expect Pong. - assert_eq!(stream.next().await.unwrap()?, Message::Pong(Vec::new()),); + assert_eq!(stream.next().await.unwrap()?, Message::Pong(Bytes::new()),); stream.send(Message::Close(None)).await?; Ok(()) diff --git a/src/data/v2/stream.rs b/src/data/v2/stream.rs index 79f0269..da79d1d 100644 --- a/src/data/v2/stream.rs +++ b/src/data/v2/stream.rs @@ -920,6 +920,8 @@ mod tests { use tokio::time::timeout; + use tungstenite::tungstenite::Utf8Bytes; + use websocket_util::test::WebSocketStream; use websocket_util::tungstenite::Message; @@ -1373,20 +1375,26 @@ mod tests { #[test(tokio::test)] async fn authenticate_and_subscribe() { async fn test(mut stream: WebSocketStream) -> Result<(), WebSocketError> { - stream.send(Message::Text(CONN_RESP.to_string())).await?; + stream + .send(Message::Text(Utf8Bytes::from_static(CONN_RESP))) + .await?; // Authentication. assert_eq!( stream.next().await.unwrap()?, - Message::Text(AUTH_REQ.to_string()), + Message::Text(Utf8Bytes::from_static(AUTH_REQ)), ); - stream.send(Message::Text(AUTH_RESP.to_string())).await?; + stream + .send(Message::Text(Utf8Bytes::from_static(AUTH_RESP))) + .await?; // Subscription. assert_eq!( stream.next().await.unwrap()?, - Message::Text(SUB_REQ.to_string()), + Message::Text(Utf8Bytes::from_static(SUB_REQ)), ); - stream.send(Message::Text(SUB_RESP.to_string())).await?; + stream + .send(Message::Text(Utf8Bytes::from_static(SUB_RESP))) + .await?; stream.send(Message::Close(None)).await?; Ok(()) } @@ -1416,20 +1424,26 @@ mod tests { #[test(tokio::test)] async fn subscribe_error() { async fn test(mut stream: WebSocketStream) -> Result<(), WebSocketError> { - stream.send(Message::Text(CONN_RESP.to_string())).await?; + stream + .send(Message::Text(Utf8Bytes::from_static(CONN_RESP))) + .await?; // Authentication. assert_eq!( stream.next().await.unwrap()?, - Message::Text(AUTH_REQ.to_string()), + Message::Text(Utf8Bytes::from_static(AUTH_REQ)), ); - stream.send(Message::Text(AUTH_RESP.to_string())).await?; + stream + .send(Message::Text(Utf8Bytes::from_static(AUTH_RESP))) + .await?; // Subscription. assert_eq!( stream.next().await.unwrap()?, - Message::Text(SUB_ERR_REQ.to_string()), + Message::Text(Utf8Bytes::from_static(SUB_ERR_REQ)), ); - stream.send(Message::Text(SUB_ERR_RESP.to_string())).await?; + stream + .send(Message::Text(Utf8Bytes::from_static(SUB_ERR_RESP))) + .await?; stream.send(Message::Close(None)).await?; Ok(()) }