startTestHub function
Starts a hub on an ephemeral port with a fixed, throwaway secret.
The secret is a constant on purpose: these hubs live on loopback for the length of one test, and a readable value makes a failing handshake easy to reason about. Never use it for anything reachable.
Implementation
Future<TestHub> startTestHub({
String session = 'test_session',
String secret = 'test-secret-not-for-real-use',
WsLimits limits = const WsLimits(),
Duration? sessionTtl,
}) async {
final credentials = HubCredentials(session: session, secret: secret);
final hub = await CoordinationHub.serve(
credentials: credentials,
limits: limits,
sessionTtl: sessionTtl,
);
return TestHub(hub, credentials);
}