Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemathinc
GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/backend/conat/test/cluster/util.ts
1712 views
1
import { initConatServer } from "@cocalc/backend/conat/test/setup";
2
import type { Options, ConatServer } from "@cocalc/conat/core/server";
3
import type { Client } from "@cocalc/conat/core/client";
4
5
export async function createClusterNode(
6
opts: {
7
clusterName: string;
8
id: string;
9
} & Options,
10
): Promise<{ server: ConatServer; client: Client }> {
11
const server = await initConatServer({
12
// disable autoscan so we can precisely control connections when building clusters for unit testing.
13
autoscanInterval: 0,
14
systemAccountPassword: "foo",
15
getUser: async () => {
16
return { hub_id: "system" };
17
},
18
...opts,
19
});
20
const client = server.client({ systemAccountPassword: "foo" });
21
await client.waitUntilSignedIn();
22
return { server, client };
23
}
24
25