@@ -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
final pingInterval = Duration (milliseconds: 10 );
38
38
final timeout = Duration (milliseconds: 30 );
@@ -101,14 +101,18 @@ void main() {
101
101
expect (fakeChannel.newConnectionCounter, 1 );
102
102
});
103
103
104
- test ('Server doesnt ack the ping, making the client shutdown the connection ' ,
104
+ test ('Server doesnt ack the ping, making the client shutdown the transport ' ,
105
105
() async {
106
+ //Send a first request, get a connection
106
107
await unresponsiveClient.echo (EchoRequest ());
108
+ expect (unresponsiveChannel.newConnectionCounter, 1 );
109
+
110
+ //Ping is not being acked on time
107
111
await Future .delayed (timeout * 2 );
108
- await expectLater (
109
- unresponsiveClient. echo ( EchoRequest ()),
110
- throwsA ( isA < GrpcError > ()),
111
- );
112
+
113
+ //A second request gets a new connection
114
+ await unresponsiveClient. echo ( EchoRequest ());
115
+ expect (unresponsiveChannel.newConnectionCounter, 2 );
112
116
});
113
117
}
114
118
@@ -146,7 +150,7 @@ class FakeHttp2ClientConnection extends Http2ClientConnection {
146
150
}
147
151
148
152
/// A wrapper around a [FakeHttp2ClientConnection]
149
- class UnresponsiveClientChannel extends ClientChannel {
153
+ class UnresponsiveClientChannel extends FakeClientChannel {
150
154
UnresponsiveClientChannel (
151
155
super .host, {
152
156
super .port,
@@ -155,11 +159,14 @@ class UnresponsiveClientChannel extends ClientChannel {
155
159
});
156
160
157
161
@override
158
- ClientConnection createConnection () =>
159
- UnresponsiveHttp2ClientConnection (host, port, options);
162
+ ClientConnection createConnection () {
163
+ fakeHttp2ClientConnection =
164
+ UnresponsiveHttp2ClientConnection (host, port, options);
165
+ return fakeHttp2ClientConnection! ;
166
+ }
160
167
}
161
168
162
- class UnresponsiveHttp2ClientConnection extends Http2ClientConnection {
169
+ class UnresponsiveHttp2ClientConnection extends FakeHttp2ClientConnection {
163
170
UnresponsiveHttp2ClientConnection (super .host, super .port, super .options);
164
171
165
172
@override
0 commit comments