cojson 0.7.0-alpha.7 → 0.7.0

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 (113) hide show
  1. package/.eslintrc.cjs +3 -2
  2. package/.prettierrc.js +9 -0
  3. package/.turbo/turbo-build.log +3 -30
  4. package/.turbo/turbo-lint.log +4 -0
  5. package/.turbo/turbo-test.log +1106 -0
  6. package/CHANGELOG.md +98 -0
  7. package/README.md +3 -1
  8. package/dist/base64url.test.js +25 -0
  9. package/dist/base64url.test.js.map +1 -0
  10. package/dist/coValueCore.js +60 -37
  11. package/dist/coValueCore.js.map +1 -1
  12. package/dist/coValues/account.js +16 -15
  13. package/dist/coValues/account.js.map +1 -1
  14. package/dist/coValues/coList.js +1 -1
  15. package/dist/coValues/coList.js.map +1 -1
  16. package/dist/coValues/coMap.js +17 -8
  17. package/dist/coValues/coMap.js.map +1 -1
  18. package/dist/coValues/group.js +13 -14
  19. package/dist/coValues/group.js.map +1 -1
  20. package/dist/coreToCoValue.js.map +1 -1
  21. package/dist/crypto/PureJSCrypto.js +89 -0
  22. package/dist/crypto/PureJSCrypto.js.map +1 -0
  23. package/dist/crypto/WasmCrypto.js +127 -0
  24. package/dist/crypto/WasmCrypto.js.map +1 -0
  25. package/dist/crypto/crypto.js +151 -0
  26. package/dist/crypto/crypto.js.map +1 -0
  27. package/dist/ids.js +4 -2
  28. package/dist/ids.js.map +1 -1
  29. package/dist/index.js +6 -8
  30. package/dist/index.js.map +1 -1
  31. package/dist/jsonStringify.js.map +1 -1
  32. package/dist/localNode.js +41 -38
  33. package/dist/localNode.js.map +1 -1
  34. package/dist/permissions.js +6 -6
  35. package/dist/permissions.js.map +1 -1
  36. package/dist/storage/FileSystem.js +61 -0
  37. package/dist/storage/FileSystem.js.map +1 -0
  38. package/dist/storage/chunksAndKnownStates.js +97 -0
  39. package/dist/storage/chunksAndKnownStates.js.map +1 -0
  40. package/dist/storage/index.js +265 -0
  41. package/dist/storage/index.js.map +1 -0
  42. package/dist/sync.js +29 -25
  43. package/dist/sync.js.map +1 -1
  44. package/dist/tests/account.test.js +58 -0
  45. package/dist/tests/account.test.js.map +1 -0
  46. package/dist/tests/coList.test.js +76 -0
  47. package/dist/tests/coList.test.js.map +1 -0
  48. package/dist/tests/coMap.test.js +136 -0
  49. package/dist/tests/coMap.test.js.map +1 -0
  50. package/dist/tests/coStream.test.js +172 -0
  51. package/dist/tests/coStream.test.js.map +1 -0
  52. package/dist/tests/coValueCore.test.js +114 -0
  53. package/dist/tests/coValueCore.test.js.map +1 -0
  54. package/dist/tests/crypto.test.js +118 -0
  55. package/dist/tests/crypto.test.js.map +1 -0
  56. package/dist/tests/cryptoImpl.test.js +113 -0
  57. package/dist/tests/cryptoImpl.test.js.map +1 -0
  58. package/dist/tests/group.test.js +34 -0
  59. package/dist/tests/group.test.js.map +1 -0
  60. package/dist/tests/permissions.test.js +1060 -0
  61. package/dist/tests/permissions.test.js.map +1 -0
  62. package/dist/tests/sync.test.js +816 -0
  63. package/dist/tests/sync.test.js.map +1 -0
  64. package/dist/tests/testUtils.js +12 -11
  65. package/dist/tests/testUtils.js.map +1 -1
  66. package/dist/typeUtils/accountOrAgentIDfromSessionID.js.map +1 -1
  67. package/dist/typeUtils/isAccountID.js.map +1 -1
  68. package/dist/typeUtils/isCoValue.js.map +1 -1
  69. package/package.json +14 -27
  70. package/src/base64url.test.ts +6 -5
  71. package/src/coValue.ts +1 -1
  72. package/src/coValueCore.ts +179 -126
  73. package/src/coValues/account.ts +30 -32
  74. package/src/coValues/coList.ts +11 -11
  75. package/src/coValues/coMap.ts +27 -17
  76. package/src/coValues/coStream.ts +17 -17
  77. package/src/coValues/group.ts +93 -109
  78. package/src/coreToCoValue.ts +5 -2
  79. package/src/crypto/PureJSCrypto.ts +200 -0
  80. package/src/crypto/WasmCrypto.ts +259 -0
  81. package/src/crypto/crypto.ts +336 -0
  82. package/src/ids.ts +8 -7
  83. package/src/index.ts +24 -24
  84. package/src/jsonStringify.ts +6 -4
  85. package/src/jsonValue.ts +2 -2
  86. package/src/localNode.ts +103 -109
  87. package/src/media.ts +3 -3
  88. package/src/permissions.ts +19 -21
  89. package/src/storage/FileSystem.ts +152 -0
  90. package/src/storage/chunksAndKnownStates.ts +139 -0
  91. package/src/storage/index.ts +479 -0
  92. package/src/streamUtils.ts +12 -12
  93. package/src/sync.ts +79 -63
  94. package/src/tests/account.test.ts +15 -15
  95. package/src/tests/coList.test.ts +94 -0
  96. package/src/tests/coMap.test.ts +162 -0
  97. package/src/tests/coStream.test.ts +246 -0
  98. package/src/tests/coValueCore.test.ts +36 -37
  99. package/src/tests/crypto.test.ts +66 -72
  100. package/src/tests/cryptoImpl.test.ts +183 -0
  101. package/src/tests/group.test.ts +16 -17
  102. package/src/tests/permissions.test.ts +269 -283
  103. package/src/tests/sync.test.ts +122 -123
  104. package/src/tests/testUtils.ts +24 -21
  105. package/src/typeUtils/accountOrAgentIDfromSessionID.ts +1 -2
  106. package/src/typeUtils/expectGroup.ts +1 -1
  107. package/src/typeUtils/isAccountID.ts +0 -1
  108. package/src/typeUtils/isCoValue.ts +1 -2
  109. package/tsconfig.json +0 -1
  110. package/dist/crypto.js +0 -254
  111. package/dist/crypto.js.map +0 -1
  112. package/src/crypto.ts +0 -484
  113. package/src/tests/coValue.test.ts +0 -497
@@ -1,497 +0,0 @@
1
- import { expect, test, beforeEach } from "vitest";
2
- import { expectList, expectMap, expectStream } from "../coValue.js";
3
- import { RawBinaryCoStream } from "../coValues/coStream.js";
4
- import { createdNowUnique } from "../crypto.js";
5
- import { MAX_RECOMMENDED_TX_SIZE, cojsonReady } from "../index.js";
6
- import { LocalNode } from "../localNode.js";
7
- import { accountOrAgentIDfromSessionID } from "../typeUtils/accountOrAgentIDfromSessionID.js";
8
- import { randomAnonymousAccountAndSessionID } from "./testUtils.js";
9
-
10
- import { webcrypto } from "node:crypto";
11
- if (!("crypto" in globalThis)) {
12
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
13
- (globalThis as any).crypto = webcrypto;
14
- }
15
-
16
- beforeEach(async () => {
17
- await cojsonReady;
18
- });
19
-
20
- test("Empty CoMap works", () => {
21
- const node = new LocalNode(...randomAnonymousAccountAndSessionID());
22
-
23
- const coValue = node.createCoValue({
24
- type: "comap",
25
- ruleset: { type: "unsafeAllowAll" },
26
- meta: null,
27
- ...createdNowUnique(),
28
- });
29
-
30
- const content = expectMap(coValue.getCurrentContent());
31
-
32
- expect(content.type).toEqual("comap");
33
- expect([...content.keys()]).toEqual([]);
34
- expect(content.toJSON()).toEqual({});
35
- });
36
-
37
- test("Can insert and delete CoMap entries in edit()", () => {
38
- const node = new LocalNode(...randomAnonymousAccountAndSessionID());
39
-
40
- const coValue = node.createCoValue({
41
- type: "comap",
42
- ruleset: { type: "unsafeAllowAll" },
43
- meta: null,
44
- ...createdNowUnique(),
45
- });
46
-
47
- const content = expectMap(coValue.getCurrentContent());
48
-
49
- expect(content.type).toEqual("comap");
50
-
51
- content.set("hello", "world", "trusting");
52
- expect(content.get("hello")).toEqual("world");
53
- content.set("foo", "bar", "trusting");
54
- expect(content.get("foo")).toEqual("bar");
55
- expect([...content.keys()]).toEqual(["hello", "foo"]);
56
- content.delete("foo", "trusting");
57
- expect(content.get("foo")).toEqual(undefined);
58
- });
59
-
60
- test("Can get CoMap entry values at different points in time", () => {
61
- const node = new LocalNode(...randomAnonymousAccountAndSessionID());
62
-
63
- const coValue = node.createCoValue({
64
- type: "comap",
65
- ruleset: { type: "unsafeAllowAll" },
66
- meta: null,
67
- ...createdNowUnique(),
68
- });
69
-
70
- const content = expectMap(coValue.getCurrentContent());
71
-
72
- expect(content.type).toEqual("comap");
73
-
74
- const beforeA = Date.now();
75
- while (Date.now() < beforeA + 10) {}
76
- content.set("hello", "A", "trusting");
77
- const beforeB = Date.now();
78
- while (Date.now() < beforeB + 10) {}
79
- content.set("hello", "B", "trusting");
80
- const beforeC = Date.now();
81
- while (Date.now() < beforeC + 10) {}
82
- content.set("hello", "C", "trusting");
83
- expect(content.get("hello")).toEqual("C");
84
- expect(content.atTime(Date.now()).get("hello")).toEqual("C");
85
- expect(content.atTime(beforeA).get("hello")).toEqual(undefined);
86
- expect(content.atTime(beforeB).get("hello")).toEqual("A");
87
- expect(content.atTime(beforeC).get("hello")).toEqual("B");
88
- });
89
-
90
- test("Can get all historic values of key in CoMap", () => {
91
- const node = new LocalNode(...randomAnonymousAccountAndSessionID());
92
-
93
- const coValue = node.createCoValue({
94
- type: "comap",
95
- ruleset: { type: "unsafeAllowAll" },
96
- meta: null,
97
- ...createdNowUnique(),
98
- });
99
-
100
- const content = expectMap(coValue.getCurrentContent());
101
-
102
- expect(content.type).toEqual("comap");
103
-
104
- content.set("hello", "A", "trusting");
105
- const editA = content.lastEditAt("hello");
106
- content.set("hello", "B", "trusting");
107
- const editB = content.lastEditAt("hello");
108
- content.delete("hello", "trusting");
109
- const editDel = content.lastEditAt("hello");
110
- content.set("hello", "C", "trusting");
111
- const editC = content.lastEditAt("hello");
112
- expect([...content.editsAt("hello")]).toEqual([
113
- {
114
- tx: editA!.tx,
115
- by: node.account.id,
116
- value: "A",
117
- at: editA?.at,
118
- },
119
- {
120
- tx: editB!.tx,
121
- by: node.account.id,
122
- value: "B",
123
- at: editB?.at,
124
- },
125
- {
126
- tx: editDel!.tx,
127
- by: node.account.id,
128
- value: undefined,
129
- at: editDel?.at,
130
- },
131
- {
132
- tx: editC!.tx,
133
- by: node.account.id,
134
- value: "C",
135
- at: editC?.at,
136
- },
137
- ]);
138
- });
139
-
140
- test("Can get last tx ID for a key in CoMap", () => {
141
- const node = new LocalNode(...randomAnonymousAccountAndSessionID());
142
-
143
- const coValue = node.createCoValue({
144
- type: "comap",
145
- ruleset: { type: "unsafeAllowAll" },
146
- meta: null,
147
- ...createdNowUnique(),
148
- });
149
-
150
- const content = expectMap(coValue.getCurrentContent());
151
-
152
- expect(content.type).toEqual("comap");
153
-
154
- expect(content.lastEditAt("hello")).toEqual(undefined);
155
- content.set("hello", "A", "trusting");
156
- const sessionID = content.lastEditAt("hello")?.tx.sessionID;
157
- expect(sessionID && accountOrAgentIDfromSessionID(sessionID)).toEqual(
158
- node.account.id
159
- );
160
- expect(content.lastEditAt("hello")?.tx.txIndex).toEqual(0);
161
- content.set("hello", "B", "trusting");
162
- expect(content.lastEditAt("hello")?.tx.txIndex).toEqual(1);
163
- content.set("hello", "C", "trusting");
164
- expect(content.lastEditAt("hello")?.tx.txIndex).toEqual(2);
165
- });
166
-
167
- test("Empty CoList works", () => {
168
- const node = new LocalNode(...randomAnonymousAccountAndSessionID());
169
-
170
- const coValue = node.createCoValue({
171
- type: "colist",
172
- ruleset: { type: "unsafeAllowAll" },
173
- meta: null,
174
- ...createdNowUnique(),
175
- });
176
-
177
- const content = expectList(coValue.getCurrentContent());
178
-
179
- expect(content.type).toEqual("colist");
180
- expect(content.toJSON()).toEqual([]);
181
- });
182
-
183
- test("Can append, prepend, delete and replace items in CoList", () => {
184
- const node = new LocalNode(...randomAnonymousAccountAndSessionID());
185
-
186
- const coValue = node.createCoValue({
187
- type: "colist",
188
- ruleset: { type: "unsafeAllowAll" },
189
- meta: null,
190
- ...createdNowUnique(),
191
- });
192
-
193
- const content = expectList(coValue.getCurrentContent());
194
-
195
- content.append("hello", 0, "trusting");
196
- expect(content.toJSON()).toEqual(["hello"]);
197
- content.append("world", 0, "trusting");
198
- expect(content.toJSON()).toEqual(["hello", "world"]);
199
- content.prepend("beautiful", 1, "trusting");
200
- expect(content.toJSON()).toEqual(["hello", "beautiful", "world"]);
201
- content.prepend("hooray", 3, "trusting");
202
- expect(content.toJSON()).toEqual(["hello", "beautiful", "world", "hooray"]);
203
- content.replace(2, "universe", "trusting");
204
- expect(content.toJSON()).toEqual(["hello", "beautiful", "universe", "hooray"]);
205
- content.delete(2, "trusting");
206
- expect(content.toJSON()).toEqual(["hello", "beautiful", "hooray"]);
207
- });
208
-
209
- test("Push is equivalent to append after last item", () => {
210
- const node = new LocalNode(...randomAnonymousAccountAndSessionID());
211
-
212
- const coValue = node.createCoValue({
213
- type: "colist",
214
- ruleset: { type: "unsafeAllowAll" },
215
- meta: null,
216
- ...createdNowUnique(),
217
- });
218
-
219
- const content = expectList(coValue.getCurrentContent());
220
-
221
- expect(content.type).toEqual("colist");
222
-
223
- content.append("hello", 0, "trusting");
224
- expect(content.toJSON()).toEqual(["hello"]);
225
- content.append("world", undefined, "trusting");
226
- expect(content.toJSON()).toEqual(["hello", "world"]);
227
- content.append("hooray", undefined, "trusting");
228
- expect(content.toJSON()).toEqual(["hello", "world", "hooray"]);
229
- });
230
-
231
- test("Can push into empty list", () => {
232
- const node = new LocalNode(...randomAnonymousAccountAndSessionID());
233
-
234
- const coValue = node.createCoValue({
235
- type: "colist",
236
- ruleset: { type: "unsafeAllowAll" },
237
- meta: null,
238
- ...createdNowUnique(),
239
- });
240
-
241
- const content = expectList(coValue.getCurrentContent());
242
-
243
- expect(content.type).toEqual("colist");
244
-
245
- content.append("hello", undefined, "trusting");
246
- expect(content.toJSON()).toEqual(["hello"]);
247
- });
248
-
249
- test("Empty CoStream works", () => {
250
- const node = new LocalNode(...randomAnonymousAccountAndSessionID());
251
-
252
- const coValue = node.createCoValue({
253
- type: "costream",
254
- ruleset: { type: "unsafeAllowAll" },
255
- meta: null,
256
- ...createdNowUnique(),
257
- });
258
-
259
- const content = expectStream(coValue.getCurrentContent());
260
-
261
- expect(content.type).toEqual("costream");
262
- expect(content.toJSON()).toEqual({});
263
- expect(content.getSingleStream()).toEqual(undefined);
264
- });
265
-
266
- test("Can push into CoStream", () => {
267
- const node = new LocalNode(...randomAnonymousAccountAndSessionID());
268
-
269
- const coValue = node.createCoValue({
270
- type: "costream",
271
- ruleset: { type: "unsafeAllowAll" },
272
- meta: null,
273
- ...createdNowUnique(),
274
- });
275
-
276
- const content = expectStream(coValue.getCurrentContent());
277
-
278
- content.push({ hello: "world" }, "trusting");
279
- expect(content.toJSON()).toEqual({
280
- [node.currentSessionID]: [{ hello: "world" }],
281
- });
282
- content.push({ foo: "bar" }, "trusting");
283
- expect(content.toJSON()).toEqual({
284
- [node.currentSessionID]: [{ hello: "world" }, { foo: "bar" }],
285
- });
286
- expect(content.getSingleStream()).toEqual([
287
- { hello: "world" },
288
- { foo: "bar" },
289
- ]);
290
- });
291
-
292
- test("Empty RawBinaryCoStream works", () => {
293
- const node = new LocalNode(...randomAnonymousAccountAndSessionID());
294
-
295
- const coValue = node.createCoValue({
296
- type: "costream",
297
- ruleset: { type: "unsafeAllowAll" },
298
- meta: { type: "binary" },
299
- ...createdNowUnique(),
300
- });
301
-
302
- const content = coValue.getCurrentContent();
303
-
304
- if (
305
- content.type !== "costream" ||
306
- content.headerMeta?.type !== "binary" ||
307
- !(content instanceof RawBinaryCoStream)
308
- ) {
309
- throw new Error("Expected binary stream");
310
- }
311
-
312
- expect(content.type).toEqual("costream");
313
- expect(content.headerMeta.type).toEqual("binary");
314
- expect(content.toJSON()).toEqual({});
315
- expect(content.getBinaryChunks()).toEqual(undefined);
316
- });
317
-
318
- test("Can push into RawBinaryCoStream", () => {
319
- const node = new LocalNode(...randomAnonymousAccountAndSessionID());
320
-
321
- const coValue = node.createCoValue({
322
- type: "costream",
323
- ruleset: { type: "unsafeAllowAll" },
324
- meta: { type: "binary" },
325
- ...createdNowUnique(),
326
- });
327
-
328
- const content = coValue.getCurrentContent();
329
-
330
- if (
331
- content.type !== "costream" ||
332
- content.headerMeta?.type !== "binary" ||
333
- !(content instanceof RawBinaryCoStream)
334
- ) {
335
- throw new Error("Expected binary stream");
336
- }
337
-
338
- content.startBinaryStream(
339
- { mimeType: "text/plain", fileName: "test.txt" },
340
- "trusting"
341
- );
342
- expect(content.getBinaryChunks(true)).toEqual({
343
- mimeType: "text/plain",
344
- fileName: "test.txt",
345
- chunks: [],
346
- finished: false,
347
- });
348
- content.pushBinaryStreamChunk(new Uint8Array([1, 2, 3]), "trusting");
349
- expect(content.getBinaryChunks(true)).toEqual({
350
- mimeType: "text/plain",
351
- fileName: "test.txt",
352
- chunks: [new Uint8Array([1, 2, 3])],
353
- finished: false,
354
- });
355
- content.pushBinaryStreamChunk(new Uint8Array([4, 5, 6]), "trusting");
356
-
357
- content.endBinaryStream("trusting");
358
- expect(content.getBinaryChunks()).toEqual({
359
- mimeType: "text/plain",
360
- fileName: "test.txt",
361
- chunks: [new Uint8Array([1, 2, 3]), new Uint8Array([4, 5, 6])],
362
- finished: true,
363
- });
364
- });
365
-
366
- 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", () => {
367
- const node = new LocalNode(...randomAnonymousAccountAndSessionID());
368
-
369
- const coValue = node.createCoValue({
370
- type: "costream",
371
- ruleset: { type: "unsafeAllowAll" },
372
- meta: { type: "binary" },
373
- ...createdNowUnique(),
374
- });
375
-
376
- const content = coValue.getCurrentContent();
377
-
378
- if (
379
- content.type !== "costream" ||
380
- content.headerMeta?.type !== "binary" ||
381
- !(content instanceof RawBinaryCoStream)
382
- ) {
383
- throw new Error("Expected binary stream");
384
- }
385
-
386
- content.startBinaryStream(
387
- { mimeType: "text/plain", fileName: "test.txt" },
388
- "trusting"
389
- );
390
-
391
- for (let i = 0; i < 10; i++) {
392
- const chunk = new Uint8Array(MAX_RECOMMENDED_TX_SIZE / 3 + 100);
393
-
394
- content.pushBinaryStreamChunk(chunk, "trusting");
395
- }
396
-
397
- content.endBinaryStream("trusting");
398
-
399
- const sessionEntry = coValue.sessionLogs.get(node.currentSessionID)!;
400
- expect(sessionEntry.transactions.length).toEqual(12);
401
- expect(sessionEntry.signatureAfter[0]).not.toBeDefined();
402
- expect(sessionEntry.signatureAfter[1]).not.toBeDefined();
403
- expect(sessionEntry.signatureAfter[2]).not.toBeDefined();
404
- expect(sessionEntry.signatureAfter[3]).toBeDefined();
405
- expect(sessionEntry.signatureAfter[4]).not.toBeDefined();
406
- expect(sessionEntry.signatureAfter[5]).not.toBeDefined();
407
- expect(sessionEntry.signatureAfter[6]).toBeDefined();
408
- expect(sessionEntry.signatureAfter[7]).not.toBeDefined();
409
- expect(sessionEntry.signatureAfter[8]).not.toBeDefined();
410
- expect(sessionEntry.signatureAfter[9]).toBeDefined();
411
- expect(sessionEntry.signatureAfter[10]).not.toBeDefined();
412
- expect(sessionEntry.signatureAfter[11]).not.toBeDefined();
413
-
414
- const newContent = coValue.newContentSince({
415
- id: coValue.id,
416
- header: false,
417
- sessions: {},
418
- })!;
419
-
420
- expect(newContent.length).toEqual(5);
421
- expect(newContent[0]!.header).toBeDefined();
422
- expect(newContent[1]!.new[node.currentSessionID]!.lastSignature).toEqual(
423
- sessionEntry.signatureAfter[3]
424
- );
425
- expect(newContent[2]!.new[node.currentSessionID]!.lastSignature).toEqual(
426
- sessionEntry.signatureAfter[6]
427
- );
428
- expect(newContent[3]!.new[node.currentSessionID]!.lastSignature).toEqual(
429
- sessionEntry.signatureAfter[9]
430
- );
431
- expect(newContent[4]!.new[node.currentSessionID]!.lastSignature).toEqual(
432
- sessionEntry.lastSignature
433
- );
434
- });
435
-
436
- 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", () => {
437
- const node = new LocalNode(...randomAnonymousAccountAndSessionID());
438
-
439
- const coValue = node.createCoValue({
440
- type: "costream",
441
- ruleset: { type: "unsafeAllowAll" },
442
- meta: { type: "binary" },
443
- ...createdNowUnique(),
444
- });
445
-
446
- const content = coValue.getCurrentContent();
447
-
448
- if (
449
- content.type !== "costream" ||
450
- content.headerMeta?.type !== "binary" ||
451
- !(content instanceof RawBinaryCoStream)
452
- ) {
453
- throw new Error("Expected binary stream");
454
- }
455
-
456
- content.startBinaryStream(
457
- { mimeType: "text/plain", fileName: "test.txt" },
458
- "trusting"
459
- );
460
-
461
- const chunk = new Uint8Array(MAX_RECOMMENDED_TX_SIZE + 100);
462
-
463
- for (let i = 0; i < 3; i++) {
464
- content.pushBinaryStreamChunk(chunk, "trusting");
465
- }
466
-
467
- content.endBinaryStream("trusting");
468
-
469
- const sessionEntry = coValue.sessionLogs.get(node.currentSessionID)!;
470
- expect(sessionEntry.transactions.length).toEqual(5);
471
- expect(sessionEntry.signatureAfter[0]).not.toBeDefined();
472
- expect(sessionEntry.signatureAfter[1]).toBeDefined();
473
- expect(sessionEntry.signatureAfter[2]).toBeDefined();
474
- expect(sessionEntry.signatureAfter[3]).toBeDefined();
475
- expect(sessionEntry.signatureAfter[4]).not.toBeDefined();
476
-
477
- const newContent = coValue.newContentSince({
478
- id: coValue.id,
479
- header: false,
480
- sessions: {},
481
- })!;
482
-
483
- expect(newContent.length).toEqual(5);
484
- expect(newContent[0]!.header).toBeDefined();
485
- expect(newContent[1]!.new[node.currentSessionID]!.lastSignature).toEqual(
486
- sessionEntry.signatureAfter[1]
487
- );
488
- expect(newContent[2]!.new[node.currentSessionID]!.lastSignature).toEqual(
489
- sessionEntry.signatureAfter[2]
490
- );
491
- expect(newContent[3]!.new[node.currentSessionID]!.lastSignature).toEqual(
492
- sessionEntry.signatureAfter[3]
493
- );
494
- expect(newContent[4]!.new[node.currentSessionID]!.lastSignature).toEqual(
495
- sessionEntry.lastSignature
496
- );
497
- });