@@ -698,25 +698,6 @@ ValueTask<QuicStream> OpenStreamAsync(QuicConnection connection, CancellationTok
698
698
await serverConnection . DisposeAsync ( ) ;
699
699
}
700
700
701
-
702
- [ Fact ]
703
- [ OuterLoop ( "May take several seconds" ) ]
704
- public async Task SetListenerTimeoutWorksWithSmallTimeout ( )
705
- {
706
- var listenerOptions = new QuicListenerOptions ( )
707
- {
708
- ListenEndPoint = new IPEndPoint ( IPAddress . Loopback , 0 ) ,
709
- ApplicationProtocols = new List < SslApplicationProtocol > ( ) { ApplicationProtocol } ,
710
- ConnectionOptionsCallback = ( _ , _ , _ ) => ValueTask . FromResult ( CreateQuicServerOptions ( ) )
711
- } ;
712
-
713
- ( QuicConnection clientConnection , QuicConnection serverConnection ) = await CreateConnectedQuicConnection ( null , listenerOptions ) ;
714
- await AssertThrowsQuicExceptionAsync ( QuicError . ConnectionIdle , async ( ) => await serverConnection . AcceptInboundStreamAsync ( ) . AsTask ( ) . WaitAsync ( TimeSpan . FromSeconds ( 100 ) ) ) ;
715
-
716
- await serverConnection . DisposeAsync ( ) ;
717
- await clientConnection . DisposeAsync ( ) ;
718
- }
719
-
720
701
[ Theory ]
721
702
[ MemberData ( nameof ( WriteData ) ) ]
722
703
public async Task WriteTests ( int [ ] [ ] writes )
@@ -1179,5 +1160,43 @@ public async Task IncompatibleAlpn_ThrowsAuthenticationException()
1179
1160
1180
1161
await Assert . ThrowsAsync < AuthenticationException > ( async ( ) => await CreateQuicConnection ( clientOptions ) ) . WaitAsync ( TimeSpan . FromSeconds ( 30 ) ) ;
1181
1162
}
1163
+
1164
+ [ Fact ]
1165
+ [ OuterLoop ( "May take several seconds" ) ]
1166
+ public async Task IdleTimeout_ThrowsQuicException ( )
1167
+ {
1168
+ QuicListenerOptions listenerOptions = new QuicListenerOptions ( )
1169
+ {
1170
+ ListenEndPoint = new IPEndPoint ( IPAddress . Loopback , 0 ) ,
1171
+ ApplicationProtocols = new List < SslApplicationProtocol > ( ) { ApplicationProtocol } ,
1172
+ ConnectionOptionsCallback = ( _ , _ , _ ) =>
1173
+ {
1174
+ var serverOptions = CreateQuicServerOptions ( ) ;
1175
+ serverOptions . MaxInboundBidirectionalStreams = 1 ;
1176
+ serverOptions . MaxInboundUnidirectionalStreams = 1 ;
1177
+ serverOptions . IdleTimeout = TimeSpan . FromSeconds ( 1 ) ;
1178
+ return ValueTask . FromResult ( serverOptions ) ;
1179
+ }
1180
+ } ;
1181
+ ( QuicConnection clientConnection , QuicConnection serverConnection ) = await CreateConnectedQuicConnection ( null , listenerOptions ) ;
1182
+
1183
+ await using ( clientConnection )
1184
+ await using ( serverConnection )
1185
+ {
1186
+ using QuicStream clientStream = await clientConnection . OpenOutboundStreamAsync ( QuicStreamType . Bidirectional ) ;
1187
+ await clientStream . WriteAsync ( new byte [ 1 ] ) ;
1188
+ using QuicStream serverStream = await serverConnection . AcceptInboundStreamAsync ( ) . AsTask ( ) . WaitAsync ( TimeSpan . FromSeconds ( 10 ) ) ;
1189
+ await serverStream . ReadAsync ( new byte [ 1 ] ) ;
1190
+
1191
+ ValueTask < QuicStream > acceptTask = serverConnection . AcceptInboundStreamAsync ( ) ;
1192
+
1193
+ // read attempts should block until idle timeout
1194
+ await AssertThrowsQuicExceptionAsync ( QuicError . ConnectionIdle , async ( ) => await serverStream . ReadAsync ( new byte [ 10 ] ) ) . WaitAsync ( TimeSpan . FromSeconds ( 10 ) ) ;
1195
+
1196
+ // write and accept should throw as well
1197
+ await AssertThrowsQuicExceptionAsync ( QuicError . ConnectionIdle , async ( ) => await serverStream . WriteAsync ( new byte [ 10 ] ) ) . WaitAsync ( TimeSpan . FromSeconds ( 10 ) ) ;
1198
+ await AssertThrowsQuicExceptionAsync ( QuicError . ConnectionIdle , async ( ) => await acceptTask ) . WaitAsync ( TimeSpan . FromSeconds ( 10 ) ) ;
1199
+ }
1200
+ }
1182
1201
}
1183
1202
}
0 commit comments