Stabilize TCP reconnect retry test
This commit is contained in:
1 parent
cc12e2eb96
commit
ef31136711
2 files changed
+9
-6
No files matched your search
@@ -551,6 +551,10 @@ class MeshCoreConnector extends ChangeNotifier {
|
||||
bool get isAutoReconnectScheduled =>
|
||||
(_shouldAutoReconnect || _shouldAutoReconnectTcp) &&
|
||||
(_reconnectTimer?.isActive ?? false);
|
||||
|
||||
@visibleForTesting
|
||||
int get reconnectAttemptsForTesting => _reconnectAttempts;
|
||||
|
||||
String? get activeTcpEndpoint => _tcpConnector.activeEndpoint;
|
||||
bool get isTcpTransportConnected =>
|
||||
_state == MeshCoreConnectionState.connected &&
|
||||
|
||||
@@ -208,14 +208,13 @@ void main() {
|
||||
_connector.state == MeshCoreConnectionState.disconnected &&
|
||||
_connector.isAutoReconnectScheduled,
|
||||
);
|
||||
await _waitFor(
|
||||
() => !_connector.isAutoReconnectScheduled,
|
||||
pollInterval: const Duration(milliseconds: 1),
|
||||
);
|
||||
// The timer firing proves an attempt started; wait for its failure to
|
||||
// finish and the next backoff to become active.
|
||||
final firstScheduledAttempt = _connector.reconnectAttemptsForTesting;
|
||||
// Wait for the failed attempt to schedule its next backoff. The timer's
|
||||
// inactive window can be shorter than a test poll interval, so observe
|
||||
// the monotonic retry count instead of trying to catch that window.
|
||||
await _waitFor(
|
||||
() =>
|
||||
_connector.reconnectAttemptsForTesting > firstScheduledAttempt &&
|
||||
_connector.state == MeshCoreConnectionState.disconnected &&
|
||||
_connector.isAutoReconnectScheduled,
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user