Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cancellation safety documentation #31

Merged
merged 5 commits into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
124 changes: 52 additions & 72 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,20 @@ on:
name: Continuous integration

jobs:
check:
name: Check
docs:
name: Documentation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
profile: minimal
toolchain: 1.65
override: true
- uses: actions-rs/cargo@v1
with:
command: check
- uses: Swatinem/rust-cache@v2
- name: Build Documentation
run: cargo doc --lib --no-deps --all-features --workspace
env:
RUSTDOCFLAGS: --cfg docsrs -Dwarnings

testmsrv:
name: Test Suite Latest
Expand All @@ -31,15 +32,13 @@ jobs:
- macos-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
profile: minimal
toolchain: 1.78.0
override: true
- uses: actions-rs/cargo@v1
with:
command: test
args: --all-features --all-targets --workspace
- uses: Swatinem/rust-cache@v2
- name: Test
run: cargo test --all-features --all-targets --workspace

testlatest:
name: Test Suite MSRV
Expand All @@ -52,104 +51,85 @@ jobs:
- macos-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
profile: minimal
toolchain: 1.65
override: true
- uses: actions-rs/cargo@v1
with:
command: test
args: --all-features --all-targets --workspace
- uses: Swatinem/rust-cache@v2
- name: Test
run: cargo test --all-features --all-targets --workspace

fmt:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
profile: minimal
toolchain: 1.65
override: true
- run: rustup component add rustfmt
- uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
components: rustfmt
- uses: Swatinem/rust-cache@v2
- run: cargo fmt --all -- --check

clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: 1.65
override: true
- run: rustup component add clippy
- uses: actions-rs/cargo@v1
with:
command: clippy
args: --all-features --workspace -- -D warnings
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
# Not the same as the MSRV as an ICE is thrown
toolchain: 1.66.0
components: clippy
- uses: Swatinem/rust-cache@v2
- run: cargo clippy --all-features --all-targets --workspace -- -D warnings

autobahnclient:
name: Autobahn Client
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
profile: minimal
toolchain: 1.65
override: true
- uses: actions-rs/cargo@v1
with:
command: run
args: --bin client --release
toolchain: 1.65.0
- uses: Swatinem/rust-cache@v2
- run: cargo run --bin client --release

autobahnserver:
name: Autobahn Server
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: 1.65
override: true
- uses: actions-rs/cargo@v1
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
command: run
args: --bin server --release
toolchain: 1.65.0
- uses: Swatinem/rust-cache@v2
- run: cargo run --bin server --release

autobahnclientsplit:
name: Autobahn Client Split Socket
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
profile: minimal
toolchain: 1.65
override: true
- uses: actions-rs/cargo@v1
with:
command: run
args: --bin split_client --release
toolchain: 1.65.0
- uses: Swatinem/rust-cache@v2
- run: cargo run --bin split_client --release

autobahnserversplit:
name: Autobahn Server Split Socket
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: 1.65
override: true
- uses: actions-rs/cargo@v1
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
command: run
args: --bin split_server --release
toolchain: 1.65.0
- uses: Swatinem/rust-cache@v2
- run: cargo run --bin split_server --release
4 changes: 2 additions & 2 deletions ratchet_core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ratchet_core"
version = "1.0.0"
version = "1.0.1"
authors = ["Swim Inc. developers info@swim.ai"]
edition = "2021"
description = "Async WebSocket implementation"
Expand All @@ -16,7 +16,7 @@ split = ["futures"]
fixture = []

[dependencies]
ratchet_ext = { version = "1.0.0", path = "../ratchet_ext" }
ratchet_ext = { version = "1.0.1", path = "../ratchet_ext" }
url = { workspace = true }
http = { workspace = true }
tokio = { workspace = true, features = ["rt", "net", "io-util"] }
Expand Down
4 changes: 2 additions & 2 deletions ratchet_core/src/framed/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ where

#[tokio::test]
async fn ping() {
let buffer = BytesMut::from_iter(&[137, 4, 1, 2, 3, 4]);
let buffer = BytesMut::from_iter([137, 4, 1, 2, 3, 4]);
let mut framed = FramedIo::new(EmptyIo, buffer, Role::Client, usize::MAX, 0);

ok_eq(
Expand All @@ -211,7 +211,7 @@ async fn ping() {

#[tokio::test]
async fn pong() {
let buffer = BytesMut::from_iter(&[138, 4, 1, 2, 3, 4]);
let buffer = BytesMut::from_iter([138, 4, 1, 2, 3, 4]);
let mut framed = FramedIo::new(EmptyIo, buffer, Role::Client, usize::MAX, 0);

ok_eq(
Expand Down
16 changes: 8 additions & 8 deletions ratchet_core/src/protocol/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ mod decode {

#[test]
fn header() {
let bytes = BytesMut::from_iter(&[129, 4, 1, 2, 3, 4]);
let bytes = BytesMut::from_iter([129, 4, 1, 2, 3, 4]);
let (header, _header_len, _payload_len) =
FrameHeader::read_from(&bytes, false, 0, usize::MAX)
.unwrap()
Expand All @@ -181,15 +181,15 @@ mod decode {

#[test]
fn rsv() {
let bytes = BytesMut::from_iter(&[161, 4, 1, 2, 3, 4]);
let bytes = BytesMut::from_iter([161, 4, 1, 2, 3, 4]);
let r = FrameHeader::read_from(&bytes, false, 0, usize::MAX);
expect_protocol_error(r, ProtocolError::UnknownExtension);

let bytes = BytesMut::from_iter(&[161, 4, 1, 2, 3, 4]);
let bytes = BytesMut::from_iter([161, 4, 1, 2, 3, 4]);
let r = FrameHeader::read_from(&bytes, false, 1 << 6 & 1 << 4, usize::MAX);
expect_protocol_error(r, ProtocolError::UnknownExtension);

let bytes = BytesMut::from_iter(&[193, 4, 1, 2, 3, 4]);
let bytes = BytesMut::from_iter([193, 4, 1, 2, 3, 4]);
let result = FrameHeader::read_from(&bytes, false, 1 << 6, usize::MAX);

let _expected = FrameHeader {
Expand All @@ -202,28 +202,28 @@ mod decode {

#[test]
fn overflow() {
let bytes = BytesMut::from_iter(&[129, 4, 1, 2, 3, 4]);
let bytes = BytesMut::from_iter([129, 4, 1, 2, 3, 4]);
let r = FrameHeader::read_from(&bytes, false, 0, 1);
expect_protocol_error(r, ProtocolError::FrameOverflow);
}

#[test]
fn fragmented_control() {
let bytes = BytesMut::from_iter(&[8, 4, 1, 2, 3, 4]);
let bytes = BytesMut::from_iter([8, 4, 1, 2, 3, 4]);
let r = FrameHeader::read_from(&bytes, false, 0, usize::MAX);
expect_protocol_error(r, ProtocolError::FragmentedControl);
}

#[test]
fn unmasked() {
let bytes = BytesMut::from_iter(&[1, 132, 0, 0, 0, 0, 1, 2, 3, 4]);
let bytes = BytesMut::from_iter([1, 132, 0, 0, 0, 0, 1, 2, 3, 4]);
let r = FrameHeader::read_from(&bytes, false, 0, usize::MAX);
expect_protocol_error(r, ProtocolError::MaskedFrame);
}

#[test]
fn masked_err() {
let bytes = BytesMut::from_iter(&[129, 4, 1, 2, 3, 4]);
let bytes = BytesMut::from_iter([129, 4, 1, 2, 3, 4]);
let r = FrameHeader::read_from(&bytes, true, 0, usize::MAX);
expect_protocol_error(r, ProtocolError::UnmaskedFrame);
}
Expand Down
Loading
Loading