Skip to content

Commit

Permalink
fix tests by polling SendRequest::ready
Browse files Browse the repository at this point in the history
  • Loading branch information
seanmonstar committed Aug 21, 2023
1 parent 4dc9bcf commit a3b4acb
Showing 1 changed file with 15 additions and 20 deletions.
35 changes: 15 additions & 20 deletions tests/h2-tests/tests/client_request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,8 @@ async fn request_over_max_concurrent_streams_errors() {

// first request is allowed
let (resp1, mut stream1) = client.send_request(request, false).unwrap();
// as long as we let the connection internals tick
client = h2.drive(client.ready()).await.unwrap();

let request = Request::builder()
.method(Method::POST)
Expand Down Expand Up @@ -303,16 +305,25 @@ async fn recv_decrement_max_concurrent_streams_when_requests_queued() {
srv.ping_pong([0; 8]).await;

// limit this server later in life
srv.send_frame(frames::settings().max_concurrent_streams(1)).await;
srv.send_frame(frames::settings().max_concurrent_streams(1))
.await;
srv.recv_frame(frames::settings_ack()).await;

srv.recv_frame(
frames::headers(3)
.request("POST", "https://example.com/")
.eos(),
)
.await;
srv.ping_pong([1; 8]).await;
srv.send_frame(frames::headers(3).response(200).eos()).await;

srv.recv_frame(
frames::headers(5)
.request("POST", "https://example.com/")
.eos(),
)
.await;
srv.send_frame(frames::headers(5).response(200).eos()).await;
};

let h2 = async move {
Expand Down Expand Up @@ -346,24 +357,6 @@ async fn recv_decrement_max_concurrent_streams_when_requests_queued() {
// second request is put into pending_open
let (resp2, _) = client.send_request(request, true).unwrap();

/*
let request = Request::builder()
.method(Method::GET)
.uri("https://example.com/")
.body(())
.unwrap();
let waker = futures::task::noop_waker();
let mut cx = Context::from_waker(&waker);
// third stream is over max concurrent
assert!(!client.poll_ready(&mut cx).is_ready());
let err = client.send_request(request, true).unwrap_err();
assert_eq!(err.to_string(), "user error: rejected");
*/


h2.drive(async move {
resp1.await.expect("req");
})
Expand Down Expand Up @@ -429,6 +422,8 @@ async fn send_request_poll_ready_when_connection_error() {

// first request is allowed
let (resp1, _) = client.send_request(request, true).unwrap();
// as long as we let the connection internals tick
client = h2.drive(client.ready()).await.unwrap();

let request = Request::builder()
.method(Method::POST)
Expand Down

0 comments on commit a3b4acb

Please sign in to comment.