cojson 0.8.36 → 0.8.38

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -26,14 +26,10 @@ export function createTestNode() {
26
26
  return new LocalNode(admin, session, Crypto);
27
27
  }
28
28
 
29
- export function createTwoConnectedNodes(
29
+ export async function createTwoConnectedNodes(
30
30
  node1Role: Peer["role"],
31
31
  node2Role: Peer["role"],
32
32
  ) {
33
- // Setup nodes
34
- const node1 = createTestNode();
35
- const node2 = createTestNode();
36
-
37
33
  // Connect nodes initially
38
34
  const [node1ToNode2Peer, node2ToNode1Peer] = connectedPeers(
39
35
  "node1ToNode2",
@@ -44,8 +40,17 @@ export function createTwoConnectedNodes(
44
40
  },
45
41
  );
46
42
 
47
- node1.syncManager.addPeer(node1ToNode2Peer);
48
- node2.syncManager.addPeer(node2ToNode1Peer);
43
+ const node1 = await LocalNode.withNewlyCreatedAccount({
44
+ peersToLoadFrom: [node1ToNode2Peer],
45
+ crypto: Crypto,
46
+ creationProps: { name: "Client" },
47
+ });
48
+
49
+ const node2 = await LocalNode.withNewlyCreatedAccount({
50
+ peersToLoadFrom: [node2ToNode1Peer],
51
+ crypto: Crypto,
52
+ creationProps: { name: "Server" },
53
+ });
49
54
 
50
55
  return {
51
56
  node1,
@@ -227,3 +232,11 @@ export async function loadCoValueOrFail<V extends RawCoValue>(
227
232
  }
228
233
  return value;
229
234
  }
235
+
236
+ export function hotSleep(ms: number) {
237
+ const before = Date.now();
238
+ while (Date.now() < before + ms) {
239
+ /* hot sleep */
240
+ }
241
+ return before;
242
+ }