cojson 0.18.37 → 0.19.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.
- package/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +16 -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/exports.d.ts +3 -3
- 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 +34 -58
- 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/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/exports.ts +3 -2
- package/src/permissions.ts +34 -66
- 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/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,5 @@
|
|
|
1
1
|
import { assert, beforeEach, describe, expect, test } from "vitest";
|
|
2
|
-
import { loadCoValueOrFail, setupTestNode } from "./testUtils.js";
|
|
2
|
+
import { fillCoMapWithLargeData, loadCoValueOrFail, setupTestNode, } from "./testUtils.js";
|
|
3
3
|
import { CO_VALUE_PRIORITY } from "../priority.js";
|
|
4
4
|
import { emptyKnownState } from "../exports.js";
|
|
5
5
|
import { addTransactionToContentMessage } from "../coValueContentMessage.js";
|
|
@@ -130,14 +130,7 @@ describe("newContentSince", () => {
|
|
|
130
130
|
const client = setupTestNode();
|
|
131
131
|
const group = client.node.createGroup();
|
|
132
132
|
const map = group.createMap();
|
|
133
|
-
|
|
134
|
-
const chunkSize = 1024; // 1KB chunks
|
|
135
|
-
const chunks = dataSize / chunkSize;
|
|
136
|
-
const value = Buffer.alloc(chunkSize, `value$`).toString("base64");
|
|
137
|
-
for (let i = 0; i < chunks; i++) {
|
|
138
|
-
const key = `key${i}`;
|
|
139
|
-
map.set(key, value, "trusting");
|
|
140
|
-
}
|
|
133
|
+
fillCoMapWithLargeData(map);
|
|
141
134
|
const content = map.core.newContentSince(undefined);
|
|
142
135
|
const sessionMapping = {
|
|
143
136
|
[client.node.currentSessionID]: "alice",
|
|
@@ -147,7 +140,7 @@ describe("newContentSince", () => {
|
|
|
147
140
|
{
|
|
148
141
|
"action": "content",
|
|
149
142
|
"expectContentUntil": {
|
|
150
|
-
"alice":
|
|
143
|
+
"alice": 200,
|
|
151
144
|
},
|
|
152
145
|
"header": "header",
|
|
153
146
|
"id": "id",
|
|
@@ -167,7 +160,20 @@ describe("newContentSince", () => {
|
|
|
167
160
|
"new": {
|
|
168
161
|
"alice": {
|
|
169
162
|
"lastSignature": "signature",
|
|
170
|
-
"newTransactions": "
|
|
163
|
+
"newTransactions": "73 transactions after 73",
|
|
164
|
+
},
|
|
165
|
+
},
|
|
166
|
+
"priority": 3,
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
"action": "content",
|
|
170
|
+
"expectContentUntil": undefined,
|
|
171
|
+
"header": undefined,
|
|
172
|
+
"id": "id",
|
|
173
|
+
"new": {
|
|
174
|
+
"alice": {
|
|
175
|
+
"lastSignature": "signature",
|
|
176
|
+
"newTransactions": "54 transactions after 146",
|
|
171
177
|
},
|
|
172
178
|
},
|
|
173
179
|
"priority": 3,
|
|
@@ -182,14 +188,7 @@ describe("newContentSince", () => {
|
|
|
182
188
|
const group = client.node.createGroup();
|
|
183
189
|
const map = group.createMap();
|
|
184
190
|
// Generate a large amount of data (about 1MB)
|
|
185
|
-
|
|
186
|
-
const chunkSize = 1024; // 1KB chunks
|
|
187
|
-
const chunks = dataSize / chunkSize;
|
|
188
|
-
const value = Buffer.alloc(chunkSize, `value$`).toString("base64");
|
|
189
|
-
for (let i = 0; i < chunks; i++) {
|
|
190
|
-
const key = `key${i}`;
|
|
191
|
-
map.set(key, value, "trusting");
|
|
192
|
-
}
|
|
191
|
+
fillCoMapWithLargeData(map);
|
|
193
192
|
// Add a small session
|
|
194
193
|
const newSession = client.spawnNewSession();
|
|
195
194
|
const mapInNewSession = await loadCoValueOrFail(newSession.node, map.id);
|
|
@@ -204,7 +203,7 @@ describe("newContentSince", () => {
|
|
|
204
203
|
{
|
|
205
204
|
"action": "content",
|
|
206
205
|
"expectContentUntil": {
|
|
207
|
-
"alice":
|
|
206
|
+
"alice": 200,
|
|
208
207
|
"bob": 1,
|
|
209
208
|
},
|
|
210
209
|
"header": "header",
|
|
@@ -225,7 +224,20 @@ describe("newContentSince", () => {
|
|
|
225
224
|
"new": {
|
|
226
225
|
"alice": {
|
|
227
226
|
"lastSignature": "signature",
|
|
228
|
-
"newTransactions": "
|
|
227
|
+
"newTransactions": "73 transactions after 73",
|
|
228
|
+
},
|
|
229
|
+
},
|
|
230
|
+
"priority": 3,
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
"action": "content",
|
|
234
|
+
"expectContentUntil": undefined,
|
|
235
|
+
"header": undefined,
|
|
236
|
+
"id": "id",
|
|
237
|
+
"new": {
|
|
238
|
+
"alice": {
|
|
239
|
+
"lastSignature": "signature",
|
|
240
|
+
"newTransactions": "54 transactions after 146",
|
|
229
241
|
},
|
|
230
242
|
"bob": {
|
|
231
243
|
"lastSignature": "signature",
|
|
@@ -244,21 +256,11 @@ describe("newContentSince", () => {
|
|
|
244
256
|
const group = client.node.createGroup();
|
|
245
257
|
const map = group.createMap();
|
|
246
258
|
// Generate a large amount of data in first session (about 1MB)
|
|
247
|
-
|
|
248
|
-
const chunkSize = 1024; // 1KB chunks
|
|
249
|
-
const chunks = dataSize / chunkSize;
|
|
250
|
-
const value = Buffer.alloc(chunkSize, `value$`).toString("base64");
|
|
251
|
-
for (let i = 0; i < chunks; i++) {
|
|
252
|
-
const key = `key1_${i}`;
|
|
253
|
-
map.set(key, value, "trusting");
|
|
254
|
-
}
|
|
259
|
+
fillCoMapWithLargeData(map);
|
|
255
260
|
// Add second large session
|
|
256
261
|
const newSession = client.spawnNewSession();
|
|
257
262
|
const mapInNewSession = await loadCoValueOrFail(newSession.node, map.id);
|
|
258
|
-
|
|
259
|
-
const key = `key2_${i}`;
|
|
260
|
-
mapInNewSession.set(key, value, "trusting");
|
|
261
|
-
}
|
|
263
|
+
fillCoMapWithLargeData(mapInNewSession);
|
|
262
264
|
const content = mapInNewSession.core.newContentSince(undefined);
|
|
263
265
|
const sessionMapping = {
|
|
264
266
|
[client.node.currentSessionID]: "alice",
|
|
@@ -269,8 +271,8 @@ describe("newContentSince", () => {
|
|
|
269
271
|
{
|
|
270
272
|
"action": "content",
|
|
271
273
|
"expectContentUntil": {
|
|
272
|
-
"alice":
|
|
273
|
-
"bob":
|
|
274
|
+
"alice": 200,
|
|
275
|
+
"bob": 200,
|
|
274
276
|
},
|
|
275
277
|
"header": "header",
|
|
276
278
|
"id": "id",
|
|
@@ -282,6 +284,19 @@ describe("newContentSince", () => {
|
|
|
282
284
|
},
|
|
283
285
|
"priority": 3,
|
|
284
286
|
},
|
|
287
|
+
{
|
|
288
|
+
"action": "content",
|
|
289
|
+
"expectContentUntil": undefined,
|
|
290
|
+
"header": undefined,
|
|
291
|
+
"id": "id",
|
|
292
|
+
"new": {
|
|
293
|
+
"alice": {
|
|
294
|
+
"lastSignature": "signature",
|
|
295
|
+
"newTransactions": "73 transactions after 73",
|
|
296
|
+
},
|
|
297
|
+
},
|
|
298
|
+
"priority": 3,
|
|
299
|
+
},
|
|
285
300
|
{
|
|
286
301
|
"action": "content",
|
|
287
302
|
"expectContentUntil": undefined,
|
|
@@ -295,6 +310,19 @@ describe("newContentSince", () => {
|
|
|
295
310
|
},
|
|
296
311
|
"priority": 3,
|
|
297
312
|
},
|
|
313
|
+
{
|
|
314
|
+
"action": "content",
|
|
315
|
+
"expectContentUntil": undefined,
|
|
316
|
+
"header": undefined,
|
|
317
|
+
"id": "id",
|
|
318
|
+
"new": {
|
|
319
|
+
"bob": {
|
|
320
|
+
"lastSignature": "signature",
|
|
321
|
+
"newTransactions": "73 transactions after 73",
|
|
322
|
+
},
|
|
323
|
+
},
|
|
324
|
+
"priority": 3,
|
|
325
|
+
},
|
|
298
326
|
{
|
|
299
327
|
"action": "content",
|
|
300
328
|
"expectContentUntil": undefined,
|
|
@@ -303,11 +331,11 @@ describe("newContentSince", () => {
|
|
|
303
331
|
"new": {
|
|
304
332
|
"alice": {
|
|
305
333
|
"lastSignature": "signature",
|
|
306
|
-
"newTransactions": "
|
|
334
|
+
"newTransactions": "54 transactions after 146",
|
|
307
335
|
},
|
|
308
336
|
"bob": {
|
|
309
337
|
"lastSignature": "signature",
|
|
310
|
-
"newTransactions": "
|
|
338
|
+
"newTransactions": "54 transactions after 146",
|
|
311
339
|
},
|
|
312
340
|
},
|
|
313
341
|
"priority": 3,
|
|
@@ -321,15 +349,7 @@ describe("newContentSince", () => {
|
|
|
321
349
|
});
|
|
322
350
|
const group = client.node.createGroup();
|
|
323
351
|
const map = group.createMap();
|
|
324
|
-
|
|
325
|
-
const dataSize = 1 * 1024 * 100;
|
|
326
|
-
const chunkSize = 1024; // 1KB chunks
|
|
327
|
-
const chunks = dataSize / chunkSize;
|
|
328
|
-
const value = Buffer.alloc(chunkSize, `value$`).toString("base64");
|
|
329
|
-
for (let i = 0; i < chunks; i++) {
|
|
330
|
-
const key = `key1_${i}`;
|
|
331
|
-
map.set(key, value, "trusting");
|
|
332
|
-
}
|
|
352
|
+
fillCoMapWithLargeData(map);
|
|
333
353
|
// Add small session
|
|
334
354
|
const session2 = client.spawnNewSession();
|
|
335
355
|
const mapInSession2 = await loadCoValueOrFail(session2.node, map.id);
|
|
@@ -337,10 +357,7 @@ describe("newContentSince", () => {
|
|
|
337
357
|
// Add third large session
|
|
338
358
|
const session3 = client.spawnNewSession();
|
|
339
359
|
const mapInSession3 = await loadCoValueOrFail(session3.node, map.id);
|
|
340
|
-
|
|
341
|
-
const key = `key3_${i}`;
|
|
342
|
-
mapInSession3.set(key, value, "trusting");
|
|
343
|
-
}
|
|
360
|
+
fillCoMapWithLargeData(mapInSession3);
|
|
344
361
|
const content = mapInSession3.core.newContentSince(undefined);
|
|
345
362
|
const sessionMapping = {
|
|
346
363
|
[client.node.currentSessionID]: "alice",
|
|
@@ -352,9 +369,9 @@ describe("newContentSince", () => {
|
|
|
352
369
|
{
|
|
353
370
|
"action": "content",
|
|
354
371
|
"expectContentUntil": {
|
|
355
|
-
"alice":
|
|
372
|
+
"alice": 200,
|
|
356
373
|
"bob": 1,
|
|
357
|
-
"charlie":
|
|
374
|
+
"charlie": 200,
|
|
358
375
|
},
|
|
359
376
|
"header": "header",
|
|
360
377
|
"id": "id",
|
|
@@ -366,6 +383,19 @@ describe("newContentSince", () => {
|
|
|
366
383
|
},
|
|
367
384
|
"priority": 3,
|
|
368
385
|
},
|
|
386
|
+
{
|
|
387
|
+
"action": "content",
|
|
388
|
+
"expectContentUntil": undefined,
|
|
389
|
+
"header": undefined,
|
|
390
|
+
"id": "id",
|
|
391
|
+
"new": {
|
|
392
|
+
"alice": {
|
|
393
|
+
"lastSignature": "signature",
|
|
394
|
+
"newTransactions": "73 transactions after 73",
|
|
395
|
+
},
|
|
396
|
+
},
|
|
397
|
+
"priority": 3,
|
|
398
|
+
},
|
|
369
399
|
{
|
|
370
400
|
"action": "content",
|
|
371
401
|
"expectContentUntil": undefined,
|
|
@@ -379,6 +409,19 @@ describe("newContentSince", () => {
|
|
|
379
409
|
},
|
|
380
410
|
"priority": 3,
|
|
381
411
|
},
|
|
412
|
+
{
|
|
413
|
+
"action": "content",
|
|
414
|
+
"expectContentUntil": undefined,
|
|
415
|
+
"header": undefined,
|
|
416
|
+
"id": "id",
|
|
417
|
+
"new": {
|
|
418
|
+
"charlie": {
|
|
419
|
+
"lastSignature": "signature",
|
|
420
|
+
"newTransactions": "73 transactions after 73",
|
|
421
|
+
},
|
|
422
|
+
},
|
|
423
|
+
"priority": 3,
|
|
424
|
+
},
|
|
382
425
|
{
|
|
383
426
|
"action": "content",
|
|
384
427
|
"expectContentUntil": undefined,
|
|
@@ -387,7 +430,7 @@ describe("newContentSince", () => {
|
|
|
387
430
|
"new": {
|
|
388
431
|
"alice": {
|
|
389
432
|
"lastSignature": "signature",
|
|
390
|
-
"newTransactions": "
|
|
433
|
+
"newTransactions": "54 transactions after 146",
|
|
391
434
|
},
|
|
392
435
|
"bob": {
|
|
393
436
|
"lastSignature": "signature",
|
|
@@ -395,7 +438,7 @@ describe("newContentSince", () => {
|
|
|
395
438
|
},
|
|
396
439
|
"charlie": {
|
|
397
440
|
"lastSignature": "signature",
|
|
398
|
-
"newTransactions": "
|
|
441
|
+
"newTransactions": "54 transactions after 146",
|
|
399
442
|
},
|
|
400
443
|
},
|
|
401
444
|
"priority": 3,
|
|
@@ -412,14 +455,7 @@ describe("newContentSince", () => {
|
|
|
412
455
|
await map.core.waitForSync();
|
|
413
456
|
client.disconnect();
|
|
414
457
|
// Generate first large session (about 1MB)
|
|
415
|
-
|
|
416
|
-
const chunkSize = 1024; // 1KB chunks
|
|
417
|
-
const chunks = dataSize / chunkSize;
|
|
418
|
-
const value = Buffer.alloc(chunkSize, `value$`).toString("base64");
|
|
419
|
-
for (let i = 0; i < chunks; i++) {
|
|
420
|
-
const key = `key1_${i}`;
|
|
421
|
-
map.set(key, value, "trusting");
|
|
422
|
-
}
|
|
458
|
+
fillCoMapWithLargeData(map);
|
|
423
459
|
const largeContent = map.core.newContentSince(undefined);
|
|
424
460
|
assert(largeContent);
|
|
425
461
|
const singleLargeContentPiece = largeContent[0];
|
|
@@ -439,10 +475,7 @@ describe("newContentSince", () => {
|
|
|
439
475
|
// Add third large session
|
|
440
476
|
const session3 = client.spawnNewSession();
|
|
441
477
|
const mapInSession3 = await loadCoValueOrFail(session3.node, map.id);
|
|
442
|
-
|
|
443
|
-
const key = `key3_${i}`;
|
|
444
|
-
mapInSession3.set(key, value, "trusting");
|
|
445
|
-
}
|
|
478
|
+
fillCoMapWithLargeData(mapInSession3);
|
|
446
479
|
const content = mapInSession3.core.newContentSince(undefined);
|
|
447
480
|
const sessionMapping = {
|
|
448
481
|
[client.node.currentSessionID]: "alice",
|
|
@@ -454,16 +487,16 @@ describe("newContentSince", () => {
|
|
|
454
487
|
{
|
|
455
488
|
"action": "content",
|
|
456
489
|
"expectContentUntil": {
|
|
457
|
-
"alice":
|
|
490
|
+
"alice": 200,
|
|
458
491
|
"bob": 1,
|
|
459
|
-
"charlie":
|
|
492
|
+
"charlie": 200,
|
|
460
493
|
},
|
|
461
494
|
"header": "header",
|
|
462
495
|
"id": "id",
|
|
463
496
|
"new": {
|
|
464
497
|
"alice": {
|
|
465
498
|
"lastSignature": "signature",
|
|
466
|
-
"newTransactions": "
|
|
499
|
+
"newTransactions": "200 transactions after 0",
|
|
467
500
|
},
|
|
468
501
|
},
|
|
469
502
|
"priority": 3,
|
|
@@ -481,6 +514,19 @@ describe("newContentSince", () => {
|
|
|
481
514
|
},
|
|
482
515
|
"priority": 3,
|
|
483
516
|
},
|
|
517
|
+
{
|
|
518
|
+
"action": "content",
|
|
519
|
+
"expectContentUntil": undefined,
|
|
520
|
+
"header": undefined,
|
|
521
|
+
"id": "id",
|
|
522
|
+
"new": {
|
|
523
|
+
"charlie": {
|
|
524
|
+
"lastSignature": "signature",
|
|
525
|
+
"newTransactions": "73 transactions after 73",
|
|
526
|
+
},
|
|
527
|
+
},
|
|
528
|
+
"priority": 3,
|
|
529
|
+
},
|
|
484
530
|
{
|
|
485
531
|
"action": "content",
|
|
486
532
|
"expectContentUntil": undefined,
|
|
@@ -493,7 +539,7 @@ describe("newContentSince", () => {
|
|
|
493
539
|
},
|
|
494
540
|
"charlie": {
|
|
495
541
|
"lastSignature": "signature",
|
|
496
|
-
"newTransactions": "
|
|
542
|
+
"newTransactions": "54 transactions after 146",
|
|
497
543
|
},
|
|
498
544
|
},
|
|
499
545
|
"priority": 3,
|
|
@@ -508,21 +554,11 @@ describe("newContentSince", () => {
|
|
|
508
554
|
const group = client.node.createGroup();
|
|
509
555
|
const map = group.createMap();
|
|
510
556
|
// Generate a large amount of data (about 1MB)
|
|
511
|
-
|
|
512
|
-
const chunkSize = 1024; // 1KB chunks
|
|
513
|
-
const chunks = dataSize / chunkSize;
|
|
514
|
-
const value = Buffer.alloc(chunkSize, `value$`).toString("base64");
|
|
515
|
-
for (let i = 0; i < chunks; i++) {
|
|
516
|
-
const key = `key${i}`;
|
|
517
|
-
map.set(key, value, "trusting");
|
|
518
|
-
}
|
|
557
|
+
fillCoMapWithLargeData(map);
|
|
519
558
|
// Capture knownState partway through
|
|
520
559
|
const knownState = map.core.knownState();
|
|
521
560
|
// Add more data
|
|
522
|
-
|
|
523
|
-
const key = `key_new_${i}`;
|
|
524
|
-
map.set(key, value, "trusting");
|
|
525
|
-
}
|
|
561
|
+
fillCoMapWithLargeData(map);
|
|
526
562
|
const content = map.core.newContentSince(knownState);
|
|
527
563
|
const sessionMapping = {
|
|
528
564
|
[client.node.currentSessionID]: "alice",
|
|
@@ -532,14 +568,14 @@ describe("newContentSince", () => {
|
|
|
532
568
|
{
|
|
533
569
|
"action": "content",
|
|
534
570
|
"expectContentUntil": {
|
|
535
|
-
"alice":
|
|
571
|
+
"alice": 400,
|
|
536
572
|
},
|
|
537
573
|
"header": undefined,
|
|
538
574
|
"id": "id",
|
|
539
575
|
"new": {
|
|
540
576
|
"alice": {
|
|
541
577
|
"lastSignature": "signature",
|
|
542
|
-
"newTransactions": "
|
|
578
|
+
"newTransactions": "19 transactions after 200",
|
|
543
579
|
},
|
|
544
580
|
},
|
|
545
581
|
"priority": 3,
|
|
@@ -552,7 +588,33 @@ describe("newContentSince", () => {
|
|
|
552
588
|
"new": {
|
|
553
589
|
"alice": {
|
|
554
590
|
"lastSignature": "signature",
|
|
555
|
-
"newTransactions": "
|
|
591
|
+
"newTransactions": "73 transactions after 219",
|
|
592
|
+
},
|
|
593
|
+
},
|
|
594
|
+
"priority": 3,
|
|
595
|
+
},
|
|
596
|
+
{
|
|
597
|
+
"action": "content",
|
|
598
|
+
"expectContentUntil": undefined,
|
|
599
|
+
"header": undefined,
|
|
600
|
+
"id": "id",
|
|
601
|
+
"new": {
|
|
602
|
+
"alice": {
|
|
603
|
+
"lastSignature": "signature",
|
|
604
|
+
"newTransactions": "73 transactions after 292",
|
|
605
|
+
},
|
|
606
|
+
},
|
|
607
|
+
"priority": 3,
|
|
608
|
+
},
|
|
609
|
+
{
|
|
610
|
+
"action": "content",
|
|
611
|
+
"expectContentUntil": undefined,
|
|
612
|
+
"header": undefined,
|
|
613
|
+
"id": "id",
|
|
614
|
+
"new": {
|
|
615
|
+
"alice": {
|
|
616
|
+
"lastSignature": "signature",
|
|
617
|
+
"newTransactions": "35 transactions after 365",
|
|
556
618
|
},
|
|
557
619
|
},
|
|
558
620
|
"priority": 3,
|
|
@@ -567,21 +629,11 @@ describe("newContentSince", () => {
|
|
|
567
629
|
const group = client.node.createGroup();
|
|
568
630
|
const map = group.createMap();
|
|
569
631
|
// Generate a large amount of data (about 1MB)
|
|
570
|
-
|
|
571
|
-
const chunkSize = 1024; // 1KB chunks
|
|
572
|
-
const chunks = dataSize / chunkSize;
|
|
573
|
-
const value = Buffer.alloc(chunkSize, `value$`).toString("base64");
|
|
574
|
-
for (let i = 0; i < chunks; i++) {
|
|
575
|
-
const key = `key${i}`;
|
|
576
|
-
map.set(key, value, "trusting");
|
|
577
|
-
}
|
|
632
|
+
fillCoMapWithLargeData(map);
|
|
578
633
|
// Capture knownState
|
|
579
634
|
const knownState = map.core.knownState();
|
|
580
635
|
// Add more data to first session
|
|
581
|
-
|
|
582
|
-
const key = `key_new_${i}`;
|
|
583
|
-
map.set(key, value, "trusting");
|
|
584
|
-
}
|
|
636
|
+
fillCoMapWithLargeData(map);
|
|
585
637
|
// Add a small session
|
|
586
638
|
const newSession = client.spawnNewSession();
|
|
587
639
|
const mapInNewSession = await loadCoValueOrFail(newSession.node, map.id);
|
|
@@ -596,7 +648,7 @@ describe("newContentSince", () => {
|
|
|
596
648
|
{
|
|
597
649
|
"action": "content",
|
|
598
650
|
"expectContentUntil": {
|
|
599
|
-
"alice":
|
|
651
|
+
"alice": 400,
|
|
600
652
|
"bob": 1,
|
|
601
653
|
},
|
|
602
654
|
"header": undefined,
|
|
@@ -604,7 +656,7 @@ describe("newContentSince", () => {
|
|
|
604
656
|
"new": {
|
|
605
657
|
"alice": {
|
|
606
658
|
"lastSignature": "signature",
|
|
607
|
-
"newTransactions": "
|
|
659
|
+
"newTransactions": "19 transactions after 200",
|
|
608
660
|
},
|
|
609
661
|
},
|
|
610
662
|
"priority": 3,
|
|
@@ -617,7 +669,33 @@ describe("newContentSince", () => {
|
|
|
617
669
|
"new": {
|
|
618
670
|
"alice": {
|
|
619
671
|
"lastSignature": "signature",
|
|
620
|
-
"newTransactions": "
|
|
672
|
+
"newTransactions": "73 transactions after 219",
|
|
673
|
+
},
|
|
674
|
+
},
|
|
675
|
+
"priority": 3,
|
|
676
|
+
},
|
|
677
|
+
{
|
|
678
|
+
"action": "content",
|
|
679
|
+
"expectContentUntil": undefined,
|
|
680
|
+
"header": undefined,
|
|
681
|
+
"id": "id",
|
|
682
|
+
"new": {
|
|
683
|
+
"alice": {
|
|
684
|
+
"lastSignature": "signature",
|
|
685
|
+
"newTransactions": "73 transactions after 292",
|
|
686
|
+
},
|
|
687
|
+
},
|
|
688
|
+
"priority": 3,
|
|
689
|
+
},
|
|
690
|
+
{
|
|
691
|
+
"action": "content",
|
|
692
|
+
"expectContentUntil": undefined,
|
|
693
|
+
"header": undefined,
|
|
694
|
+
"id": "id",
|
|
695
|
+
"new": {
|
|
696
|
+
"alice": {
|
|
697
|
+
"lastSignature": "signature",
|
|
698
|
+
"newTransactions": "35 transactions after 365",
|
|
621
699
|
},
|
|
622
700
|
"bob": {
|
|
623
701
|
"lastSignature": "signature",
|
|
@@ -640,21 +718,11 @@ describe("newContentSince", () => {
|
|
|
640
718
|
// Capture knownState
|
|
641
719
|
const knownState = map.core.knownState();
|
|
642
720
|
// Generate a large amount of data in first session (about 1MB)
|
|
643
|
-
|
|
644
|
-
const chunkSize = 1024; // 1KB chunks
|
|
645
|
-
const chunks = dataSize / chunkSize;
|
|
646
|
-
const value = Buffer.alloc(chunkSize, `value$`).toString("base64");
|
|
647
|
-
for (let i = 0; i < chunks; i++) {
|
|
648
|
-
const key = `key1_${i}`;
|
|
649
|
-
map.set(key, value, "trusting");
|
|
650
|
-
}
|
|
721
|
+
fillCoMapWithLargeData(map);
|
|
651
722
|
// Add second large session
|
|
652
723
|
const newSession = client.spawnNewSession();
|
|
653
724
|
const mapInNewSession = await loadCoValueOrFail(newSession.node, map.id);
|
|
654
|
-
|
|
655
|
-
const key = `key2_${i}`;
|
|
656
|
-
mapInNewSession.set(key, value, "trusting");
|
|
657
|
-
}
|
|
725
|
+
fillCoMapWithLargeData(mapInNewSession);
|
|
658
726
|
const content = mapInNewSession.core.newContentSince(knownState);
|
|
659
727
|
const sessionMapping = {
|
|
660
728
|
[client.node.currentSessionID]: "alice",
|
|
@@ -665,8 +733,8 @@ describe("newContentSince", () => {
|
|
|
665
733
|
{
|
|
666
734
|
"action": "content",
|
|
667
735
|
"expectContentUntil": {
|
|
668
|
-
"alice":
|
|
669
|
-
"bob":
|
|
736
|
+
"alice": 201,
|
|
737
|
+
"bob": 200,
|
|
670
738
|
},
|
|
671
739
|
"header": undefined,
|
|
672
740
|
"id": "id",
|
|
@@ -678,6 +746,19 @@ describe("newContentSince", () => {
|
|
|
678
746
|
},
|
|
679
747
|
"priority": 3,
|
|
680
748
|
},
|
|
749
|
+
{
|
|
750
|
+
"action": "content",
|
|
751
|
+
"expectContentUntil": undefined,
|
|
752
|
+
"header": undefined,
|
|
753
|
+
"id": "id",
|
|
754
|
+
"new": {
|
|
755
|
+
"alice": {
|
|
756
|
+
"lastSignature": "signature",
|
|
757
|
+
"newTransactions": "73 transactions after 74",
|
|
758
|
+
},
|
|
759
|
+
},
|
|
760
|
+
"priority": 3,
|
|
761
|
+
},
|
|
681
762
|
{
|
|
682
763
|
"action": "content",
|
|
683
764
|
"expectContentUntil": undefined,
|
|
@@ -691,6 +772,19 @@ describe("newContentSince", () => {
|
|
|
691
772
|
},
|
|
692
773
|
"priority": 3,
|
|
693
774
|
},
|
|
775
|
+
{
|
|
776
|
+
"action": "content",
|
|
777
|
+
"expectContentUntil": undefined,
|
|
778
|
+
"header": undefined,
|
|
779
|
+
"id": "id",
|
|
780
|
+
"new": {
|
|
781
|
+
"bob": {
|
|
782
|
+
"lastSignature": "signature",
|
|
783
|
+
"newTransactions": "73 transactions after 73",
|
|
784
|
+
},
|
|
785
|
+
},
|
|
786
|
+
"priority": 3,
|
|
787
|
+
},
|
|
694
788
|
{
|
|
695
789
|
"action": "content",
|
|
696
790
|
"expectContentUntil": undefined,
|
|
@@ -699,11 +793,11 @@ describe("newContentSince", () => {
|
|
|
699
793
|
"new": {
|
|
700
794
|
"alice": {
|
|
701
795
|
"lastSignature": "signature",
|
|
702
|
-
"newTransactions": "
|
|
796
|
+
"newTransactions": "54 transactions after 147",
|
|
703
797
|
},
|
|
704
798
|
"bob": {
|
|
705
799
|
"lastSignature": "signature",
|
|
706
|
-
"newTransactions": "
|
|
800
|
+
"newTransactions": "54 transactions after 146",
|
|
707
801
|
},
|
|
708
802
|
},
|
|
709
803
|
"priority": 3,
|
|
@@ -722,14 +816,7 @@ describe("newContentSince", () => {
|
|
|
722
816
|
// Capture knownState
|
|
723
817
|
const knownState = map.core.knownState();
|
|
724
818
|
// Generate first large session (about 1MB)
|
|
725
|
-
|
|
726
|
-
const chunkSize = 1024; // 1KB chunks
|
|
727
|
-
const chunks = dataSize / chunkSize;
|
|
728
|
-
const value = Buffer.alloc(chunkSize, `value$`).toString("base64");
|
|
729
|
-
for (let i = 0; i < chunks; i++) {
|
|
730
|
-
const key = `key1_${i}`;
|
|
731
|
-
map.set(key, value, "trusting");
|
|
732
|
-
}
|
|
819
|
+
fillCoMapWithLargeData(map);
|
|
733
820
|
// Add small session
|
|
734
821
|
const session2 = client.spawnNewSession();
|
|
735
822
|
const mapInSession2 = await loadCoValueOrFail(session2.node, map.id);
|
|
@@ -737,10 +824,7 @@ describe("newContentSince", () => {
|
|
|
737
824
|
// Add third large session
|
|
738
825
|
const session3 = client.spawnNewSession();
|
|
739
826
|
const mapInSession3 = await loadCoValueOrFail(session3.node, map.id);
|
|
740
|
-
|
|
741
|
-
const key = `key3_${i}`;
|
|
742
|
-
mapInSession3.set(key, value, "trusting");
|
|
743
|
-
}
|
|
827
|
+
fillCoMapWithLargeData(mapInSession3);
|
|
744
828
|
const content = mapInSession3.core.newContentSince(knownState);
|
|
745
829
|
const sessionMapping = {
|
|
746
830
|
[client.node.currentSessionID]: "alice",
|
|
@@ -752,9 +836,9 @@ describe("newContentSince", () => {
|
|
|
752
836
|
{
|
|
753
837
|
"action": "content",
|
|
754
838
|
"expectContentUntil": {
|
|
755
|
-
"alice":
|
|
839
|
+
"alice": 201,
|
|
756
840
|
"bob": 1,
|
|
757
|
-
"charlie":
|
|
841
|
+
"charlie": 200,
|
|
758
842
|
},
|
|
759
843
|
"header": undefined,
|
|
760
844
|
"id": "id",
|
|
@@ -766,6 +850,19 @@ describe("newContentSince", () => {
|
|
|
766
850
|
},
|
|
767
851
|
"priority": 3,
|
|
768
852
|
},
|
|
853
|
+
{
|
|
854
|
+
"action": "content",
|
|
855
|
+
"expectContentUntil": undefined,
|
|
856
|
+
"header": undefined,
|
|
857
|
+
"id": "id",
|
|
858
|
+
"new": {
|
|
859
|
+
"alice": {
|
|
860
|
+
"lastSignature": "signature",
|
|
861
|
+
"newTransactions": "73 transactions after 74",
|
|
862
|
+
},
|
|
863
|
+
},
|
|
864
|
+
"priority": 3,
|
|
865
|
+
},
|
|
769
866
|
{
|
|
770
867
|
"action": "content",
|
|
771
868
|
"expectContentUntil": undefined,
|
|
@@ -779,6 +876,19 @@ describe("newContentSince", () => {
|
|
|
779
876
|
},
|
|
780
877
|
"priority": 3,
|
|
781
878
|
},
|
|
879
|
+
{
|
|
880
|
+
"action": "content",
|
|
881
|
+
"expectContentUntil": undefined,
|
|
882
|
+
"header": undefined,
|
|
883
|
+
"id": "id",
|
|
884
|
+
"new": {
|
|
885
|
+
"charlie": {
|
|
886
|
+
"lastSignature": "signature",
|
|
887
|
+
"newTransactions": "73 transactions after 73",
|
|
888
|
+
},
|
|
889
|
+
},
|
|
890
|
+
"priority": 3,
|
|
891
|
+
},
|
|
782
892
|
{
|
|
783
893
|
"action": "content",
|
|
784
894
|
"expectContentUntil": undefined,
|
|
@@ -787,7 +897,7 @@ describe("newContentSince", () => {
|
|
|
787
897
|
"new": {
|
|
788
898
|
"alice": {
|
|
789
899
|
"lastSignature": "signature",
|
|
790
|
-
"newTransactions": "
|
|
900
|
+
"newTransactions": "54 transactions after 147",
|
|
791
901
|
},
|
|
792
902
|
"bob": {
|
|
793
903
|
"lastSignature": "signature",
|
|
@@ -795,7 +905,7 @@ describe("newContentSince", () => {
|
|
|
795
905
|
},
|
|
796
906
|
"charlie": {
|
|
797
907
|
"lastSignature": "signature",
|
|
798
|
-
"newTransactions": "
|
|
908
|
+
"newTransactions": "54 transactions after 146",
|
|
799
909
|
},
|
|
800
910
|
},
|
|
801
911
|
"priority": 3,
|