@@ -32,7 +32,7 @@ void main() {
32
32
late EchoServiceClient fakeClient;
33
33
late FakeClientChannel fakeChannel;
34
34
late EchoServiceClient unresponsiveClient;
35
- late ClientChannel unresponsiveChannel;
35
+ late FakeClientChannel unresponsiveChannel;
36
36
37
37
setUp (() async {
38
38
final serverOptions = ServerKeepAliveOptions (
@@ -99,12 +99,18 @@ void main() {
99
99
expect (fakeChannel.newConnectionCounter, 1 );
100
100
});
101
101
102
- test ('Server doesnt ack the ping, making the client shutdown the connection ' ,
102
+ test ('Server doesnt ack the ping, making the client shutdown the transport ' ,
103
103
() async {
104
+ //Send a first request, get a connection
104
105
await unresponsiveClient.echo (EchoRequest ());
106
+ expect (unresponsiveChannel.newConnectionCounter, 1 );
107
+
108
+ //Ping is not being acked on time
105
109
await Future .delayed (Duration (milliseconds: 200 ));
106
- await expectLater (
107
- unresponsiveClient.echo (EchoRequest ()), throwsA (isA <GrpcError >()));
110
+
111
+ //A second request gets a new connection
112
+ await unresponsiveClient.echo (EchoRequest ());
113
+ expect (unresponsiveChannel.newConnectionCounter, 2 );
108
114
});
109
115
}
110
116
@@ -113,7 +119,7 @@ class FakeClientChannel extends ClientChannel {
113
119
FakeHttp2ClientConnection ? fakeHttp2ClientConnection;
114
120
FakeClientChannel (
115
121
super .host, {
116
- super .port = 443 ,
122
+ super .port,
117
123
super .options = const ChannelOptions (),
118
124
super .channelShutdownHandler,
119
125
});
@@ -142,20 +148,23 @@ class FakeHttp2ClientConnection extends Http2ClientConnection {
142
148
}
143
149
144
150
/// A wrapper around a [FakeHttp2ClientConnection]
145
- class UnresponsiveClientChannel extends ClientChannel {
151
+ class UnresponsiveClientChannel extends FakeClientChannel {
146
152
UnresponsiveClientChannel (
147
153
super .host, {
148
- super .port = 443 ,
154
+ super .port,
149
155
super .options = const ChannelOptions (),
150
156
super .channelShutdownHandler,
151
157
});
152
158
153
159
@override
154
- ClientConnection createConnection () =>
155
- UnresponsiveHttp2ClientConnection (host, port, options);
160
+ ClientConnection createConnection () {
161
+ fakeHttp2ClientConnection =
162
+ UnresponsiveHttp2ClientConnection (host, port, options);
163
+ return fakeHttp2ClientConnection! ;
164
+ }
156
165
}
157
166
158
- class UnresponsiveHttp2ClientConnection extends Http2ClientConnection {
167
+ class UnresponsiveHttp2ClientConnection extends FakeHttp2ClientConnection {
159
168
UnresponsiveHttp2ClientConnection (super .host, super .port, super .options);
160
169
161
170
@override
@@ -189,8 +198,6 @@ class FakeEchoService extends EchoServiceBase {
189
198
190
199
@override
191
200
Stream <ServerStreamingEchoResponse > serverStreamingEcho (
192
- ServiceCall call, ServerStreamingEchoRequest request) {
193
- // TODO: implement serverStreamingEcho
194
- throw UnimplementedError ();
195
- }
201
+ ServiceCall call, ServerStreamingEchoRequest request) =>
202
+ throw UnimplementedError ();
196
203
}
0 commit comments