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 =>
|
bool get isAutoReconnectScheduled =>
|
||||||
(_shouldAutoReconnect || _shouldAutoReconnectTcp) &&
|
(_shouldAutoReconnect || _shouldAutoReconnectTcp) &&
|
||||||
(_reconnectTimer?.isActive ?? false);
|
(_reconnectTimer?.isActive ?? false);
|
||||||
|
|
||||||
|
@visibleForTesting
|
||||||
|
int get reconnectAttemptsForTesting => _reconnectAttempts;
|
||||||
|
|
||||||
String? get activeTcpEndpoint => _tcpConnector.activeEndpoint;
|
String? get activeTcpEndpoint => _tcpConnector.activeEndpoint;
|
||||||
bool get isTcpTransportConnected =>
|
bool get isTcpTransportConnected =>
|
||||||
_state == MeshCoreConnectionState.connected &&
|
_state == MeshCoreConnectionState.connected &&
|
||||||
|
|||||||
@@ -208,14 +208,13 @@ void main() {
|
|||||||
_connector.state == MeshCoreConnectionState.disconnected &&
|
_connector.state == MeshCoreConnectionState.disconnected &&
|
||||||
_connector.isAutoReconnectScheduled,
|
_connector.isAutoReconnectScheduled,
|
||||||
);
|
);
|
||||||
await _waitFor(
|
final firstScheduledAttempt = _connector.reconnectAttemptsForTesting;
|
||||||
() => !_connector.isAutoReconnectScheduled,
|
// Wait for the failed attempt to schedule its next backoff. The timer's
|
||||||
pollInterval: const Duration(milliseconds: 1),
|
// inactive window can be shorter than a test poll interval, so observe
|
||||||
);
|
// the monotonic retry count instead of trying to catch that window.
|
||||||
// The timer firing proves an attempt started; wait for its failure to
|
|
||||||
// finish and the next backoff to become active.
|
|
||||||
await _waitFor(
|
await _waitFor(
|
||||||
() =>
|
() =>
|
||||||
|
_connector.reconnectAttemptsForTesting > firstScheduledAttempt &&
|
||||||
_connector.state == MeshCoreConnectionState.disconnected &&
|
_connector.state == MeshCoreConnectionState.disconnected &&
|
||||||
_connector.isAutoReconnectScheduled,
|
_connector.isAutoReconnectScheduled,
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in new issue
Block a user