@@ -420,6 +420,72 @@ TEST_F(QuicWtSessionTest, SetPriority) {
420420 EXPECT_EQ (httpPriority->incremental , true );
421421}
422422
423+ // The priority must reach the QuicSocket, otherwise the stream sits at default
424+ // priority in the connection's write queue and is never compared against the
425+ // other streams (or the wt datagram flows) sharing it.
426+ TEST_F (QuicWtSessionTest, SetPriorityPropagatesToQuicSocket) {
427+ auto handle = session_->createUniStream ();
428+ ASSERT_TRUE (handle.hasValue ());
429+ auto id = handle.value ()->getID ();
430+
431+ // deliberately every field differs from HTTPPriorityQueue's default
432+ // (u=3, i=true, o=0), so this cannot pass on an unpropagated priority
433+ quic::HTTPPriorityQueue::Priority priority (/* u=*/ 5 ,
434+ /* i=*/ false ,
435+ /* o=*/ 42 );
436+ socketDriver_.expectSetPriority (id, priority);
437+
438+ EXPECT_TRUE (session_->setPriority (id, priority).hasValue ());
439+ // the local egress schedule is updated too
440+ EXPECT_EQ (quic::HTTPPriorityQueue::Priority (handle.value ()->getPriority ()),
441+ priority);
442+ }
443+
444+ // Applications reprioritize through the write handle they already hold rather
445+ // than by stream id, so this is the path that has to reach the socket.
446+ TEST_F (QuicWtSessionTest, WriteHandleSetPriorityPropagatesToQuicSocket) {
447+ auto handle = session_->createUniStream ();
448+ ASSERT_TRUE (handle.hasValue ());
449+ auto id = handle.value ()->getID ();
450+
451+ quic::HTTPPriorityQueue::Priority priority (/* u=*/ 5 ,
452+ /* i=*/ false ,
453+ /* o=*/ 42 );
454+ socketDriver_.expectSetPriority (id, priority);
455+
456+ EXPECT_TRUE (handle.value ()->setPriority (priority).hasValue ());
457+ EXPECT_EQ (quic::HTTPPriorityQueue::Priority (handle.value ()->getPriority ()),
458+ priority);
459+ }
460+
461+ TEST_F (QuicWtSessionTest, SetPriorityUnknownStreamId) {
462+ // no stream has been created, so there is nothing to prioritize
463+ constexpr uint64_t kUnknownStreamId = 4 ;
464+ EXPECT_CALL (*socketDriver_.getSocket (), setStreamPriority (_, _)).Times (0 );
465+
466+ auto res = session_->setPriority (kUnknownStreamId ,
467+ quic::HTTPPriorityQueue::Priority (5 , false ));
468+ ASSERT_TRUE (res.hasError ());
469+ EXPECT_EQ (res.error (), WebTransport::ErrorCode::INVALID_STREAM_ID );
470+ }
471+
472+ // The socket half is best effort -- a transport that no longer has the stream
473+ // does not make the call a failure, and the local schedule still applies.
474+ TEST_F (QuicWtSessionTest, SetPriorityQuicSocketErrorIgnored) {
475+ auto handle = session_->createUniStream ();
476+ ASSERT_TRUE (handle.hasValue ());
477+ auto id = handle.value ()->getID ();
478+
479+ quic::HTTPPriorityQueue::Priority priority (/* u=*/ 5 , /* i=*/ false , /* o=*/ 42 );
480+ EXPECT_CALL (*socketDriver_.getSocket (), setStreamPriority (id, _))
481+ .WillOnce (Return (
482+ quic::make_unexpected (quic::LocalErrorCode::STREAM_NOT_EXISTS )));
483+
484+ EXPECT_TRUE (session_->setPriority (id, priority).hasValue ());
485+ EXPECT_EQ (quic::HTTPPriorityQueue::Priority (handle.value ()->getPriority ()),
486+ priority);
487+ }
488+
423489TEST_F (QuicWtSessionTest, AwaitWritable) {
424490 // Note: This test verifies basic functionality but doesn't test the blocking
425491 // scenario where awaitWritable returns a "not ready" future.
@@ -986,6 +1052,22 @@ TEST_F(H3WtSessionTest, CapsuleParseErrorClosesSession) {
9861052 connectStreamCb_.events .back ()));
9871053}
9881054
1055+ // H3WtSession shares the QuicSocket with the http/3 session, so its wt streams
1056+ // have to be ranked in that shared write queue like any other quic stream.
1057+ TEST_F (H3WtSessionTest, SetPriorityPropagatesToQuicSocket) {
1058+ socketDriver_.setMaxUniStreams (1 );
1059+ auto handle = session_->createUniStream ();
1060+ ASSERT_TRUE (handle.hasValue ());
1061+ auto id = handle.value ()->getID ();
1062+
1063+ quic::HTTPPriorityQueue::Priority priority (/* u=*/ 5 ,
1064+ /* i=*/ false ,
1065+ /* o=*/ 42 );
1066+ socketDriver_.expectSetPriority (id, priority);
1067+
1068+ EXPECT_TRUE (handle.value ()->setPriority (priority).hasValue ());
1069+ }
1070+
9891071TEST_F (H3WtSessionTest, AcquireIngressStream) {
9901072 // client-initiated stream ids (server is the local endpoint)
9911073 constexpr uint64_t kClientBidiId = 0 ;
0 commit comments