@fireproof/core 0.20.0-dev-preview-40 → 0.20.0-dev-preview-50

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 (45) hide show
  1. package/README.md +6 -4
  2. package/deno/index.js +2 -2
  3. package/deno/index.js.map +1 -1
  4. package/deno.json +3 -2
  5. package/index.cjs +955 -599
  6. package/index.cjs.map +1 -1
  7. package/index.d.cts +334 -127
  8. package/index.d.ts +334 -127
  9. package/index.js +939 -582
  10. package/index.js.map +1 -1
  11. package/indexeddb/index.cjs.map +1 -1
  12. package/indexeddb/index.js.map +1 -1
  13. package/indexeddb/metafile-cjs.json +1 -1
  14. package/indexeddb/metafile-esm.json +1 -1
  15. package/metafile-cjs.json +1 -1
  16. package/metafile-esm.json +1 -1
  17. package/package.json +7 -5
  18. package/react/index.cjs +17 -9
  19. package/react/index.cjs.map +1 -1
  20. package/react/index.d.cts +5 -4
  21. package/react/index.d.ts +5 -4
  22. package/react/index.js +17 -9
  23. package/react/index.js.map +1 -1
  24. package/react/metafile-cjs.json +1 -1
  25. package/react/metafile-esm.json +1 -1
  26. package/tests/blockstore/interceptor-gateway.test.ts +15 -1
  27. package/tests/blockstore/keyed-crypto-indexeddb-file.test.ts +8 -18
  28. package/tests/blockstore/keyed-crypto.test.ts +31 -53
  29. package/tests/blockstore/loader.test.ts +21 -19
  30. package/tests/blockstore/store.test.ts +52 -56
  31. package/tests/blockstore/transaction.test.ts +13 -11
  32. package/tests/fireproof/all-gateway.test.ts +53 -50
  33. package/tests/fireproof/attachable.test.ts +356 -0
  34. package/tests/fireproof/crdt.test.ts +100 -60
  35. package/tests/fireproof/database.test.ts +95 -54
  36. package/tests/fireproof/fireproof.test.ts +58 -55
  37. package/tests/fireproof/hello.test.ts +4 -4
  38. package/tests/fireproof/indexer.test.ts +44 -44
  39. package/tests/fireproof/stable-cid.test.ts +69 -0
  40. package/tests/fireproof/utils.test.ts +21 -10
  41. package/tests/gateway/file/loader-config.test.ts +25 -25
  42. package/tests/gateway/fp-envelope-serialize.test.ts +8 -8
  43. package/tests/gateway/indexeddb/loader-config.test.ts +6 -6
  44. package/tests/helpers.ts +81 -2
  45. package/tests/react/useFireproof.test.tsx +59 -17
@@ -6,11 +6,11 @@ import { Index, index } from "@fireproof/core";
6
6
  describe("Fresh crdt", function () {
7
7
  let crdt: CRDT;
8
8
  const sthis = ensureSuperThis();
9
- afterEach(async function () {
9
+ afterEach(async () => {
10
10
  await crdt.close();
11
11
  await crdt.destroy();
12
12
  });
13
- beforeEach(async function () {
13
+ beforeEach(async () => {
14
14
  await sthis.start();
15
15
  const dbOpts: LedgerOpts = {
16
16
  name: "test-crdt",
@@ -20,17 +20,18 @@ describe("Fresh crdt", function () {
20
20
  storeEnDe: bs.ensureStoreEnDeFile({}),
21
21
  };
22
22
  crdt = new CRDTImpl(sthis, dbOpts);
23
+ await crdt.ready();
23
24
  });
24
- it("should have an empty head", async function () {
25
+ it("should have an empty head", async () => {
25
26
  const head = crdt.clock.head;
26
27
  expect(head.length).toBe(0);
27
28
  });
28
- it("should accept put and return results", async function () {
29
+ it("should accept put and return results", async () => {
29
30
  const didPut = await crdt.bulk([{ id: "hello", value: { hello: "world" } }]);
30
31
  const head = didPut.head;
31
32
  expect(head.length).toBe(1);
32
33
  });
33
- it("should accept multi-put and return results", async function () {
34
+ it("should accept multi-put and return results", async () => {
34
35
  const didPut = await crdt.bulk([
35
36
  { id: "ace", value: { points: 11 } },
36
37
  { id: "king", value: { points: 10 } },
@@ -49,12 +50,12 @@ describe("CRDT with one record", function () {
49
50
  let firstPut: CRDTMeta;
50
51
  const sthis = ensureSuperThis();
51
52
 
52
- afterEach(async function () {
53
+ afterEach(async () => {
53
54
  await crdt.close();
54
55
  await crdt.destroy();
55
56
  });
56
57
 
57
- beforeEach(async function () {
58
+ beforeEach(async () => {
58
59
  await sthis.start();
59
60
  const dbOpts: LedgerOpts = {
60
61
  name: "test-crdt",
@@ -66,32 +67,32 @@ describe("CRDT with one record", function () {
66
67
  crdt = new CRDTImpl(sthis, dbOpts);
67
68
  firstPut = await crdt.bulk([{ id: "hello", value: { hello: "world" } }]);
68
69
  });
69
- it("should have a one-element head", async function () {
70
+ it("should have a one-element head", async () => {
70
71
  const head = crdt.clock.head;
71
72
  expect(head.length).toBe(1);
72
73
  });
73
- it("should return the head", async function () {
74
+ it("should return the head", async () => {
74
75
  expect(firstPut.head.length).toBe(1);
75
76
  });
76
- it("return the record on get", async function () {
77
+ it("return the record on get", async () => {
77
78
  const got = (await crdt.get("hello")) as DocValue<CRDTTestType>;
78
79
  expect(got).toBeTruthy();
79
80
  expect(got.doc.hello).toBe("world");
80
81
  });
81
- it("should accept another put and return results", async function () {
82
+ it("should accept another put and return results", async () => {
82
83
  const didPut = await crdt.bulk([{ id: "nice", value: { nice: "data" } }]);
83
84
  const head = didPut.head;
84
85
  expect(head.length).toBe(1);
85
86
  const { doc } = (await crdt.get("nice")) as DocValue<CRDTTestType>;
86
87
  expect(doc.nice).toBe("data");
87
88
  });
88
- it("should allow for a delete", async function () {
89
+ it("should allow for a delete", async () => {
89
90
  const didDel = await crdt.bulk([{ id: "hello", del: true }]);
90
91
  expect(didDel.head).toBeTruthy();
91
92
  const got = await crdt.get("hello");
92
93
  expect(got).toBeFalsy();
93
94
  });
94
- it("should offer changes", async function () {
95
+ it("should offer changes", async () => {
95
96
  const { result } = await crdt.changes<Partial<CRDTTestType>>([]);
96
97
  expect(result.length).toBe(1);
97
98
  expect(result[0].id).toBe("hello");
@@ -107,11 +108,11 @@ describe("CRDT with a multi-write", function () {
107
108
  let firstPut: CRDTMeta;
108
109
  const sthis = ensureSuperThis();
109
110
 
110
- afterEach(async function () {
111
+ afterEach(async () => {
111
112
  await crdt.close();
112
113
  await crdt.destroy();
113
114
  });
114
- beforeEach(async function () {
115
+ beforeEach(async () => {
115
116
  await sthis.start();
116
117
  const dbOpts: LedgerOpts = {
117
118
  name: "test-crdt",
@@ -126,12 +127,12 @@ describe("CRDT with a multi-write", function () {
126
127
  { id: "king", value: { points: 10 } },
127
128
  ]);
128
129
  });
129
- it("should have a one-element head", async function () {
130
+ it("should have a one-element head", async () => {
130
131
  const head = crdt.clock.head;
131
132
  expect(head.length).toBe(1);
132
133
  expect(firstPut.head.length).toBe(1);
133
134
  });
134
- it("return the records on get", async function () {
135
+ it("return the records on get", async () => {
135
136
  const { doc } = (await crdt.get("ace")) as DocValue<CRDTTestType>;
136
137
  expect(doc.points).toBe(11);
137
138
 
@@ -139,7 +140,7 @@ describe("CRDT with a multi-write", function () {
139
140
  expect(got2).toBeTruthy();
140
141
  expect(got2.doc.points).toBe(10);
141
142
  });
142
- it("should accept another put and return results", async function () {
143
+ it("should accept another put and return results", async () => {
143
144
  const didPut = await crdt.bulk([{ id: "queen", value: { points: 10 } }]);
144
145
  const head = didPut.head;
145
146
  expect(head.length).toBe(1);
@@ -147,14 +148,14 @@ describe("CRDT with a multi-write", function () {
147
148
  expect(got).toBeTruthy();
148
149
  expect(got.doc.points).toBe(10);
149
150
  });
150
- it("should offer changes", async function () {
151
+ it("should offer changes", async () => {
151
152
  const { result } = await crdt.changes<CRDTTestType>([]);
152
153
  expect(result.length).toBe(2);
153
154
  expect(result[0].id).toBe("ace");
154
155
  expect(result[0].value?.points).toBe(11);
155
156
  expect(result[1].id).toBe("king");
156
157
  });
157
- it("should offer changes since", async function () {
158
+ it("should offer changes since", async () => {
158
159
  /** @type {CRDTMeta} */
159
160
  const secondPut = await crdt.bulk([
160
161
  { id: "queen", value: { points: 10 } },
@@ -178,7 +179,7 @@ describe("CRDT with two multi-writes", function () {
178
179
  let firstPut: CRDTMeta;
179
180
  let secondPut: CRDTMeta;
180
181
  const sthis = ensureSuperThis();
181
- afterEach(async function () {
182
+ afterEach(async () => {
182
183
  await crdt.close();
183
184
  await crdt.destroy();
184
185
  });
@@ -201,14 +202,14 @@ describe("CRDT with two multi-writes", function () {
201
202
  { id: "jack", value: { points: 10 } },
202
203
  ]);
203
204
  });
204
- it("should have a one-element head", async function () {
205
+ it("should have a one-element head", async () => {
205
206
  const head = crdt.clock.head;
206
207
  expect(head.length).toBe(1);
207
208
  expect(firstPut.head.length).toBe(1);
208
209
  expect(secondPut.head.length).toBe(1);
209
210
  expect(firstPut.head[0]).not.toBe(secondPut.head[0]);
210
211
  });
211
- it("return the records on get", async function () {
212
+ it("return the records on get", async () => {
212
213
  const ret = await crdt.get("ace");
213
214
  expect(ret).not.toBeNull();
214
215
  const { doc } = ret as DocValue<CRDTTestType>;
@@ -219,7 +220,7 @@ describe("CRDT with two multi-writes", function () {
219
220
  expect(doc.points).toBe(10);
220
221
  }
221
222
  });
222
- it("should offer changes", async function () {
223
+ it("should offer changes", async () => {
223
224
  const { result } = await crdt.changes<CRDTTestType>();
224
225
  expect(result.length).toBe(4);
225
226
  expect(result[0].id).toBe("ace");
@@ -233,17 +234,22 @@ describe("CRDT with two multi-writes", function () {
233
234
  describe("Compact a named CRDT with writes", function () {
234
235
  let crdt: CRDT;
235
236
  const sthis = ensureSuperThis();
236
- afterEach(async function () {
237
+ afterEach(async () => {
237
238
  await crdt.close();
238
239
  await crdt.destroy();
239
240
  });
240
- beforeEach(async function () {
241
+ beforeEach(async () => {
241
242
  await sthis.start();
243
+ // sthis.env.set(
244
+ // "FP_STORAGE_URL",
245
+ // BuildURI.from(sthis.env.get("FP_STORAGE_URL")).setParam(PARAM.STORE_KEY, "insecure").toString(),
246
+ // );
247
+ // console.log("FP_STORAGE_URL", sthis.env.get("FP_STORAGE_URL"));
242
248
  const dbOpts: LedgerOpts = {
243
249
  name: "test-crdt",
244
250
  writeQueue: defaultWriteQueueOpts({}),
245
251
  keyBag: rt.defaultKeyBagOpts(sthis),
246
- storeUrls: toStoreURIRuntime(sthis, `named-crdt-compaction`),
252
+ storeUrls: toStoreURIRuntime(sthis, `named-crdt-compaction-${sthis.nextId().str}`),
247
253
  storeEnDe: bs.ensureStoreEnDeFile({}),
248
254
  };
249
255
  crdt = new CRDTImpl(sthis, dbOpts);
@@ -254,25 +260,59 @@ describe("Compact a named CRDT with writes", function () {
254
260
  ];
255
261
  await crdt.bulk(bulk);
256
262
  }
263
+ // await sleep(1000);
257
264
  });
258
- it("has data", async function () {
265
+ it("has data", async () => {
259
266
  const got = (await crdt.get("ace")) as DocValue<CRDTTestType>;
260
267
  expect(got.doc).toBeTruthy();
261
268
  expect(got.doc.points).toBe(11);
262
269
  });
263
- it("should start with blocks", async function () {
270
+ it("should start with blocks", async () => {
264
271
  const blz: bs.AnyBlock[] = [];
265
272
  for await (const blk of crdt.blockstore.entries()) {
266
273
  blz.push(blk);
267
274
  }
268
- expect(blz.length).toBe(13);
269
- });
270
- it("should start with changes", async function () {
275
+ // expect(blz.map((i) => sthis.txt.decode(i.bytes) + "\n=================\n")).toEqual([
276
+ //
277
+ // ])
278
+ expect(blz.map((i) => i.cid.toString())).toEqual([
279
+ "bafyreicuomyooryb747esregkhooc4phr656tocowyo6dwcocq22h7qdhu",
280
+ "bafyreig5jhovaiocwk3vfafzdspgtwinftjygyghjzigkc554muhdmp5ba",
281
+ "bafyreiegj7yumreue7llzqroebigscedyzrkeir3zneg5q7zia77itowy4",
282
+ "bafyreihobual6tt3hgdfve4h5uzt7fey62se3dfecbuj6f4ndkkwquke4u",
283
+ "bafyreibqqcs3r6mhpr3525na6jtqnjcf6dmgskk27x4a2jb3r2qveqgexm",
284
+ "bafyreibr7udlekt4xgavn54i4zfsdlrmi4r76iq6gh3bdq4xh52px6to3e",
285
+ "bafyreidg2eyas62nvwvi6ggq44tsldj4kwmupyk2xtwmxbwf77g3noqtp4",
286
+ "bafyreigbzxzj4eh7ljfvzlc7smdextuuk7gvep5mpnb3igaj5r2qzjlfye",
287
+ "bafyreicr7takuntpofvk52xerdcoiq7wdt73ef54acoya2geig2ywkqlsi",
288
+ "bafyreihmmgm5sufvnsgjic4fbizkdbajpy2yrklyieadstbtegfr4qko2m",
289
+ "bafyreibnu44uyu3ggqwgmnlxodw6dyta3qg7e5qldsjq7bkbv452ova6oa",
290
+ "bafyreieh4nlzg7enfczmj4z7uxvgrnykh7ajw7crxjrncqfrzj47ip6t6m",
291
+ "bafyreigqqrccymfvvdfetjd2twsdzjwxbb6cn6tedqntvpgp5vboky2ol4",
292
+ "bafyreid6kkobhgdmce2cyroepyos3jwumtdrfuzi6suldlxzjsgagc3fvi",
293
+ "bafyreibo2d56wo5ldey24hygtmsfhdxsqgdpmtne5oitehxjppipru33ma",
294
+ "bafyreifjv6havcza3is7w6ii345f5akba7e34xqcxwoqozmsnihkivykum",
295
+ "bafyreig6eroqeg3y7am4bnrun3yzbvd656epzxjyivdpzwqo3j3vpuwysi",
296
+ "bafyreibpsnfsducp7refempcyqnte54j7ueh4ysdlabggihclbddfnuzxm",
297
+ "bafyreicfkkygbzz5zawr3xbfah2gy3e7w4opzysew4tini7xnksujj4gf4",
298
+ "bafyreiddjm5xkpfa5vmyhoj5opocrwo6zbdnmqyhouc5ttfxoilmaf25bm",
299
+ "bafyreibp7vlgfexaknaoxpemnnwadyfa4cfuc3euzlkslskks2n44wwspu",
300
+ "bafyreichwj7izzpxeyjkhwl26pq45m4hnhxcgzqfk5ffeqkscafleiwfzm",
301
+ "bafyreidzjjqou36q2ghqdue4buq7536w4sl5aejni6tw25mzsusl26gtwu",
302
+ "bafyreibxibqhi6wh5klrje7ne4htffeqyyqfd6y7x2no6wnhid4nixizau",
303
+ "bafyreidnvv4mwvweup5w52ddre2sl4syhvczm6ejqsmuekajowdl2cf2q4",
304
+ "bafyreihh6nbfbhgkf5lz7hhsscjgiquw426rxzr3fprbgonekzmyvirrhe",
305
+ "bafyreiejg3twlaxr7gfvvhtxrhvwaydytdv4guidmtvaz5dskm6gp73ryi",
306
+ "bafyreiblui55o25dopc5faol3umsnuohb5carto7tot4kicnkfc37he4h4",
307
+ ]);
308
+ // expect(blz.length).toBe(13);
309
+ }, 1000000);
310
+ it("should start with changes", async () => {
271
311
  const { result } = await crdt.changes();
272
312
  expect(result.length).toBe(2);
273
313
  expect(result[0].id).toBe("ace");
274
314
  });
275
- it.skip("should have fewer blocks after compact", async function () {
315
+ it.skip("should have fewer blocks after compact", async () => {
276
316
  await crdt.compact();
277
317
  const blz: bs.AnyBlock[] = [];
278
318
  for await (const blk of crdt.blockstore.entries()) {
@@ -280,13 +320,13 @@ describe("Compact a named CRDT with writes", function () {
280
320
  }
281
321
  expect(blz.length).toBe(23);
282
322
  });
283
- it("should have data after compact", async function () {
323
+ it("should have data after compact", async () => {
284
324
  await crdt.compact();
285
325
  const got = (await crdt.get("ace")) as DocValue<CRDTTestType>;
286
326
  expect(got.doc).toBeTruthy();
287
327
  expect(got.doc.points).toBe(11);
288
328
  });
289
- it("should have changes after compact", async function () {
329
+ it("should have changes after compact", async () => {
290
330
  const chs = await crdt.changes();
291
331
  expect(chs.result[0].id).toBe("ace");
292
332
  });
@@ -296,11 +336,11 @@ describe("CRDT with an index", function () {
296
336
  let crdt: CRDT;
297
337
  let idx: Index<number, CRDTTestType>;
298
338
  const sthis = ensureSuperThis();
299
- afterEach(async function () {
339
+ afterEach(async () => {
300
340
  await crdt.close();
301
341
  await crdt.destroy();
302
342
  });
303
- beforeEach(async function () {
343
+ beforeEach(async () => {
304
344
  await sthis.start();
305
345
  const dbOpts: LedgerOpts = {
306
346
  name: "test-crdt",
@@ -316,13 +356,13 @@ describe("CRDT with an index", function () {
316
356
  ]);
317
357
  idx = await index<number, CRDTTestType>(crdt, "points");
318
358
  });
319
- it("should query the data", async function () {
359
+ it("should query the data", async () => {
320
360
  const got = await idx.query({ range: [9, 12] });
321
361
  expect(got.rows.length).toBe(2);
322
362
  expect(got.rows[0].id).toBe("king");
323
363
  expect(got.rows[0].key).toBe(10);
324
364
  });
325
- it("should register the index", async function () {
365
+ it("should register the index", async () => {
326
366
  const rIdx = await index<number, CRDTTestType>(crdt, "points");
327
367
  expect(rIdx).toBeTruthy();
328
368
  expect(rIdx.name).toBe("points");
@@ -331,7 +371,7 @@ describe("CRDT with an index", function () {
331
371
  expect(got.rows[0].id).toBe("king");
332
372
  expect(got.rows[0].key).toBe(10);
333
373
  });
334
- it("creating a different index with same name should not work", async function () {
374
+ it("creating a different index with same name should not work", async () => {
335
375
  const e = await index(crdt, "points", (doc) => doc._id)
336
376
  .query()
337
377
  .catch((err) => err);
@@ -346,11 +386,11 @@ describe("Loader with a committed transaction", function () {
346
386
  let done: CRDTMeta;
347
387
  const dbname = "test-loader";
348
388
  const sthis = ensureSuperThis();
349
- afterEach(async function () {
389
+ afterEach(async () => {
350
390
  await crdt.close();
351
391
  await crdt.destroy();
352
392
  });
353
- beforeEach(async function () {
393
+ beforeEach(async () => {
354
394
  await sthis.start();
355
395
  const dbOpts: LedgerOpts = {
356
396
  name: "test-crdt",
@@ -376,16 +416,16 @@ describe("Loader with a committed transaction", function () {
376
416
  it("should commit a transaction", function () {
377
417
  expect(done.head).toBeTruthy();
378
418
  // expect(done.cars).toBeTruthy();
379
- expect(loader.carLog.length).toBe(1);
419
+ expect(loader.carLog.length).toBe(1 + 1 /* genesis */);
380
420
  });
381
421
  it("can load the car", async () => {
382
- const blk = loader.carLog[0][0];
422
+ const blk = loader.carLog.asArray()[0][0];
383
423
  expect(blk).toBeTruthy();
384
- const reader = await loader.loadCar(blk);
424
+ const reader = await loader.loadCar(blk, loader.attachedStores.local());
385
425
  expect(reader).toBeTruthy();
386
426
  const parsed = await bs.parseCarFile<CRDTMeta>(reader, loader.logger);
387
427
  expect(parsed.cars).toBeTruthy();
388
- expect(parsed.cars.length).toBe(0);
428
+ expect(parsed.cars.length).toBe(0 + 1 /* genesis */);
389
429
  expect(parsed.meta).toBeTruthy();
390
430
  expect(parsed.meta.head).toBeTruthy();
391
431
  });
@@ -398,11 +438,11 @@ describe("Loader with two committed transactions", function () {
398
438
  let done1: CRDTMeta;
399
439
  let done2: CRDTMeta;
400
440
  const sthis = ensureSuperThis();
401
- afterEach(async function () {
441
+ afterEach(async () => {
402
442
  await crdt.close();
403
443
  await crdt.destroy();
404
444
  });
405
- beforeEach(async function () {
445
+ beforeEach(async () => {
406
446
  await sthis.start();
407
447
  const dbOpts: LedgerOpts = {
408
448
  name: "test-crdt",
@@ -426,20 +466,20 @@ describe("Loader with two committed transactions", function () {
426
466
  expect(done1.head).not.toBe(done2.head);
427
467
  // expect(done1.cars).not.toBe(done2.cars);
428
468
  // expect(blockstore.transactions.size).toBe(2);
429
- expect(loader.carLog.length).toBe(2);
469
+ expect(loader.carLog.length).toBe(2 + 1 /* genesis */);
430
470
  // expect(loader.carLog.indexOf(done1.cars)).toBe(1);
431
471
  // expect(loader.carLog.map((cs) => cs.toString()).indexOf(done1.cars.toString())).toBe(1);
432
472
  // expect(loader.carLog.indexOf(done2.cars)).toBe(0);
433
473
  // expect(loader.carLog.map((cs) => cs.toString()).indexOf(done2.cars.toString())).toBe(0);
434
474
  });
435
- it("can load the car", async function () {
436
- const blk = loader.carLog[0][0];
475
+ it("can load the car", async () => {
476
+ const blk = loader.carLog.asArray()[0][0];
437
477
  expect(blk).toBeTruthy();
438
- const reader = await loader.loadCar(blk);
478
+ const reader = await loader.loadCar(blk, loader.attachedStores.local());
439
479
  expect(reader).toBeTruthy();
440
480
  const parsed = await bs.parseCarFile<CRDTMeta>(reader, loader.logger);
441
481
  expect(parsed.cars).toBeTruthy();
442
- expect(parsed.cars.length).toBe(1);
482
+ expect(parsed.cars.length).toBe(1 + 1 /* genesis */);
443
483
  expect(parsed.meta).toBeTruthy();
444
484
  expect(parsed.meta.head).toBeTruthy();
445
485
  });
@@ -452,11 +492,11 @@ describe("Loader with many committed transactions", function () {
452
492
  let dones: CRDTMeta[];
453
493
  const count = 10;
454
494
  const sthis = ensureSuperThis();
455
- afterEach(async function () {
495
+ afterEach(async () => {
456
496
  await crdt.close();
457
497
  await crdt.destroy();
458
498
  });
459
- beforeEach(async function () {
499
+ beforeEach(async () => {
460
500
  await sthis.start();
461
501
  const dbOpts: LedgerOpts = {
462
502
  name: "test-crdt",
@@ -481,16 +521,16 @@ describe("Loader with many committed transactions", function () {
481
521
  // expect(done.cars).toBeTruthy();
482
522
  }
483
523
  expect(blockstore.transactions.size).toBe(0); // cleaned up on commit
484
- expect(loader.carLog.length).toBe(count);
524
+ expect(loader.carLog.length).toBe(count + 1 /* genesis */);
485
525
  });
486
- it("can load the car", async function () {
487
- const blk = loader.carLog[2][0];
526
+ it("can load the car", async () => {
527
+ const blk = loader.carLog.asArray()[2][0];
488
528
  // expect(dones[5].cars).toBeTruthy();
489
- const reader = await loader.loadCar(blk);
529
+ const reader = await loader.loadCar(blk, loader.attachedStores.local());
490
530
  expect(reader).toBeTruthy();
491
531
  const parsed = await bs.parseCarFile<CRDTMeta>(reader, loader.logger);
492
532
  expect(parsed.cars).toBeTruthy();
493
- expect(parsed.cars.length).toBe(7);
533
+ expect(parsed.cars.length).toBe(7 + 1 /* genesis */);
494
534
  expect(parsed.meta).toBeTruthy();
495
535
  expect(parsed.meta.head).toBeTruthy();
496
536
  });