Skip to content

Commit

Permalink
Update websocket-util dependency 0.14
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
d-e-s-o committed Dec 29, 2024
1 parent 2169a66 commit fcf3d02
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 38 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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}\",
Expand Down
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
63 changes: 41 additions & 22 deletions src/api/v2/updates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(())
}

Expand All @@ -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?;
Expand All @@ -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(())
}

Expand All @@ -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(())
}
Expand All @@ -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(())
Expand All @@ -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(())
Expand Down
34 changes: 24 additions & 10 deletions src/data/v2/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -920,6 +920,8 @@ mod tests {

use tokio::time::timeout;

use tungstenite::tungstenite::Utf8Bytes;

use websocket_util::test::WebSocketStream;
use websocket_util::tungstenite::Message;

Expand Down Expand Up @@ -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(())
}
Expand Down Expand Up @@ -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(())
}
Expand Down

0 comments on commit fcf3d02

Please sign in to comment.