@powersync/service-core-tests 0.15.0 → 0.15.2

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 (28) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/dist/test-utils/general-utils.d.ts +13 -1
  3. package/dist/test-utils/general-utils.js +30 -1
  4. package/dist/test-utils/general-utils.js.map +1 -1
  5. package/dist/test-utils/stream_utils.js +2 -2
  6. package/dist/test-utils/stream_utils.js.map +1 -1
  7. package/dist/tests/register-compacting-tests.js +266 -257
  8. package/dist/tests/register-compacting-tests.js.map +1 -1
  9. package/dist/tests/register-data-storage-checkpoint-tests.js +36 -57
  10. package/dist/tests/register-data-storage-checkpoint-tests.js.map +1 -1
  11. package/dist/tests/register-data-storage-data-tests.js +839 -863
  12. package/dist/tests/register-data-storage-data-tests.js.map +1 -1
  13. package/dist/tests/register-data-storage-parameter-tests.js +228 -236
  14. package/dist/tests/register-data-storage-parameter-tests.js.map +1 -1
  15. package/dist/tests/register-parameter-compacting-tests.js +81 -89
  16. package/dist/tests/register-parameter-compacting-tests.js.map +1 -1
  17. package/dist/tests/register-sync-tests.js +468 -462
  18. package/dist/tests/register-sync-tests.js.map +1 -1
  19. package/package.json +3 -3
  20. package/src/test-utils/general-utils.ts +41 -2
  21. package/src/test-utils/stream_utils.ts +2 -2
  22. package/src/tests/register-compacting-tests.ts +279 -270
  23. package/src/tests/register-data-storage-checkpoint-tests.ts +36 -57
  24. package/src/tests/register-data-storage-data-tests.ts +673 -770
  25. package/src/tests/register-data-storage-parameter-tests.ts +245 -257
  26. package/src/tests/register-parameter-compacting-tests.ts +84 -92
  27. package/src/tests/register-sync-tests.ts +375 -391
  28. package/tsconfig.tsbuildinfo +1 -1
@@ -6,7 +6,6 @@ import { bucketRequestMap, bucketRequests } from './util.js';
6
6
 
7
7
  export function registerCompactTests(config: storage.TestStorageConfig) {
8
8
  const generateStorageFactory = config.factory;
9
- const TEST_TABLE = test_utils.makeTestTable('test', ['id'], config);
10
9
 
11
10
  test('compacting (1)', async () => {
12
11
  await using factory = await generateStorageFactory();
@@ -19,39 +18,40 @@ bucket_definitions:
19
18
  );
20
19
  const bucketStorage = factory.getInstance(syncRules);
21
20
 
22
- const result = await bucketStorage.startBatch(test_utils.BATCH_OPTIONS, async (batch) => {
23
- await batch.markAllSnapshotDone('1/1');
24
- await batch.save({
25
- sourceTable: TEST_TABLE,
26
- tag: storage.SaveOperationTag.INSERT,
27
- after: {
28
- id: 't1'
29
- },
30
- afterReplicaId: test_utils.rid('t1')
31
- });
32
-
33
- await batch.save({
34
- sourceTable: TEST_TABLE,
35
- tag: storage.SaveOperationTag.INSERT,
36
- after: {
37
- id: 't2'
38
- },
39
- afterReplicaId: test_utils.rid('t2')
40
- });
21
+ await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
22
+ const testTable = await test_utils.resolveTestTable(writer, 'test', ['id'], config);
23
+ await writer.markAllSnapshotDone('1/1');
24
+ await writer.save({
25
+ sourceTable: testTable,
26
+ tag: storage.SaveOperationTag.INSERT,
27
+ after: {
28
+ id: 't1'
29
+ },
30
+ afterReplicaId: test_utils.rid('t1')
31
+ });
41
32
 
42
- await batch.save({
43
- sourceTable: TEST_TABLE,
44
- tag: storage.SaveOperationTag.UPDATE,
45
- after: {
46
- id: 't2'
47
- },
48
- afterReplicaId: test_utils.rid('t2')
49
- });
33
+ await writer.save({
34
+ sourceTable: testTable,
35
+ tag: storage.SaveOperationTag.INSERT,
36
+ after: {
37
+ id: 't2'
38
+ },
39
+ afterReplicaId: test_utils.rid('t2')
40
+ });
50
41
 
51
- await batch.commit('1/1');
42
+ await writer.save({
43
+ sourceTable: testTable,
44
+ tag: storage.SaveOperationTag.UPDATE,
45
+ after: {
46
+ id: 't2'
47
+ },
48
+ afterReplicaId: test_utils.rid('t2')
52
49
  });
53
50
 
54
- const checkpoint = result!.flushed_op;
51
+ await writer.commit('1/1');
52
+ await writer.flush();
53
+
54
+ const checkpoint = writer.last_flushed_op!;
55
55
 
56
56
  const request = bucketRequest(syncRules, 'global[]');
57
57
 
@@ -125,48 +125,49 @@ bucket_definitions:
125
125
  );
126
126
  const bucketStorage = factory.getInstance(syncRules);
127
127
 
128
- const result = await bucketStorage.startBatch(test_utils.BATCH_OPTIONS, async (batch) => {
129
- await batch.markAllSnapshotDone('1/1');
130
- await batch.save({
131
- sourceTable: TEST_TABLE,
132
- tag: storage.SaveOperationTag.INSERT,
133
- after: {
134
- id: 't1'
135
- },
136
- afterReplicaId: test_utils.rid('t1')
137
- });
138
-
139
- await batch.save({
140
- sourceTable: TEST_TABLE,
141
- tag: storage.SaveOperationTag.INSERT,
142
- after: {
143
- id: 't2'
144
- },
145
- afterReplicaId: test_utils.rid('t2')
146
- });
128
+ await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
129
+ const testTable = await test_utils.resolveTestTable(writer, 'test', ['id'], config);
130
+ await writer.markAllSnapshotDone('1/1');
131
+ await writer.save({
132
+ sourceTable: testTable,
133
+ tag: storage.SaveOperationTag.INSERT,
134
+ after: {
135
+ id: 't1'
136
+ },
137
+ afterReplicaId: test_utils.rid('t1')
138
+ });
147
139
 
148
- await batch.save({
149
- sourceTable: TEST_TABLE,
150
- tag: storage.SaveOperationTag.DELETE,
151
- before: {
152
- id: 't1'
153
- },
154
- beforeReplicaId: test_utils.rid('t1')
155
- });
140
+ await writer.save({
141
+ sourceTable: testTable,
142
+ tag: storage.SaveOperationTag.INSERT,
143
+ after: {
144
+ id: 't2'
145
+ },
146
+ afterReplicaId: test_utils.rid('t2')
147
+ });
156
148
 
157
- await batch.save({
158
- sourceTable: TEST_TABLE,
159
- tag: storage.SaveOperationTag.UPDATE,
160
- after: {
161
- id: 't2'
162
- },
163
- afterReplicaId: test_utils.rid('t2')
164
- });
149
+ await writer.save({
150
+ sourceTable: testTable,
151
+ tag: storage.SaveOperationTag.DELETE,
152
+ before: {
153
+ id: 't1'
154
+ },
155
+ beforeReplicaId: test_utils.rid('t1')
156
+ });
165
157
 
166
- await batch.commit('1/1');
158
+ await writer.save({
159
+ sourceTable: testTable,
160
+ tag: storage.SaveOperationTag.UPDATE,
161
+ after: {
162
+ id: 't2'
163
+ },
164
+ afterReplicaId: test_utils.rid('t2')
167
165
  });
168
166
 
169
- const checkpoint = result!.flushed_op;
167
+ await writer.commit('1/1');
168
+ await writer.flush();
169
+
170
+ const checkpoint = writer.last_flushed_op!;
170
171
  const request = bucketRequest(syncRules, 'global[]');
171
172
 
172
173
  const batchBefore = await test_utils.oneFromAsync(bucketStorage.getBucketDataBatch(checkpoint, [request]));
@@ -240,54 +241,54 @@ bucket_definitions:
240
241
  );
241
242
  const bucketStorage = factory.getInstance(syncRules);
242
243
 
243
- const result = await bucketStorage.startBatch(test_utils.BATCH_OPTIONS, async (batch) => {
244
- await batch.markAllSnapshotDone('1/1');
245
- await batch.save({
246
- sourceTable: TEST_TABLE,
247
- tag: storage.SaveOperationTag.INSERT,
248
- after: {
249
- id: 't1'
250
- },
251
- afterReplicaId: 't1'
252
- });
253
-
254
- await batch.save({
255
- sourceTable: TEST_TABLE,
256
- tag: storage.SaveOperationTag.INSERT,
257
- after: {
258
- id: 't2'
259
- },
260
- afterReplicaId: 't2'
261
- });
244
+ await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
245
+ const testTable = await test_utils.resolveTestTable(writer, 'test', ['id'], config);
246
+ await writer.markAllSnapshotDone('1/1');
247
+ await writer.save({
248
+ sourceTable: testTable,
249
+ tag: storage.SaveOperationTag.INSERT,
250
+ after: {
251
+ id: 't1'
252
+ },
253
+ afterReplicaId: 't1'
254
+ });
262
255
 
263
- await batch.save({
264
- sourceTable: TEST_TABLE,
265
- tag: storage.SaveOperationTag.DELETE,
266
- before: {
267
- id: 't1'
268
- },
269
- beforeReplicaId: 't1'
270
- });
256
+ await writer.save({
257
+ sourceTable: testTable,
258
+ tag: storage.SaveOperationTag.INSERT,
259
+ after: {
260
+ id: 't2'
261
+ },
262
+ afterReplicaId: 't2'
263
+ });
271
264
 
272
- await batch.commit('1/1');
265
+ await writer.save({
266
+ sourceTable: testTable,
267
+ tag: storage.SaveOperationTag.DELETE,
268
+ before: {
269
+ id: 't1'
270
+ },
271
+ beforeReplicaId: 't1'
273
272
  });
274
273
 
275
- const checkpoint1 = result!.flushed_op;
274
+ await writer.commit('1/1');
275
+ await writer.flush();
276
+
277
+ const checkpoint1 = writer.last_flushed_op!;
276
278
  const request = bucketRequest(syncRules, 'global[]');
277
- const checksumBefore = await bucketStorage.getChecksums(checkpoint1, [request]);
278
-
279
- const result2 = await bucketStorage.startBatch(test_utils.BATCH_OPTIONS, async (batch) => {
280
- await batch.save({
281
- sourceTable: TEST_TABLE,
282
- tag: storage.SaveOperationTag.DELETE,
283
- before: {
284
- id: 't2'
285
- },
286
- beforeReplicaId: 't2'
287
- });
288
- await batch.commit('2/1');
279
+ await using writer2 = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
280
+ const testTable2 = await test_utils.resolveTestTable(writer2, 'test', ['id'], config);
281
+ await writer2.save({
282
+ sourceTable: testTable2,
283
+ tag: storage.SaveOperationTag.DELETE,
284
+ before: {
285
+ id: 't2'
286
+ },
287
+ beforeReplicaId: 't2'
289
288
  });
290
- const checkpoint2 = result2!.flushed_op;
289
+ await writer2.commit('2/1');
290
+ await writer2.flush();
291
+ const checkpoint2 = writer2.last_flushed_op!;
291
292
 
292
293
  await bucketStorage.compact({
293
294
  clearBatchLimit: 2,
@@ -328,76 +329,78 @@ bucket_definitions:
328
329
  );
329
330
  const bucketStorage = factory.getInstance(syncRules);
330
331
 
331
- const result = await bucketStorage.startBatch(test_utils.BATCH_OPTIONS, async (batch) => {
332
- await batch.markAllSnapshotDone('1/1');
333
- /**
334
- * Repeatedly create operations which fall into different buckets.
335
- * The bucket operations are purposely interleaved as the op_id increases.
336
- * A large amount of operations are created here.
337
- * The configured window of compacting operations is 100. This means the initial window will
338
- * contain operations from multiple buckets.
339
- */
340
- for (let count = 0; count < 100; count++) {
341
- await batch.save({
342
- sourceTable: TEST_TABLE,
343
- tag: storage.SaveOperationTag.INSERT,
344
- after: {
345
- id: 't1',
346
- b: 'b1',
347
- value: 'start'
348
- },
349
- afterReplicaId: test_utils.rid('t1')
350
- });
351
-
352
- await batch.save({
353
- sourceTable: TEST_TABLE,
354
- tag: storage.SaveOperationTag.UPDATE,
355
- after: {
356
- id: 't1',
357
- b: 'b1',
358
- value: 'intermediate'
359
- },
360
- afterReplicaId: test_utils.rid('t1')
361
- });
362
-
363
- await batch.save({
364
- sourceTable: TEST_TABLE,
365
- tag: storage.SaveOperationTag.INSERT,
366
- after: {
367
- id: 't2',
368
- b: 'b2',
369
- value: 'start'
370
- },
371
- afterReplicaId: test_utils.rid('t2')
372
- });
373
-
374
- await batch.save({
375
- sourceTable: TEST_TABLE,
376
- tag: storage.SaveOperationTag.UPDATE,
377
- after: {
378
- id: 't1',
379
- b: 'b1',
380
- value: 'final'
381
- },
382
- afterReplicaId: test_utils.rid('t1')
383
- });
384
-
385
- await batch.save({
386
- sourceTable: TEST_TABLE,
387
- tag: storage.SaveOperationTag.UPDATE,
388
- after: {
389
- id: 't2',
390
- b: 'b2',
391
- value: 'final'
392
- },
393
- afterReplicaId: test_utils.rid('t2')
394
- });
395
-
396
- await batch.commit('1/1');
397
- }
398
- });
332
+ await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
333
+ const testTable = await test_utils.resolveTestTable(writer, 'test', ['id'], config);
334
+ await writer.markAllSnapshotDone('1/1');
335
+ /**
336
+ * Repeatedly create operations which fall into different buckets.
337
+ * The bucket operations are purposely interleaved as the op_id increases.
338
+ * A large amount of operations are created here.
339
+ * The configured window of compacting operations is 100. This means the initial window will
340
+ * contain operations from multiple buckets.
341
+ */
342
+ for (let count = 0; count < 100; count++) {
343
+ await writer.save({
344
+ sourceTable: testTable,
345
+ tag: storage.SaveOperationTag.INSERT,
346
+ after: {
347
+ id: 't1',
348
+ b: 'b1',
349
+ value: 'start'
350
+ },
351
+ afterReplicaId: test_utils.rid('t1')
352
+ });
353
+
354
+ await writer.save({
355
+ sourceTable: testTable,
356
+ tag: storage.SaveOperationTag.UPDATE,
357
+ after: {
358
+ id: 't1',
359
+ b: 'b1',
360
+ value: 'intermediate'
361
+ },
362
+ afterReplicaId: test_utils.rid('t1')
363
+ });
364
+
365
+ await writer.save({
366
+ sourceTable: testTable,
367
+ tag: storage.SaveOperationTag.INSERT,
368
+ after: {
369
+ id: 't2',
370
+ b: 'b2',
371
+ value: 'start'
372
+ },
373
+ afterReplicaId: test_utils.rid('t2')
374
+ });
375
+
376
+ await writer.save({
377
+ sourceTable: testTable,
378
+ tag: storage.SaveOperationTag.UPDATE,
379
+ after: {
380
+ id: 't1',
381
+ b: 'b1',
382
+ value: 'final'
383
+ },
384
+ afterReplicaId: test_utils.rid('t1')
385
+ });
386
+
387
+ await writer.save({
388
+ sourceTable: testTable,
389
+ tag: storage.SaveOperationTag.UPDATE,
390
+ after: {
391
+ id: 't2',
392
+ b: 'b2',
393
+ value: 'final'
394
+ },
395
+ afterReplicaId: test_utils.rid('t2')
396
+ });
397
+
398
+ await writer.commit('1/1');
399
+ }
399
400
 
400
- const checkpoint = result!.flushed_op;
401
+ await writer.flush();
402
+
403
+ const checkpoint = writer.last_flushed_op!;
401
404
 
402
405
  await bucketStorage.compact({
403
406
  clearBatchLimit: 100,
@@ -456,38 +459,39 @@ bucket_definitions:
456
459
  );
457
460
  const bucketStorage = factory.getInstance(syncRules);
458
461
 
459
- await bucketStorage.startBatch(test_utils.BATCH_OPTIONS, async (batch) => {
460
- await batch.markAllSnapshotDone('1/1');
461
- await batch.save({
462
- sourceTable: TEST_TABLE,
463
- tag: storage.SaveOperationTag.INSERT,
464
- after: {
465
- id: 't1'
466
- },
467
- afterReplicaId: 't1'
468
- });
469
-
470
- await batch.save({
471
- sourceTable: TEST_TABLE,
472
- tag: storage.SaveOperationTag.INSERT,
473
- after: {
474
- id: 't2'
475
- },
476
- afterReplicaId: 't2'
477
- });
462
+ await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
463
+ const testTable = await test_utils.resolveTestTable(writer, 'test', ['id'], config);
464
+ await writer.markAllSnapshotDone('1/1');
465
+ await writer.save({
466
+ sourceTable: testTable,
467
+ tag: storage.SaveOperationTag.INSERT,
468
+ after: {
469
+ id: 't1'
470
+ },
471
+ afterReplicaId: 't1'
472
+ });
478
473
 
479
- await batch.save({
480
- sourceTable: TEST_TABLE,
481
- tag: storage.SaveOperationTag.DELETE,
482
- before: {
483
- id: 't1'
484
- },
485
- beforeReplicaId: 't1'
486
- });
474
+ await writer.save({
475
+ sourceTable: testTable,
476
+ tag: storage.SaveOperationTag.INSERT,
477
+ after: {
478
+ id: 't2'
479
+ },
480
+ afterReplicaId: 't2'
481
+ });
487
482
 
488
- await batch.commit('1/1');
483
+ await writer.save({
484
+ sourceTable: testTable,
485
+ tag: storage.SaveOperationTag.DELETE,
486
+ before: {
487
+ id: 't1'
488
+ },
489
+ beforeReplicaId: 't1'
489
490
  });
490
491
 
492
+ await writer.commit('1/1');
493
+ await writer.flush();
494
+
491
495
  await bucketStorage.compact({
492
496
  clearBatchLimit: 2,
493
497
  moveBatchLimit: 1,
@@ -496,18 +500,19 @@ bucket_definitions:
496
500
  minChangeRatio: 0
497
501
  });
498
502
 
499
- const result2 = await bucketStorage.startBatch(test_utils.BATCH_OPTIONS, async (batch) => {
500
- await batch.save({
501
- sourceTable: TEST_TABLE,
502
- tag: storage.SaveOperationTag.DELETE,
503
- before: {
504
- id: 't2'
505
- },
506
- beforeReplicaId: 't2'
507
- });
508
- await batch.commit('2/1');
503
+ await using writer2 = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
504
+ const testTable2 = await test_utils.resolveTestTable(writer2, 'test', ['id'], config);
505
+ await writer2.save({
506
+ sourceTable: testTable2,
507
+ tag: storage.SaveOperationTag.DELETE,
508
+ before: {
509
+ id: 't2'
510
+ },
511
+ beforeReplicaId: 't2'
509
512
  });
510
- const checkpoint2 = result2!.flushed_op;
513
+ await writer2.commit('2/1');
514
+ await writer2.flush();
515
+ const checkpoint2 = writer2.last_flushed_op!;
511
516
  const request = bucketRequest(syncRules, 'global[]');
512
517
  await bucketStorage.clearChecksumCache();
513
518
  const checksumAfter = await bucketStorage.getChecksums(checkpoint2, [request]);
@@ -532,42 +537,44 @@ bucket_definitions:
532
537
  );
533
538
  const bucketStorage = factory.getInstance(syncRules);
534
539
 
535
- const result = await bucketStorage.startBatch(test_utils.BATCH_OPTIONS, async (batch) => {
536
- await batch.markAllSnapshotDone('1/1');
537
- await batch.save({
538
- sourceTable: TEST_TABLE,
539
- tag: storage.SaveOperationTag.INSERT,
540
- after: {
541
- id: 't1'
542
- },
543
- afterReplicaId: 't1'
544
- });
545
-
546
- await batch.save({
547
- sourceTable: TEST_TABLE,
548
- tag: storage.SaveOperationTag.UPDATE,
549
- after: {
550
- id: 't1'
551
- },
552
- afterReplicaId: 't1'
553
- });
540
+ await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
541
+ const testTable = await test_utils.resolveTestTable(writer, 'test', ['id'], config);
542
+ await writer.markAllSnapshotDone('1/1');
543
+ await writer.save({
544
+ sourceTable: testTable,
545
+ tag: storage.SaveOperationTag.INSERT,
546
+ after: {
547
+ id: 't1'
548
+ },
549
+ afterReplicaId: 't1'
550
+ });
554
551
 
555
- await batch.commit('1/1');
552
+ await writer.save({
553
+ sourceTable: testTable,
554
+ tag: storage.SaveOperationTag.UPDATE,
555
+ after: {
556
+ id: 't1'
557
+ },
558
+ afterReplicaId: 't1'
556
559
  });
557
560
 
561
+ await writer.commit('1/1');
562
+ await writer.flush();
563
+
558
564
  // Get checksums here just to populate the cache
559
- await bucketStorage.getChecksums(result!.flushed_op, bucketRequests(syncRules, ['global[]']));
560
- const result2 = await bucketStorage.startBatch(test_utils.BATCH_OPTIONS, async (batch) => {
561
- await batch.save({
562
- sourceTable: TEST_TABLE,
563
- tag: storage.SaveOperationTag.DELETE,
564
- before: {
565
- id: 't1'
566
- },
567
- beforeReplicaId: 't1'
568
- });
569
- await batch.commit('2/1');
565
+ await bucketStorage.getChecksums(writer.last_flushed_op!, bucketRequests(syncRules, ['global[]']));
566
+ await using writer2 = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
567
+ const testTable2 = await test_utils.resolveTestTable(writer2, 'test', ['id'], config);
568
+ await writer2.save({
569
+ sourceTable: testTable2,
570
+ tag: storage.SaveOperationTag.DELETE,
571
+ before: {
572
+ id: 't1'
573
+ },
574
+ beforeReplicaId: 't1'
570
575
  });
576
+ await writer2.commit('2/1');
577
+ await writer2.flush();
571
578
 
572
579
  await bucketStorage.compact({
573
580
  clearBatchLimit: 20,
@@ -577,7 +584,7 @@ bucket_definitions:
577
584
  minChangeRatio: 0
578
585
  });
579
586
 
580
- const checkpoint2 = result2!.flushed_op;
587
+ const checkpoint2 = writer2.last_flushed_op!;
581
588
  const request = bucketRequest(syncRules, 'global[]');
582
589
  // Check that the checksum was correctly updated with the clear operation after having a cached checksum
583
590
  const checksumAfter = await bucketStorage.getChecksums(checkpoint2, [request]);
@@ -601,29 +608,31 @@ bucket_definitions:
601
608
  );
602
609
  const bucketStorage = factory.getInstance(syncRules);
603
610
 
604
- const result1 = await bucketStorage.startBatch(test_utils.BATCH_OPTIONS, async (batch) => {
605
- await batch.markAllSnapshotDone('1/1');
606
- await batch.save({
607
- sourceTable: TEST_TABLE,
608
- tag: storage.SaveOperationTag.INSERT,
609
- after: { id: 't1' },
610
- afterReplicaId: test_utils.rid('t1')
611
- });
612
- await batch.commit('1/1');
611
+ await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
612
+ const testTable = await test_utils.resolveTestTable(writer, 'test', ['id'], config);
613
+ await writer.markAllSnapshotDone('1/1');
614
+ await writer.save({
615
+ sourceTable: testTable,
616
+ tag: storage.SaveOperationTag.INSERT,
617
+ after: { id: 't1' },
618
+ afterReplicaId: test_utils.rid('t1')
613
619
  });
614
-
615
- const checkpoint1 = result1!.flushed_op;
616
-
617
- const result2 = await bucketStorage.startBatch(test_utils.BATCH_OPTIONS, async (batch) => {
618
- // This is flushed but not committed (does not advance the checkpoint)
619
- await batch.save({
620
- sourceTable: TEST_TABLE,
621
- tag: storage.SaveOperationTag.UPDATE,
622
- after: { id: 't1' },
623
- afterReplicaId: test_utils.rid('t1')
624
- });
620
+ await writer.commit('1/1');
621
+ await writer.flush();
622
+
623
+ const checkpoint1 = writer.last_flushed_op!;
624
+
625
+ await using writer2 = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
626
+ const testTable2 = await test_utils.resolveTestTable(writer2, 'test', ['id'], config);
627
+ // This is flushed but not committed (does not advance the checkpoint)
628
+ await writer2.save({
629
+ sourceTable: testTable2,
630
+ tag: storage.SaveOperationTag.UPDATE,
631
+ after: { id: 't1' },
632
+ afterReplicaId: test_utils.rid('t1')
625
633
  });
626
- const checkpoint2 = result2!.flushed_op;
634
+ await writer2.flush();
635
+ const checkpoint2 = writer2.last_flushed_op!;
627
636
 
628
637
  const checkpointBeforeCompact = await bucketStorage.getCheckpoint();
629
638
  expect(checkpointBeforeCompact.checkpoint).toEqual(checkpoint1);