cojson 0.13.16 → 0.13.18

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.
Files changed (168) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/CHANGELOG.md +16 -0
  3. package/dist/PeerState.d.ts +3 -0
  4. package/dist/PeerState.d.ts.map +1 -1
  5. package/dist/PeerState.js +9 -0
  6. package/dist/PeerState.js.map +1 -1
  7. package/dist/SyncStateManager.d.ts.map +1 -1
  8. package/dist/SyncStateManager.js +2 -3
  9. package/dist/SyncStateManager.js.map +1 -1
  10. package/dist/coValue.d.ts +6 -4
  11. package/dist/coValue.d.ts.map +1 -1
  12. package/dist/coValue.js +5 -4
  13. package/dist/coValue.js.map +1 -1
  14. package/dist/coValueCore/coValueCore.d.ts +143 -0
  15. package/dist/coValueCore/coValueCore.d.ts.map +1 -0
  16. package/dist/{coValueCore.js → coValueCore/coValueCore.js} +314 -246
  17. package/dist/coValueCore/coValueCore.js.map +1 -0
  18. package/dist/coValueCore/verifiedState.d.ts +65 -0
  19. package/dist/coValueCore/verifiedState.d.ts.map +1 -0
  20. package/dist/coValueCore/verifiedState.js +210 -0
  21. package/dist/coValueCore/verifiedState.js.map +1 -0
  22. package/dist/coValues/account.d.ts +8 -10
  23. package/dist/coValues/account.d.ts.map +1 -1
  24. package/dist/coValues/account.js +12 -13
  25. package/dist/coValues/account.js.map +1 -1
  26. package/dist/coValues/coList.d.ts +10 -6
  27. package/dist/coValues/coList.d.ts.map +1 -1
  28. package/dist/coValues/coList.js +41 -15
  29. package/dist/coValues/coList.js.map +1 -1
  30. package/dist/coValues/coMap.d.ts +4 -3
  31. package/dist/coValues/coMap.d.ts.map +1 -1
  32. package/dist/coValues/coMap.js +5 -3
  33. package/dist/coValues/coMap.js.map +1 -1
  34. package/dist/coValues/coPlainText.d.ts +2 -2
  35. package/dist/coValues/coPlainText.d.ts.map +1 -1
  36. package/dist/coValues/coPlainText.js +5 -5
  37. package/dist/coValues/coPlainText.js.map +1 -1
  38. package/dist/coValues/coStream.d.ts +5 -4
  39. package/dist/coValues/coStream.d.ts.map +1 -1
  40. package/dist/coValues/coStream.js +5 -3
  41. package/dist/coValues/coStream.js.map +1 -1
  42. package/dist/coValues/group.d.ts +7 -2
  43. package/dist/coValues/group.d.ts.map +1 -1
  44. package/dist/coValues/group.js +29 -26
  45. package/dist/coValues/group.js.map +1 -1
  46. package/dist/coreToCoValue.d.ts +4 -3
  47. package/dist/coreToCoValue.d.ts.map +1 -1
  48. package/dist/coreToCoValue.js +10 -14
  49. package/dist/coreToCoValue.js.map +1 -1
  50. package/dist/exports.d.ts +6 -5
  51. package/dist/exports.d.ts.map +1 -1
  52. package/dist/exports.js +3 -4
  53. package/dist/exports.js.map +1 -1
  54. package/dist/localNode.d.ts +30 -24
  55. package/dist/localNode.d.ts.map +1 -1
  56. package/dist/localNode.js +153 -177
  57. package/dist/localNode.js.map +1 -1
  58. package/dist/permissions.d.ts +2 -1
  59. package/dist/permissions.d.ts.map +1 -1
  60. package/dist/permissions.js +15 -11
  61. package/dist/permissions.js.map +1 -1
  62. package/dist/priority.d.ts +1 -1
  63. package/dist/priority.d.ts.map +1 -1
  64. package/dist/sync.d.ts +2 -2
  65. package/dist/sync.d.ts.map +1 -1
  66. package/dist/sync.js +86 -55
  67. package/dist/sync.js.map +1 -1
  68. package/dist/tests/coList.test.js +133 -13
  69. package/dist/tests/coList.test.js.map +1 -1
  70. package/dist/tests/coMap.test.js +43 -14
  71. package/dist/tests/coMap.test.js.map +1 -1
  72. package/dist/tests/coPlainText.test.js +9 -10
  73. package/dist/tests/coPlainText.test.js.map +1 -1
  74. package/dist/tests/coStream.test.js +49 -18
  75. package/dist/tests/coStream.test.js.map +1 -1
  76. package/dist/tests/coValueCore.test.js +22 -28
  77. package/dist/tests/coValueCore.test.js.map +1 -1
  78. package/dist/tests/coValueCoreLoadingState.test.d.ts +2 -0
  79. package/dist/tests/coValueCoreLoadingState.test.d.ts.map +1 -0
  80. package/dist/tests/coValueCoreLoadingState.test.js +227 -0
  81. package/dist/tests/coValueCoreLoadingState.test.js.map +1 -0
  82. package/dist/tests/group.test.js +42 -43
  83. package/dist/tests/group.test.js.map +1 -1
  84. package/dist/tests/messagesTestUtils.d.ts +2 -2
  85. package/dist/tests/messagesTestUtils.d.ts.map +1 -1
  86. package/dist/tests/messagesTestUtils.js +1 -1
  87. package/dist/tests/messagesTestUtils.js.map +1 -1
  88. package/dist/tests/permissions.test.js +224 -292
  89. package/dist/tests/permissions.test.js.map +1 -1
  90. package/dist/tests/priority.test.js +13 -14
  91. package/dist/tests/priority.test.js.map +1 -1
  92. package/dist/tests/sync.auth.test.d.ts +2 -0
  93. package/dist/tests/sync.auth.test.d.ts.map +1 -0
  94. package/dist/tests/sync.auth.test.js +141 -0
  95. package/dist/tests/sync.auth.test.js.map +1 -0
  96. package/dist/tests/sync.load.test.js +60 -2
  97. package/dist/tests/sync.load.test.js.map +1 -1
  98. package/dist/tests/sync.mesh.test.js +70 -10
  99. package/dist/tests/sync.mesh.test.js.map +1 -1
  100. package/dist/tests/sync.peerReconciliation.test.js +19 -19
  101. package/dist/tests/sync.peerReconciliation.test.js.map +1 -1
  102. package/dist/tests/sync.storage.test.js +20 -13
  103. package/dist/tests/sync.storage.test.js.map +1 -1
  104. package/dist/tests/sync.test.js +32 -39
  105. package/dist/tests/sync.test.js.map +1 -1
  106. package/dist/tests/sync.upload.test.js +126 -37
  107. package/dist/tests/sync.upload.test.js.map +1 -1
  108. package/dist/tests/testUtils.d.ts +24 -15
  109. package/dist/tests/testUtils.d.ts.map +1 -1
  110. package/dist/tests/testUtils.js +88 -61
  111. package/dist/tests/testUtils.js.map +1 -1
  112. package/dist/typeUtils/expectGroup.js +1 -1
  113. package/dist/typeUtils/expectGroup.js.map +1 -1
  114. package/package.json +1 -1
  115. package/src/PeerState.ts +11 -0
  116. package/src/SyncStateManager.ts +2 -3
  117. package/src/coValue.ts +14 -8
  118. package/src/{coValueCore.ts → coValueCore/coValueCore.ts} +470 -413
  119. package/src/coValueCore/verifiedState.ts +376 -0
  120. package/src/coValues/account.ts +20 -25
  121. package/src/coValues/coList.ts +63 -29
  122. package/src/coValues/coMap.ts +13 -6
  123. package/src/coValues/coPlainText.ts +10 -8
  124. package/src/coValues/coStream.ts +12 -7
  125. package/src/coValues/group.ts +50 -28
  126. package/src/coreToCoValue.ts +14 -15
  127. package/src/exports.ts +9 -7
  128. package/src/localNode.ts +248 -283
  129. package/src/permissions.ts +18 -12
  130. package/src/priority.ts +1 -1
  131. package/src/sync.ts +96 -63
  132. package/src/tests/coList.test.ts +200 -12
  133. package/src/tests/coMap.test.ts +65 -14
  134. package/src/tests/coPlainText.test.ts +12 -9
  135. package/src/tests/coStream.test.ts +80 -17
  136. package/src/tests/coValueCore.test.ts +30 -27
  137. package/src/tests/coValueCoreLoadingState.test.ts +337 -0
  138. package/src/tests/group.test.ts +44 -68
  139. package/src/tests/messagesTestUtils.ts +3 -8
  140. package/src/tests/permissions.test.ts +283 -449
  141. package/src/tests/priority.test.ts +17 -13
  142. package/src/tests/sync.auth.test.ts +188 -0
  143. package/src/tests/sync.load.test.ts +79 -2
  144. package/src/tests/sync.mesh.test.ts +89 -9
  145. package/src/tests/sync.peerReconciliation.test.ts +25 -25
  146. package/src/tests/sync.storage.test.ts +20 -13
  147. package/src/tests/sync.test.ts +43 -43
  148. package/src/tests/sync.upload.test.ts +157 -37
  149. package/src/tests/testUtils.ts +120 -74
  150. package/src/typeUtils/expectGroup.ts +1 -1
  151. package/dist/CoValuesStore.d.ts +0 -14
  152. package/dist/CoValuesStore.d.ts.map +0 -1
  153. package/dist/CoValuesStore.js +0 -32
  154. package/dist/CoValuesStore.js.map +0 -1
  155. package/dist/coValueCore.d.ts +0 -141
  156. package/dist/coValueCore.d.ts.map +0 -1
  157. package/dist/coValueCore.js.map +0 -1
  158. package/dist/coValueState.d.ts +0 -34
  159. package/dist/coValueState.d.ts.map +0 -1
  160. package/dist/coValueState.js +0 -228
  161. package/dist/coValueState.js.map +0 -1
  162. package/dist/tests/coValueState.test.d.ts +0 -2
  163. package/dist/tests/coValueState.test.d.ts.map +0 -1
  164. package/dist/tests/coValueState.test.js +0 -344
  165. package/dist/tests/coValueState.test.js.map +0 -1
  166. package/src/CoValuesStore.ts +0 -41
  167. package/src/coValueState.ts +0 -300
  168. package/src/tests/coValueState.test.ts +0 -525
@@ -1,6 +1,6 @@
1
- import { describe, expect, test } from "vitest";
1
+ import { beforeEach, describe, expect, test } from "vitest";
2
2
  import { expectStream } from "../coValue.js";
3
- import { MAX_RECOMMENDED_TX_SIZE } from "../coValueCore.js";
3
+ import { MAX_RECOMMENDED_TX_SIZE } from "../coValueCore/coValueCore.js";
4
4
  import {
5
5
  BinaryStreamItem,
6
6
  CoStreamItem,
@@ -10,12 +10,22 @@ import {
10
10
  import { WasmCrypto } from "../crypto/WasmCrypto.js";
11
11
  import { SessionID } from "../ids.js";
12
12
  import { LocalNode } from "../localNode.js";
13
- import { randomAnonymousAccountAndSessionID } from "./testUtils.js";
13
+ import {
14
+ loadCoValueOrFail,
15
+ nodeWithRandomAgentAndSessionID,
16
+ randomAgentAndSessionID,
17
+ setupTestNode,
18
+ waitFor,
19
+ } from "./testUtils.js";
14
20
 
15
21
  const Crypto = await WasmCrypto.create();
16
22
 
23
+ beforeEach(async () => {
24
+ setupTestNode({ isSyncServer: true });
25
+ });
26
+
17
27
  test("Empty CoStream works", () => {
18
- const node = new LocalNode(...randomAnonymousAccountAndSessionID(), Crypto);
28
+ const node = nodeWithRandomAgentAndSessionID();
19
29
 
20
30
  const coValue = node.createCoValue({
21
31
  type: "costream",
@@ -32,7 +42,7 @@ test("Empty CoStream works", () => {
32
42
  });
33
43
 
34
44
  test("Can push into CoStream", () => {
35
- const node = new LocalNode(...randomAnonymousAccountAndSessionID(), Crypto);
45
+ const node = nodeWithRandomAgentAndSessionID();
36
46
 
37
47
  const coValue = node.createCoValue({
38
48
  type: "costream",
@@ -58,7 +68,7 @@ test("Can push into CoStream", () => {
58
68
  });
59
69
 
60
70
  test("Empty RawBinaryCoStream works", () => {
61
- const node = new LocalNode(...randomAnonymousAccountAndSessionID(), Crypto);
71
+ const node = nodeWithRandomAgentAndSessionID();
62
72
 
63
73
  const coValue = node.createCoValue({
64
74
  type: "costream",
@@ -84,7 +94,7 @@ test("Empty RawBinaryCoStream works", () => {
84
94
  });
85
95
 
86
96
  test("Can push into RawBinaryCoStream", () => {
87
- const node = new LocalNode(...randomAnonymousAccountAndSessionID(), Crypto);
97
+ const node = nodeWithRandomAgentAndSessionID();
88
98
 
89
99
  const coValue = node.createCoValue({
90
100
  type: "costream",
@@ -120,7 +130,7 @@ test("Can push into RawBinaryCoStream", () => {
120
130
  });
121
131
 
122
132
  test("When adding large transactions (small fraction of MAX_RECOMMENDED_TX_SIZE), we store an inbetween signature every time we reach MAX_RECOMMENDED_TX_SIZE and split up newContentSince accordingly", () => {
123
- const node = new LocalNode(...randomAnonymousAccountAndSessionID(), Crypto);
133
+ const node = nodeWithRandomAgentAndSessionID();
124
134
 
125
135
  const coValue = node.createCoValue({
126
136
  type: "costream",
@@ -152,7 +162,11 @@ test("When adding large transactions (small fraction of MAX_RECOMMENDED_TX_SIZE)
152
162
 
153
163
  content.endBinaryStream("trusting");
154
164
 
155
- const sessionEntry = coValue.sessionLogs.get(node.currentSessionID)!;
165
+ if (!coValue.isAvailable()) {
166
+ throw new Error("CoValue is not available");
167
+ }
168
+
169
+ const sessionEntry = coValue.verified.sessions.get(node.currentSessionID)!;
156
170
  expect(sessionEntry.transactions.length).toEqual(12);
157
171
  expect(sessionEntry.signatureAfter[0]).not.toBeDefined();
158
172
  expect(sessionEntry.signatureAfter[1]).not.toBeDefined();
@@ -167,7 +181,7 @@ test("When adding large transactions (small fraction of MAX_RECOMMENDED_TX_SIZE)
167
181
  expect(sessionEntry.signatureAfter[10]).not.toBeDefined();
168
182
  expect(sessionEntry.signatureAfter[11]).not.toBeDefined();
169
183
 
170
- const newContent = coValue.newContentSince({
184
+ const newContent = coValue.verified.newContentSince({
171
185
  id: coValue.id,
172
186
  header: false,
173
187
  sessions: {},
@@ -190,7 +204,7 @@ test("When adding large transactions (small fraction of MAX_RECOMMENDED_TX_SIZE)
190
204
  });
191
205
 
192
206
  test("When adding large transactions (bigger than MAX_RECOMMENDED_TX_SIZE), we store an inbetween signature after every large transaction and split up newContentSince accordingly", () => {
193
- const node = new LocalNode(...randomAnonymousAccountAndSessionID(), Crypto);
207
+ const node = nodeWithRandomAgentAndSessionID();
194
208
 
195
209
  const coValue = node.createCoValue({
196
210
  type: "costream",
@@ -222,7 +236,11 @@ test("When adding large transactions (bigger than MAX_RECOMMENDED_TX_SIZE), we s
222
236
 
223
237
  content.endBinaryStream("trusting");
224
238
 
225
- const sessionEntry = coValue.sessionLogs.get(node.currentSessionID)!;
239
+ if (!coValue.isAvailable()) {
240
+ throw new Error("CoValue is not available");
241
+ }
242
+
243
+ const sessionEntry = coValue.verified.sessions.get(node.currentSessionID)!;
226
244
  expect(sessionEntry.transactions.length).toEqual(5);
227
245
  expect(sessionEntry.signatureAfter[0]).not.toBeDefined();
228
246
  expect(sessionEntry.signatureAfter[1]).toBeDefined();
@@ -230,7 +248,7 @@ test("When adding large transactions (bigger than MAX_RECOMMENDED_TX_SIZE), we s
230
248
  expect(sessionEntry.signatureAfter[3]).toBeDefined();
231
249
  expect(sessionEntry.signatureAfter[4]).not.toBeDefined();
232
250
 
233
- const newContent = coValue.newContentSince({
251
+ const newContent = coValue.verified.newContentSince({
234
252
  id: coValue.id,
235
253
  header: false,
236
254
  sessions: {},
@@ -252,9 +270,54 @@ test("When adding large transactions (bigger than MAX_RECOMMENDED_TX_SIZE), we s
252
270
  );
253
271
  });
254
272
 
273
+ test("totalValidTransactions should return the number of valid transactions processed", async () => {
274
+ const client = setupTestNode({
275
+ connected: true,
276
+ });
277
+ const otherClient = setupTestNode({});
278
+
279
+ const otherClientConnection = otherClient.connectToSyncServer();
280
+
281
+ const group = client.node.createGroup();
282
+ group.addMember("everyone", "reader");
283
+
284
+ const stream = group.createStream();
285
+ stream.push(1, "trusting");
286
+
287
+ const streamOnOtherClient = await loadCoValueOrFail(
288
+ otherClient.node,
289
+ stream.id,
290
+ );
291
+
292
+ otherClientConnection.peerState.gracefulShutdown();
293
+
294
+ group.addMember("everyone", "writer");
295
+
296
+ await new Promise((resolve) => setTimeout(resolve, 50));
297
+
298
+ streamOnOtherClient.push(2, "trusting");
299
+
300
+ expect(streamOnOtherClient.totalValidTransactions).toEqual(1);
301
+ expect(Object.keys(streamOnOtherClient.toJSON()).length).toEqual(1);
302
+
303
+ otherClient.connectToSyncServer();
304
+
305
+ await waitFor(() => {
306
+ expect(
307
+ Object.keys(
308
+ streamOnOtherClient.core.getCurrentContent().toJSON() as object,
309
+ ).length,
310
+ ).toEqual(2);
311
+ });
312
+
313
+ expect(
314
+ streamOnOtherClient.core.getCurrentContent().totalValidTransactions,
315
+ ).toEqual(2);
316
+ });
317
+
255
318
  describe("isBinaryStreamEnded", () => {
256
319
  function setup() {
257
- const node = new LocalNode(...randomAnonymousAccountAndSessionID(), Crypto);
320
+ const node = nodeWithRandomAgentAndSessionID();
258
321
 
259
322
  const coValue = node.createCoValue({
260
323
  type: "costream",
@@ -317,7 +380,7 @@ describe("Binary stream order", () => {
317
380
  }
318
381
 
319
382
  test("sorts by madeAt timestamp first", () => {
320
- const node = new LocalNode(...randomAnonymousAccountAndSessionID(), Crypto);
383
+ const node = nodeWithRandomAgentAndSessionID();
321
384
  const coValue = node.createCoValue({
322
385
  type: "costream",
323
386
  ruleset: { type: "unsafeAllowAll" },
@@ -349,7 +412,7 @@ describe("Binary stream order", () => {
349
412
  });
350
413
 
351
414
  test("sorts by sessionID when timestamps are equal", () => {
352
- const node = new LocalNode(...randomAnonymousAccountAndSessionID(), Crypto);
415
+ const node = nodeWithRandomAgentAndSessionID();
353
416
  const coValue = node.createCoValue({
354
417
  type: "costream",
355
418
  ruleset: { type: "unsafeAllowAll" },
@@ -382,7 +445,7 @@ describe("Binary stream order", () => {
382
445
  });
383
446
 
384
447
  test("sorts by txIndex when timestamps and sessionIDs are equal", () => {
385
- const node = new LocalNode(...randomAnonymousAccountAndSessionID(), Crypto);
448
+ const node = nodeWithRandomAgentAndSessionID();
386
449
  const coValue = node.createCoValue({
387
450
  type: "costream",
388
451
  ruleset: { type: "unsafeAllowAll" },
@@ -1,5 +1,6 @@
1
1
  import { assert, afterEach, beforeEach, expect, test, vi } from "vitest";
2
- import { CoValueCore, Transaction } from "../coValueCore.js";
2
+ import { CoValueCore } from "../coValueCore/coValueCore.js";
3
+ import { Transaction } from "../coValueCore/verifiedState.js";
3
4
  import { MapOpPayload } from "../coValues/coMap.js";
4
5
  import { WasmCrypto } from "../crypto/WasmCrypto.js";
5
6
  import { stableStringify } from "../jsonStringify.js";
@@ -10,7 +11,8 @@ import {
10
11
  createTestNode,
11
12
  createTwoConnectedNodes,
12
13
  loadCoValueOrFail,
13
- randomAnonymousAccountAndSessionID,
14
+ nodeWithRandomAgentAndSessionID,
15
+ randomAgentAndSessionID,
14
16
  tearDownTestMetricReader,
15
17
  } from "./testUtils.js";
16
18
 
@@ -27,8 +29,8 @@ afterEach(() => {
27
29
  });
28
30
 
29
31
  test("Can create coValue with new agent credentials and add transaction to it", () => {
30
- const [account, sessionID] = randomAnonymousAccountAndSessionID();
31
- const node = new LocalNode(account, sessionID, Crypto);
32
+ const [agent, sessionID] = randomAgentAndSessionID();
33
+ const node = new LocalNode(agent.agentSecret, sessionID, Crypto);
32
34
 
33
35
  const coValue = node.createCoValue({
34
36
  type: "costream",
@@ -47,7 +49,7 @@ test("Can create coValue with new agent credentials and add transaction to it",
47
49
  ]),
48
50
  };
49
51
 
50
- const { expectedNewHash } = coValue.expectedNewHashAfter(
52
+ const { expectedNewHash } = coValue.verified.expectedNewHashAfter(
51
53
  node.currentSessionID,
52
54
  [transaction],
53
55
  );
@@ -58,7 +60,8 @@ test("Can create coValue with new agent credentials and add transaction to it",
58
60
  node.currentSessionID,
59
61
  [transaction],
60
62
  expectedNewHash,
61
- Crypto.sign(account.currentSignerSecret(), expectedNewHash),
63
+ Crypto.sign(agent.currentSignerSecret(), expectedNewHash),
64
+ "immediate",
62
65
  )
63
66
  ._unsafeUnwrap(),
64
67
  ).toBe(true);
@@ -66,8 +69,7 @@ test("Can create coValue with new agent credentials and add transaction to it",
66
69
 
67
70
  test("transactions with wrong signature are rejected", () => {
68
71
  const wrongAgent = Crypto.newRandomAgentSecret();
69
- const [agentSecret, sessionID] = randomAnonymousAccountAndSessionID();
70
- const node = new LocalNode(agentSecret, sessionID, Crypto);
72
+ const node = nodeWithRandomAgentAndSessionID();
71
73
 
72
74
  const coValue = node.createCoValue({
73
75
  type: "costream",
@@ -86,7 +88,7 @@ test("transactions with wrong signature are rejected", () => {
86
88
  ]),
87
89
  };
88
90
 
89
- const { expectedNewHash } = coValue.expectedNewHashAfter(
91
+ const { expectedNewHash } = coValue.verified.expectedNewHashAfter(
90
92
  node.currentSessionID,
91
93
  [transaction],
92
94
  );
@@ -98,13 +100,14 @@ test("transactions with wrong signature are rejected", () => {
98
100
  [transaction],
99
101
  expectedNewHash,
100
102
  Crypto.sign(Crypto.getAgentSignerSecret(wrongAgent), expectedNewHash),
103
+ "immediate",
101
104
  )
102
105
  ._unsafeUnwrapErr({ withStackTrace: true });
103
106
  });
104
107
 
105
108
  test("transactions with correctly signed, but wrong hash are rejected", () => {
106
- const [account, sessionID] = randomAnonymousAccountAndSessionID();
107
- const node = new LocalNode(account, sessionID, Crypto);
109
+ const [agent, sessionID] = randomAgentAndSessionID();
110
+ const node = new LocalNode(agent.agentSecret, sessionID, Crypto);
108
111
 
109
112
  const coValue = node.createCoValue({
110
113
  type: "costream",
@@ -123,7 +126,7 @@ test("transactions with correctly signed, but wrong hash are rejected", () => {
123
126
  ]),
124
127
  };
125
128
 
126
- const { expectedNewHash } = coValue.expectedNewHashAfter(
129
+ const { expectedNewHash } = coValue.verified.expectedNewHashAfter(
127
130
  node.currentSessionID,
128
131
  [
129
132
  {
@@ -144,14 +147,15 @@ test("transactions with correctly signed, but wrong hash are rejected", () => {
144
147
  node.currentSessionID,
145
148
  [transaction],
146
149
  expectedNewHash,
147
- Crypto.sign(account.currentSignerSecret(), expectedNewHash),
150
+ Crypto.sign(agent.currentSignerSecret(), expectedNewHash),
151
+ "immediate",
148
152
  )
149
153
  ._unsafeUnwrapErr({ withStackTrace: true });
150
154
  });
151
155
 
152
156
  test("New transactions in a group correctly update owned values, including subscriptions", async () => {
153
- const [account, sessionID] = randomAnonymousAccountAndSessionID();
154
- const node = new LocalNode(account, sessionID, Crypto);
157
+ const [agent, sessionID] = randomAgentAndSessionID();
158
+ const node = new LocalNode(agent.agentSecret, sessionID, Crypto);
155
159
 
156
160
  const group = node.createGroup();
157
161
 
@@ -175,18 +179,19 @@ test("New transactions in a group correctly update owned values, including subsc
175
179
  changes: stableStringify([
176
180
  {
177
181
  op: "set",
178
- key: account.id,
182
+ key: agent.id,
179
183
  value: "revoked",
180
- } satisfies MapOpPayload<typeof account.id, Role>,
184
+ } satisfies MapOpPayload<typeof agent.id, Role>,
181
185
  ]),
182
186
  } satisfies Transaction;
183
187
 
184
- const { expectedNewHash } = group.core.expectedNewHashAfter(sessionID, [
185
- resignationThatWeJustLearnedAbout,
186
- ]);
188
+ const { expectedNewHash } = group.core.verified.expectedNewHashAfter(
189
+ sessionID,
190
+ [resignationThatWeJustLearnedAbout],
191
+ );
187
192
 
188
193
  const signature = Crypto.sign(
189
- node.account.currentSignerSecret(),
194
+ node.getCurrentAgent().currentSignerSecret(),
190
195
  expectedNewHash,
191
196
  );
192
197
 
@@ -198,6 +203,7 @@ test("New transactions in a group correctly update owned values, including subsc
198
203
  [resignationThatWeJustLearnedAbout],
199
204
  expectedNewHash,
200
205
  signature,
206
+ "immediate",
201
207
  )
202
208
  ._unsafeUnwrap({ withStackTrace: true });
203
209
 
@@ -210,8 +216,7 @@ test("New transactions in a group correctly update owned values, including subsc
210
216
  });
211
217
 
212
218
  test("correctly records transactions", async () => {
213
- const [account, sessionID] = randomAnonymousAccountAndSessionID();
214
- const node = new LocalNode(account, sessionID, Crypto);
219
+ const node = nodeWithRandomAgentAndSessionID();
215
220
 
216
221
  const changes1 = stableStringify([{ hello: "world" }]);
217
222
  node.syncManager.recordTransactionsSize(
@@ -253,8 +258,7 @@ test("correctly records transactions", async () => {
253
258
  });
254
259
 
255
260
  test("(smoke test) records transactions from local node", async () => {
256
- const [account, sessionID] = randomAnonymousAccountAndSessionID();
257
- const node = new LocalNode(account, sessionID, Crypto);
261
+ const node = nodeWithRandomAgentAndSessionID();
258
262
 
259
263
  node.createGroup();
260
264
 
@@ -294,8 +298,7 @@ test("creating a coValue with a group should't trigger automatically a content c
294
298
  });
295
299
 
296
300
  test("loading a coValue core without having the owner group available doesn't crash", () => {
297
- const [account, sessionID] = randomAnonymousAccountAndSessionID();
298
- const node = new LocalNode(account, sessionID, Crypto);
301
+ const node = nodeWithRandomAgentAndSessionID();
299
302
 
300
303
  const otherNode = createTestNode();
301
304