cojson 0.18.36 → 0.18.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.
- package/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +18 -0
- package/dist/coValueCore/SessionMap.d.ts +5 -3
- package/dist/coValueCore/SessionMap.d.ts.map +1 -1
- package/dist/coValueCore/SessionMap.js +19 -9
- package/dist/coValueCore/SessionMap.js.map +1 -1
- package/dist/coValueCore/coValueCore.d.ts +5 -2
- package/dist/coValueCore/coValueCore.d.ts.map +1 -1
- package/dist/coValueCore/coValueCore.js +24 -4
- package/dist/coValueCore/coValueCore.js.map +1 -1
- package/dist/coValueCore/verifiedState.d.ts +1 -3
- package/dist/coValueCore/verifiedState.d.ts.map +1 -1
- package/dist/coValueCore/verifiedState.js +10 -14
- package/dist/coValueCore/verifiedState.js.map +1 -1
- package/dist/coValues/group.d.ts +2 -1
- package/dist/coValues/group.d.ts.map +1 -1
- package/dist/coValues/group.js +21 -18
- package/dist/coValues/group.js.map +1 -1
- package/dist/exports.d.ts +5 -4
- package/dist/exports.d.ts.map +1 -1
- package/dist/exports.js +3 -3
- package/dist/exports.js.map +1 -1
- package/dist/permissions.d.ts +0 -1
- package/dist/permissions.d.ts.map +1 -1
- package/dist/permissions.js +83 -89
- package/dist/permissions.js.map +1 -1
- package/dist/queue/LocalTransactionsSyncQueue.d.ts.map +1 -1
- package/dist/queue/LocalTransactionsSyncQueue.js +1 -18
- package/dist/queue/LocalTransactionsSyncQueue.js.map +1 -1
- package/dist/sync.d.ts.map +1 -1
- package/dist/sync.js +8 -0
- package/dist/sync.js.map +1 -1
- package/dist/tests/StorageApiAsync.test.js +8 -8
- package/dist/tests/coValueCore.isStreaming.test.js +30 -40
- package/dist/tests/coValueCore.isStreaming.test.js.map +1 -1
- package/dist/tests/coValueCore.newContentSince.test.js +242 -132
- package/dist/tests/coValueCore.newContentSince.test.js.map +1 -1
- package/dist/tests/group.inheritance.test.js +47 -1
- package/dist/tests/group.inheritance.test.js.map +1 -1
- package/dist/tests/group.invite.test.js +4 -9
- package/dist/tests/group.invite.test.js.map +1 -1
- package/dist/tests/sync.auth.test.js +6 -6
- package/dist/tests/sync.load.test.js +11 -75
- package/dist/tests/sync.load.test.js.map +1 -1
- package/dist/tests/sync.mesh.test.js +2 -2
- package/dist/tests/sync.storage.test.js +22 -48
- package/dist/tests/sync.storage.test.js.map +1 -1
- package/dist/tests/sync.storageAsync.test.js +121 -71
- package/dist/tests/sync.storageAsync.test.js.map +1 -1
- package/dist/tests/sync.upload.test.js +11 -75
- package/dist/tests/sync.upload.test.js.map +1 -1
- package/dist/tests/testUtils.d.ts +4 -1
- package/dist/tests/testUtils.d.ts.map +1 -1
- package/dist/tests/testUtils.js +11 -0
- package/dist/tests/testUtils.js.map +1 -1
- package/package.json +3 -3
- package/src/coValueCore/SessionMap.ts +25 -15
- package/src/coValueCore/coValueCore.ts +32 -2
- package/src/coValueCore/verifiedState.ts +11 -20
- package/src/coValues/group.ts +28 -24
- package/src/exports.ts +5 -2
- package/src/permissions.ts +98 -119
- package/src/queue/LocalTransactionsSyncQueue.ts +1 -20
- package/src/sync.ts +9 -0
- package/src/tests/StorageApiAsync.test.ts +8 -8
- package/src/tests/coValueCore.isStreaming.test.ts +84 -91
- package/src/tests/coValueCore.newContentSince.test.ts +246 -141
- package/src/tests/group.inheritance.test.ts +61 -0
- package/src/tests/group.invite.test.ts +4 -21
- package/src/tests/sync.auth.test.ts +6 -6
- package/src/tests/sync.load.test.ts +11 -79
- package/src/tests/sync.mesh.test.ts +2 -2
- package/src/tests/sync.storage.test.ts +22 -51
- package/src/tests/sync.storageAsync.test.ts +159 -76
- package/src/tests/sync.upload.test.ts +11 -78
- package/src/tests/testUtils.ts +16 -0
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { assert, beforeEach, describe, expect, test } from "vitest";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
fillCoMapWithLargeData,
|
|
4
|
+
loadCoValueOrFail,
|
|
5
|
+
setupTestNode,
|
|
6
|
+
} from "./testUtils.js";
|
|
3
7
|
import { CO_VALUE_PRIORITY } from "../priority.js";
|
|
4
8
|
import { emptyKnownState, SessionID } from "../exports.js";
|
|
5
9
|
import { NewContentMessage } from "../sync.js";
|
|
@@ -175,15 +179,7 @@ describe("newContentSince", () => {
|
|
|
175
179
|
const group = client.node.createGroup();
|
|
176
180
|
const map = group.createMap();
|
|
177
181
|
|
|
178
|
-
|
|
179
|
-
const chunkSize = 1024; // 1KB chunks
|
|
180
|
-
const chunks = dataSize / chunkSize;
|
|
181
|
-
const value = Buffer.alloc(chunkSize, `value$`).toString("base64");
|
|
182
|
-
|
|
183
|
-
for (let i = 0; i < chunks; i++) {
|
|
184
|
-
const key = `key${i}`;
|
|
185
|
-
map.set(key, value, "trusting");
|
|
186
|
-
}
|
|
182
|
+
fillCoMapWithLargeData(map);
|
|
187
183
|
|
|
188
184
|
const content = map.core.newContentSince(undefined);
|
|
189
185
|
|
|
@@ -198,7 +194,7 @@ describe("newContentSince", () => {
|
|
|
198
194
|
{
|
|
199
195
|
"action": "content",
|
|
200
196
|
"expectContentUntil": {
|
|
201
|
-
"alice":
|
|
197
|
+
"alice": 200,
|
|
202
198
|
},
|
|
203
199
|
"header": "header",
|
|
204
200
|
"id": "id",
|
|
@@ -218,7 +214,20 @@ describe("newContentSince", () => {
|
|
|
218
214
|
"new": {
|
|
219
215
|
"alice": {
|
|
220
216
|
"lastSignature": "signature",
|
|
221
|
-
"newTransactions": "
|
|
217
|
+
"newTransactions": "73 transactions after 73",
|
|
218
|
+
},
|
|
219
|
+
},
|
|
220
|
+
"priority": 3,
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
"action": "content",
|
|
224
|
+
"expectContentUntil": undefined,
|
|
225
|
+
"header": undefined,
|
|
226
|
+
"id": "id",
|
|
227
|
+
"new": {
|
|
228
|
+
"alice": {
|
|
229
|
+
"lastSignature": "signature",
|
|
230
|
+
"newTransactions": "54 transactions after 146",
|
|
222
231
|
},
|
|
223
232
|
},
|
|
224
233
|
"priority": 3,
|
|
@@ -236,15 +245,7 @@ describe("newContentSince", () => {
|
|
|
236
245
|
const map = group.createMap();
|
|
237
246
|
|
|
238
247
|
// Generate a large amount of data (about 1MB)
|
|
239
|
-
|
|
240
|
-
const chunkSize = 1024; // 1KB chunks
|
|
241
|
-
const chunks = dataSize / chunkSize;
|
|
242
|
-
const value = Buffer.alloc(chunkSize, `value$`).toString("base64");
|
|
243
|
-
|
|
244
|
-
for (let i = 0; i < chunks; i++) {
|
|
245
|
-
const key = `key${i}`;
|
|
246
|
-
map.set(key, value, "trusting");
|
|
247
|
-
}
|
|
248
|
+
fillCoMapWithLargeData(map);
|
|
248
249
|
|
|
249
250
|
// Add a small session
|
|
250
251
|
const newSession = client.spawnNewSession();
|
|
@@ -265,7 +266,7 @@ describe("newContentSince", () => {
|
|
|
265
266
|
{
|
|
266
267
|
"action": "content",
|
|
267
268
|
"expectContentUntil": {
|
|
268
|
-
"alice":
|
|
269
|
+
"alice": 200,
|
|
269
270
|
"bob": 1,
|
|
270
271
|
},
|
|
271
272
|
"header": "header",
|
|
@@ -286,7 +287,20 @@ describe("newContentSince", () => {
|
|
|
286
287
|
"new": {
|
|
287
288
|
"alice": {
|
|
288
289
|
"lastSignature": "signature",
|
|
289
|
-
"newTransactions": "
|
|
290
|
+
"newTransactions": "73 transactions after 73",
|
|
291
|
+
},
|
|
292
|
+
},
|
|
293
|
+
"priority": 3,
|
|
294
|
+
},
|
|
295
|
+
{
|
|
296
|
+
"action": "content",
|
|
297
|
+
"expectContentUntil": undefined,
|
|
298
|
+
"header": undefined,
|
|
299
|
+
"id": "id",
|
|
300
|
+
"new": {
|
|
301
|
+
"alice": {
|
|
302
|
+
"lastSignature": "signature",
|
|
303
|
+
"newTransactions": "54 transactions after 146",
|
|
290
304
|
},
|
|
291
305
|
"bob": {
|
|
292
306
|
"lastSignature": "signature",
|
|
@@ -308,24 +322,13 @@ describe("newContentSince", () => {
|
|
|
308
322
|
const map = group.createMap();
|
|
309
323
|
|
|
310
324
|
// Generate a large amount of data in first session (about 1MB)
|
|
311
|
-
|
|
312
|
-
const chunkSize = 1024; // 1KB chunks
|
|
313
|
-
const chunks = dataSize / chunkSize;
|
|
314
|
-
const value = Buffer.alloc(chunkSize, `value$`).toString("base64");
|
|
315
|
-
|
|
316
|
-
for (let i = 0; i < chunks; i++) {
|
|
317
|
-
const key = `key1_${i}`;
|
|
318
|
-
map.set(key, value, "trusting");
|
|
319
|
-
}
|
|
325
|
+
fillCoMapWithLargeData(map);
|
|
320
326
|
|
|
321
327
|
// Add second large session
|
|
322
328
|
const newSession = client.spawnNewSession();
|
|
323
329
|
const mapInNewSession = await loadCoValueOrFail(newSession.node, map.id);
|
|
324
330
|
|
|
325
|
-
|
|
326
|
-
const key = `key2_${i}`;
|
|
327
|
-
mapInNewSession.set(key, value, "trusting");
|
|
328
|
-
}
|
|
331
|
+
fillCoMapWithLargeData(mapInNewSession);
|
|
329
332
|
|
|
330
333
|
const content = mapInNewSession.core.newContentSince(undefined);
|
|
331
334
|
|
|
@@ -341,8 +344,8 @@ describe("newContentSince", () => {
|
|
|
341
344
|
{
|
|
342
345
|
"action": "content",
|
|
343
346
|
"expectContentUntil": {
|
|
344
|
-
"alice":
|
|
345
|
-
"bob":
|
|
347
|
+
"alice": 200,
|
|
348
|
+
"bob": 200,
|
|
346
349
|
},
|
|
347
350
|
"header": "header",
|
|
348
351
|
"id": "id",
|
|
@@ -354,6 +357,19 @@ describe("newContentSince", () => {
|
|
|
354
357
|
},
|
|
355
358
|
"priority": 3,
|
|
356
359
|
},
|
|
360
|
+
{
|
|
361
|
+
"action": "content",
|
|
362
|
+
"expectContentUntil": undefined,
|
|
363
|
+
"header": undefined,
|
|
364
|
+
"id": "id",
|
|
365
|
+
"new": {
|
|
366
|
+
"alice": {
|
|
367
|
+
"lastSignature": "signature",
|
|
368
|
+
"newTransactions": "73 transactions after 73",
|
|
369
|
+
},
|
|
370
|
+
},
|
|
371
|
+
"priority": 3,
|
|
372
|
+
},
|
|
357
373
|
{
|
|
358
374
|
"action": "content",
|
|
359
375
|
"expectContentUntil": undefined,
|
|
@@ -367,6 +383,19 @@ describe("newContentSince", () => {
|
|
|
367
383
|
},
|
|
368
384
|
"priority": 3,
|
|
369
385
|
},
|
|
386
|
+
{
|
|
387
|
+
"action": "content",
|
|
388
|
+
"expectContentUntil": undefined,
|
|
389
|
+
"header": undefined,
|
|
390
|
+
"id": "id",
|
|
391
|
+
"new": {
|
|
392
|
+
"bob": {
|
|
393
|
+
"lastSignature": "signature",
|
|
394
|
+
"newTransactions": "73 transactions after 73",
|
|
395
|
+
},
|
|
396
|
+
},
|
|
397
|
+
"priority": 3,
|
|
398
|
+
},
|
|
370
399
|
{
|
|
371
400
|
"action": "content",
|
|
372
401
|
"expectContentUntil": undefined,
|
|
@@ -375,11 +404,11 @@ describe("newContentSince", () => {
|
|
|
375
404
|
"new": {
|
|
376
405
|
"alice": {
|
|
377
406
|
"lastSignature": "signature",
|
|
378
|
-
"newTransactions": "
|
|
407
|
+
"newTransactions": "54 transactions after 146",
|
|
379
408
|
},
|
|
380
409
|
"bob": {
|
|
381
410
|
"lastSignature": "signature",
|
|
382
|
-
"newTransactions": "
|
|
411
|
+
"newTransactions": "54 transactions after 146",
|
|
383
412
|
},
|
|
384
413
|
},
|
|
385
414
|
"priority": 3,
|
|
@@ -396,16 +425,7 @@ describe("newContentSince", () => {
|
|
|
396
425
|
const group = client.node.createGroup();
|
|
397
426
|
const map = group.createMap();
|
|
398
427
|
|
|
399
|
-
|
|
400
|
-
const dataSize = 1 * 1024 * 100;
|
|
401
|
-
const chunkSize = 1024; // 1KB chunks
|
|
402
|
-
const chunks = dataSize / chunkSize;
|
|
403
|
-
const value = Buffer.alloc(chunkSize, `value$`).toString("base64");
|
|
404
|
-
|
|
405
|
-
for (let i = 0; i < chunks; i++) {
|
|
406
|
-
const key = `key1_${i}`;
|
|
407
|
-
map.set(key, value, "trusting");
|
|
408
|
-
}
|
|
428
|
+
fillCoMapWithLargeData(map);
|
|
409
429
|
|
|
410
430
|
// Add small session
|
|
411
431
|
const session2 = client.spawnNewSession();
|
|
@@ -416,10 +436,7 @@ describe("newContentSince", () => {
|
|
|
416
436
|
const session3 = client.spawnNewSession();
|
|
417
437
|
const mapInSession3 = await loadCoValueOrFail(session3.node, map.id);
|
|
418
438
|
|
|
419
|
-
|
|
420
|
-
const key = `key3_${i}`;
|
|
421
|
-
mapInSession3.set(key, value, "trusting");
|
|
422
|
-
}
|
|
439
|
+
fillCoMapWithLargeData(mapInSession3);
|
|
423
440
|
|
|
424
441
|
const content = mapInSession3.core.newContentSince(undefined);
|
|
425
442
|
|
|
@@ -436,9 +453,9 @@ describe("newContentSince", () => {
|
|
|
436
453
|
{
|
|
437
454
|
"action": "content",
|
|
438
455
|
"expectContentUntil": {
|
|
439
|
-
"alice":
|
|
456
|
+
"alice": 200,
|
|
440
457
|
"bob": 1,
|
|
441
|
-
"charlie":
|
|
458
|
+
"charlie": 200,
|
|
442
459
|
},
|
|
443
460
|
"header": "header",
|
|
444
461
|
"id": "id",
|
|
@@ -450,6 +467,19 @@ describe("newContentSince", () => {
|
|
|
450
467
|
},
|
|
451
468
|
"priority": 3,
|
|
452
469
|
},
|
|
470
|
+
{
|
|
471
|
+
"action": "content",
|
|
472
|
+
"expectContentUntil": undefined,
|
|
473
|
+
"header": undefined,
|
|
474
|
+
"id": "id",
|
|
475
|
+
"new": {
|
|
476
|
+
"alice": {
|
|
477
|
+
"lastSignature": "signature",
|
|
478
|
+
"newTransactions": "73 transactions after 73",
|
|
479
|
+
},
|
|
480
|
+
},
|
|
481
|
+
"priority": 3,
|
|
482
|
+
},
|
|
453
483
|
{
|
|
454
484
|
"action": "content",
|
|
455
485
|
"expectContentUntil": undefined,
|
|
@@ -463,6 +493,19 @@ describe("newContentSince", () => {
|
|
|
463
493
|
},
|
|
464
494
|
"priority": 3,
|
|
465
495
|
},
|
|
496
|
+
{
|
|
497
|
+
"action": "content",
|
|
498
|
+
"expectContentUntil": undefined,
|
|
499
|
+
"header": undefined,
|
|
500
|
+
"id": "id",
|
|
501
|
+
"new": {
|
|
502
|
+
"charlie": {
|
|
503
|
+
"lastSignature": "signature",
|
|
504
|
+
"newTransactions": "73 transactions after 73",
|
|
505
|
+
},
|
|
506
|
+
},
|
|
507
|
+
"priority": 3,
|
|
508
|
+
},
|
|
466
509
|
{
|
|
467
510
|
"action": "content",
|
|
468
511
|
"expectContentUntil": undefined,
|
|
@@ -471,7 +514,7 @@ describe("newContentSince", () => {
|
|
|
471
514
|
"new": {
|
|
472
515
|
"alice": {
|
|
473
516
|
"lastSignature": "signature",
|
|
474
|
-
"newTransactions": "
|
|
517
|
+
"newTransactions": "54 transactions after 146",
|
|
475
518
|
},
|
|
476
519
|
"bob": {
|
|
477
520
|
"lastSignature": "signature",
|
|
@@ -479,7 +522,7 @@ describe("newContentSince", () => {
|
|
|
479
522
|
},
|
|
480
523
|
"charlie": {
|
|
481
524
|
"lastSignature": "signature",
|
|
482
|
-
"newTransactions": "
|
|
525
|
+
"newTransactions": "54 transactions after 146",
|
|
483
526
|
},
|
|
484
527
|
},
|
|
485
528
|
"priority": 3,
|
|
@@ -499,15 +542,7 @@ describe("newContentSince", () => {
|
|
|
499
542
|
client.disconnect();
|
|
500
543
|
|
|
501
544
|
// Generate first large session (about 1MB)
|
|
502
|
-
|
|
503
|
-
const chunkSize = 1024; // 1KB chunks
|
|
504
|
-
const chunks = dataSize / chunkSize;
|
|
505
|
-
const value = Buffer.alloc(chunkSize, `value$`).toString("base64");
|
|
506
|
-
|
|
507
|
-
for (let i = 0; i < chunks; i++) {
|
|
508
|
-
const key = `key1_${i}`;
|
|
509
|
-
map.set(key, value, "trusting");
|
|
510
|
-
}
|
|
545
|
+
fillCoMapWithLargeData(map);
|
|
511
546
|
|
|
512
547
|
const largeContent = map.core.newContentSince(undefined);
|
|
513
548
|
assert(largeContent);
|
|
@@ -543,10 +578,7 @@ describe("newContentSince", () => {
|
|
|
543
578
|
const session3 = client.spawnNewSession();
|
|
544
579
|
const mapInSession3 = await loadCoValueOrFail(session3.node, map.id);
|
|
545
580
|
|
|
546
|
-
|
|
547
|
-
const key = `key3_${i}`;
|
|
548
|
-
mapInSession3.set(key, value, "trusting");
|
|
549
|
-
}
|
|
581
|
+
fillCoMapWithLargeData(mapInSession3);
|
|
550
582
|
|
|
551
583
|
const content = mapInSession3.core.newContentSince(undefined);
|
|
552
584
|
|
|
@@ -563,16 +595,16 @@ describe("newContentSince", () => {
|
|
|
563
595
|
{
|
|
564
596
|
"action": "content",
|
|
565
597
|
"expectContentUntil": {
|
|
566
|
-
"alice":
|
|
598
|
+
"alice": 200,
|
|
567
599
|
"bob": 1,
|
|
568
|
-
"charlie":
|
|
600
|
+
"charlie": 200,
|
|
569
601
|
},
|
|
570
602
|
"header": "header",
|
|
571
603
|
"id": "id",
|
|
572
604
|
"new": {
|
|
573
605
|
"alice": {
|
|
574
606
|
"lastSignature": "signature",
|
|
575
|
-
"newTransactions": "
|
|
607
|
+
"newTransactions": "200 transactions after 0",
|
|
576
608
|
},
|
|
577
609
|
},
|
|
578
610
|
"priority": 3,
|
|
@@ -590,6 +622,19 @@ describe("newContentSince", () => {
|
|
|
590
622
|
},
|
|
591
623
|
"priority": 3,
|
|
592
624
|
},
|
|
625
|
+
{
|
|
626
|
+
"action": "content",
|
|
627
|
+
"expectContentUntil": undefined,
|
|
628
|
+
"header": undefined,
|
|
629
|
+
"id": "id",
|
|
630
|
+
"new": {
|
|
631
|
+
"charlie": {
|
|
632
|
+
"lastSignature": "signature",
|
|
633
|
+
"newTransactions": "73 transactions after 73",
|
|
634
|
+
},
|
|
635
|
+
},
|
|
636
|
+
"priority": 3,
|
|
637
|
+
},
|
|
593
638
|
{
|
|
594
639
|
"action": "content",
|
|
595
640
|
"expectContentUntil": undefined,
|
|
@@ -602,7 +647,7 @@ describe("newContentSince", () => {
|
|
|
602
647
|
},
|
|
603
648
|
"charlie": {
|
|
604
649
|
"lastSignature": "signature",
|
|
605
|
-
"newTransactions": "
|
|
650
|
+
"newTransactions": "54 transactions after 146",
|
|
606
651
|
},
|
|
607
652
|
},
|
|
608
653
|
"priority": 3,
|
|
@@ -620,24 +665,13 @@ describe("newContentSince", () => {
|
|
|
620
665
|
const map = group.createMap();
|
|
621
666
|
|
|
622
667
|
// Generate a large amount of data (about 1MB)
|
|
623
|
-
|
|
624
|
-
const chunkSize = 1024; // 1KB chunks
|
|
625
|
-
const chunks = dataSize / chunkSize;
|
|
626
|
-
const value = Buffer.alloc(chunkSize, `value$`).toString("base64");
|
|
627
|
-
|
|
628
|
-
for (let i = 0; i < chunks; i++) {
|
|
629
|
-
const key = `key${i}`;
|
|
630
|
-
map.set(key, value, "trusting");
|
|
631
|
-
}
|
|
668
|
+
fillCoMapWithLargeData(map);
|
|
632
669
|
|
|
633
670
|
// Capture knownState partway through
|
|
634
671
|
const knownState = map.core.knownState();
|
|
635
672
|
|
|
636
673
|
// Add more data
|
|
637
|
-
|
|
638
|
-
const key = `key_new_${i}`;
|
|
639
|
-
map.set(key, value, "trusting");
|
|
640
|
-
}
|
|
674
|
+
fillCoMapWithLargeData(map);
|
|
641
675
|
|
|
642
676
|
const content = map.core.newContentSince(knownState);
|
|
643
677
|
|
|
@@ -652,14 +686,14 @@ describe("newContentSince", () => {
|
|
|
652
686
|
{
|
|
653
687
|
"action": "content",
|
|
654
688
|
"expectContentUntil": {
|
|
655
|
-
"alice":
|
|
689
|
+
"alice": 400,
|
|
656
690
|
},
|
|
657
691
|
"header": undefined,
|
|
658
692
|
"id": "id",
|
|
659
693
|
"new": {
|
|
660
694
|
"alice": {
|
|
661
695
|
"lastSignature": "signature",
|
|
662
|
-
"newTransactions": "
|
|
696
|
+
"newTransactions": "19 transactions after 200",
|
|
663
697
|
},
|
|
664
698
|
},
|
|
665
699
|
"priority": 3,
|
|
@@ -672,7 +706,33 @@ describe("newContentSince", () => {
|
|
|
672
706
|
"new": {
|
|
673
707
|
"alice": {
|
|
674
708
|
"lastSignature": "signature",
|
|
675
|
-
"newTransactions": "
|
|
709
|
+
"newTransactions": "73 transactions after 219",
|
|
710
|
+
},
|
|
711
|
+
},
|
|
712
|
+
"priority": 3,
|
|
713
|
+
},
|
|
714
|
+
{
|
|
715
|
+
"action": "content",
|
|
716
|
+
"expectContentUntil": undefined,
|
|
717
|
+
"header": undefined,
|
|
718
|
+
"id": "id",
|
|
719
|
+
"new": {
|
|
720
|
+
"alice": {
|
|
721
|
+
"lastSignature": "signature",
|
|
722
|
+
"newTransactions": "73 transactions after 292",
|
|
723
|
+
},
|
|
724
|
+
},
|
|
725
|
+
"priority": 3,
|
|
726
|
+
},
|
|
727
|
+
{
|
|
728
|
+
"action": "content",
|
|
729
|
+
"expectContentUntil": undefined,
|
|
730
|
+
"header": undefined,
|
|
731
|
+
"id": "id",
|
|
732
|
+
"new": {
|
|
733
|
+
"alice": {
|
|
734
|
+
"lastSignature": "signature",
|
|
735
|
+
"newTransactions": "35 transactions after 365",
|
|
676
736
|
},
|
|
677
737
|
},
|
|
678
738
|
"priority": 3,
|
|
@@ -690,24 +750,13 @@ describe("newContentSince", () => {
|
|
|
690
750
|
const map = group.createMap();
|
|
691
751
|
|
|
692
752
|
// Generate a large amount of data (about 1MB)
|
|
693
|
-
|
|
694
|
-
const chunkSize = 1024; // 1KB chunks
|
|
695
|
-
const chunks = dataSize / chunkSize;
|
|
696
|
-
const value = Buffer.alloc(chunkSize, `value$`).toString("base64");
|
|
697
|
-
|
|
698
|
-
for (let i = 0; i < chunks; i++) {
|
|
699
|
-
const key = `key${i}`;
|
|
700
|
-
map.set(key, value, "trusting");
|
|
701
|
-
}
|
|
753
|
+
fillCoMapWithLargeData(map);
|
|
702
754
|
|
|
703
755
|
// Capture knownState
|
|
704
756
|
const knownState = map.core.knownState();
|
|
705
757
|
|
|
706
758
|
// Add more data to first session
|
|
707
|
-
|
|
708
|
-
const key = `key_new_${i}`;
|
|
709
|
-
map.set(key, value, "trusting");
|
|
710
|
-
}
|
|
759
|
+
fillCoMapWithLargeData(map);
|
|
711
760
|
|
|
712
761
|
// Add a small session
|
|
713
762
|
const newSession = client.spawnNewSession();
|
|
@@ -728,7 +777,7 @@ describe("newContentSince", () => {
|
|
|
728
777
|
{
|
|
729
778
|
"action": "content",
|
|
730
779
|
"expectContentUntil": {
|
|
731
|
-
"alice":
|
|
780
|
+
"alice": 400,
|
|
732
781
|
"bob": 1,
|
|
733
782
|
},
|
|
734
783
|
"header": undefined,
|
|
@@ -736,7 +785,7 @@ describe("newContentSince", () => {
|
|
|
736
785
|
"new": {
|
|
737
786
|
"alice": {
|
|
738
787
|
"lastSignature": "signature",
|
|
739
|
-
"newTransactions": "
|
|
788
|
+
"newTransactions": "19 transactions after 200",
|
|
740
789
|
},
|
|
741
790
|
},
|
|
742
791
|
"priority": 3,
|
|
@@ -749,7 +798,33 @@ describe("newContentSince", () => {
|
|
|
749
798
|
"new": {
|
|
750
799
|
"alice": {
|
|
751
800
|
"lastSignature": "signature",
|
|
752
|
-
"newTransactions": "
|
|
801
|
+
"newTransactions": "73 transactions after 219",
|
|
802
|
+
},
|
|
803
|
+
},
|
|
804
|
+
"priority": 3,
|
|
805
|
+
},
|
|
806
|
+
{
|
|
807
|
+
"action": "content",
|
|
808
|
+
"expectContentUntil": undefined,
|
|
809
|
+
"header": undefined,
|
|
810
|
+
"id": "id",
|
|
811
|
+
"new": {
|
|
812
|
+
"alice": {
|
|
813
|
+
"lastSignature": "signature",
|
|
814
|
+
"newTransactions": "73 transactions after 292",
|
|
815
|
+
},
|
|
816
|
+
},
|
|
817
|
+
"priority": 3,
|
|
818
|
+
},
|
|
819
|
+
{
|
|
820
|
+
"action": "content",
|
|
821
|
+
"expectContentUntil": undefined,
|
|
822
|
+
"header": undefined,
|
|
823
|
+
"id": "id",
|
|
824
|
+
"new": {
|
|
825
|
+
"alice": {
|
|
826
|
+
"lastSignature": "signature",
|
|
827
|
+
"newTransactions": "35 transactions after 365",
|
|
753
828
|
},
|
|
754
829
|
"bob": {
|
|
755
830
|
"lastSignature": "signature",
|
|
@@ -777,24 +852,13 @@ describe("newContentSince", () => {
|
|
|
777
852
|
const knownState = map.core.knownState();
|
|
778
853
|
|
|
779
854
|
// Generate a large amount of data in first session (about 1MB)
|
|
780
|
-
|
|
781
|
-
const chunkSize = 1024; // 1KB chunks
|
|
782
|
-
const chunks = dataSize / chunkSize;
|
|
783
|
-
const value = Buffer.alloc(chunkSize, `value$`).toString("base64");
|
|
784
|
-
|
|
785
|
-
for (let i = 0; i < chunks; i++) {
|
|
786
|
-
const key = `key1_${i}`;
|
|
787
|
-
map.set(key, value, "trusting");
|
|
788
|
-
}
|
|
855
|
+
fillCoMapWithLargeData(map);
|
|
789
856
|
|
|
790
857
|
// Add second large session
|
|
791
858
|
const newSession = client.spawnNewSession();
|
|
792
859
|
const mapInNewSession = await loadCoValueOrFail(newSession.node, map.id);
|
|
793
860
|
|
|
794
|
-
|
|
795
|
-
const key = `key2_${i}`;
|
|
796
|
-
mapInNewSession.set(key, value, "trusting");
|
|
797
|
-
}
|
|
861
|
+
fillCoMapWithLargeData(mapInNewSession);
|
|
798
862
|
|
|
799
863
|
const content = mapInNewSession.core.newContentSince(knownState);
|
|
800
864
|
|
|
@@ -810,8 +874,8 @@ describe("newContentSince", () => {
|
|
|
810
874
|
{
|
|
811
875
|
"action": "content",
|
|
812
876
|
"expectContentUntil": {
|
|
813
|
-
"alice":
|
|
814
|
-
"bob":
|
|
877
|
+
"alice": 201,
|
|
878
|
+
"bob": 200,
|
|
815
879
|
},
|
|
816
880
|
"header": undefined,
|
|
817
881
|
"id": "id",
|
|
@@ -823,6 +887,19 @@ describe("newContentSince", () => {
|
|
|
823
887
|
},
|
|
824
888
|
"priority": 3,
|
|
825
889
|
},
|
|
890
|
+
{
|
|
891
|
+
"action": "content",
|
|
892
|
+
"expectContentUntil": undefined,
|
|
893
|
+
"header": undefined,
|
|
894
|
+
"id": "id",
|
|
895
|
+
"new": {
|
|
896
|
+
"alice": {
|
|
897
|
+
"lastSignature": "signature",
|
|
898
|
+
"newTransactions": "73 transactions after 74",
|
|
899
|
+
},
|
|
900
|
+
},
|
|
901
|
+
"priority": 3,
|
|
902
|
+
},
|
|
826
903
|
{
|
|
827
904
|
"action": "content",
|
|
828
905
|
"expectContentUntil": undefined,
|
|
@@ -836,6 +913,19 @@ describe("newContentSince", () => {
|
|
|
836
913
|
},
|
|
837
914
|
"priority": 3,
|
|
838
915
|
},
|
|
916
|
+
{
|
|
917
|
+
"action": "content",
|
|
918
|
+
"expectContentUntil": undefined,
|
|
919
|
+
"header": undefined,
|
|
920
|
+
"id": "id",
|
|
921
|
+
"new": {
|
|
922
|
+
"bob": {
|
|
923
|
+
"lastSignature": "signature",
|
|
924
|
+
"newTransactions": "73 transactions after 73",
|
|
925
|
+
},
|
|
926
|
+
},
|
|
927
|
+
"priority": 3,
|
|
928
|
+
},
|
|
839
929
|
{
|
|
840
930
|
"action": "content",
|
|
841
931
|
"expectContentUntil": undefined,
|
|
@@ -844,11 +934,11 @@ describe("newContentSince", () => {
|
|
|
844
934
|
"new": {
|
|
845
935
|
"alice": {
|
|
846
936
|
"lastSignature": "signature",
|
|
847
|
-
"newTransactions": "
|
|
937
|
+
"newTransactions": "54 transactions after 147",
|
|
848
938
|
},
|
|
849
939
|
"bob": {
|
|
850
940
|
"lastSignature": "signature",
|
|
851
|
-
"newTransactions": "
|
|
941
|
+
"newTransactions": "54 transactions after 146",
|
|
852
942
|
},
|
|
853
943
|
},
|
|
854
944
|
"priority": 3,
|
|
@@ -872,15 +962,7 @@ describe("newContentSince", () => {
|
|
|
872
962
|
const knownState = map.core.knownState();
|
|
873
963
|
|
|
874
964
|
// Generate first large session (about 1MB)
|
|
875
|
-
|
|
876
|
-
const chunkSize = 1024; // 1KB chunks
|
|
877
|
-
const chunks = dataSize / chunkSize;
|
|
878
|
-
const value = Buffer.alloc(chunkSize, `value$`).toString("base64");
|
|
879
|
-
|
|
880
|
-
for (let i = 0; i < chunks; i++) {
|
|
881
|
-
const key = `key1_${i}`;
|
|
882
|
-
map.set(key, value, "trusting");
|
|
883
|
-
}
|
|
965
|
+
fillCoMapWithLargeData(map);
|
|
884
966
|
|
|
885
967
|
// Add small session
|
|
886
968
|
const session2 = client.spawnNewSession();
|
|
@@ -891,10 +973,7 @@ describe("newContentSince", () => {
|
|
|
891
973
|
const session3 = client.spawnNewSession();
|
|
892
974
|
const mapInSession3 = await loadCoValueOrFail(session3.node, map.id);
|
|
893
975
|
|
|
894
|
-
|
|
895
|
-
const key = `key3_${i}`;
|
|
896
|
-
mapInSession3.set(key, value, "trusting");
|
|
897
|
-
}
|
|
976
|
+
fillCoMapWithLargeData(mapInSession3);
|
|
898
977
|
|
|
899
978
|
const content = mapInSession3.core.newContentSince(knownState);
|
|
900
979
|
|
|
@@ -911,9 +990,9 @@ describe("newContentSince", () => {
|
|
|
911
990
|
{
|
|
912
991
|
"action": "content",
|
|
913
992
|
"expectContentUntil": {
|
|
914
|
-
"alice":
|
|
993
|
+
"alice": 201,
|
|
915
994
|
"bob": 1,
|
|
916
|
-
"charlie":
|
|
995
|
+
"charlie": 200,
|
|
917
996
|
},
|
|
918
997
|
"header": undefined,
|
|
919
998
|
"id": "id",
|
|
@@ -925,6 +1004,19 @@ describe("newContentSince", () => {
|
|
|
925
1004
|
},
|
|
926
1005
|
"priority": 3,
|
|
927
1006
|
},
|
|
1007
|
+
{
|
|
1008
|
+
"action": "content",
|
|
1009
|
+
"expectContentUntil": undefined,
|
|
1010
|
+
"header": undefined,
|
|
1011
|
+
"id": "id",
|
|
1012
|
+
"new": {
|
|
1013
|
+
"alice": {
|
|
1014
|
+
"lastSignature": "signature",
|
|
1015
|
+
"newTransactions": "73 transactions after 74",
|
|
1016
|
+
},
|
|
1017
|
+
},
|
|
1018
|
+
"priority": 3,
|
|
1019
|
+
},
|
|
928
1020
|
{
|
|
929
1021
|
"action": "content",
|
|
930
1022
|
"expectContentUntil": undefined,
|
|
@@ -938,6 +1030,19 @@ describe("newContentSince", () => {
|
|
|
938
1030
|
},
|
|
939
1031
|
"priority": 3,
|
|
940
1032
|
},
|
|
1033
|
+
{
|
|
1034
|
+
"action": "content",
|
|
1035
|
+
"expectContentUntil": undefined,
|
|
1036
|
+
"header": undefined,
|
|
1037
|
+
"id": "id",
|
|
1038
|
+
"new": {
|
|
1039
|
+
"charlie": {
|
|
1040
|
+
"lastSignature": "signature",
|
|
1041
|
+
"newTransactions": "73 transactions after 73",
|
|
1042
|
+
},
|
|
1043
|
+
},
|
|
1044
|
+
"priority": 3,
|
|
1045
|
+
},
|
|
941
1046
|
{
|
|
942
1047
|
"action": "content",
|
|
943
1048
|
"expectContentUntil": undefined,
|
|
@@ -946,7 +1051,7 @@ describe("newContentSince", () => {
|
|
|
946
1051
|
"new": {
|
|
947
1052
|
"alice": {
|
|
948
1053
|
"lastSignature": "signature",
|
|
949
|
-
"newTransactions": "
|
|
1054
|
+
"newTransactions": "54 transactions after 147",
|
|
950
1055
|
},
|
|
951
1056
|
"bob": {
|
|
952
1057
|
"lastSignature": "signature",
|
|
@@ -954,7 +1059,7 @@ describe("newContentSince", () => {
|
|
|
954
1059
|
},
|
|
955
1060
|
"charlie": {
|
|
956
1061
|
"lastSignature": "signature",
|
|
957
|
-
"newTransactions": "
|
|
1062
|
+
"newTransactions": "54 transactions after 146",
|
|
958
1063
|
},
|
|
959
1064
|
},
|
|
960
1065
|
"priority": 3,
|