@fireproof/core-test 0.23.0 → 0.23.1-dev-issue-1057

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 (91) hide show
  1. package/blockstore/interceptor-gateway.test.js.map +1 -1
  2. package/blockstore/keyed-crypto-indexeddb-file.test.js.map +1 -1
  3. package/blockstore/keyed-crypto.test.js.map +1 -1
  4. package/blockstore/loader.test.js.map +1 -1
  5. package/blockstore/standalone.test.js.map +1 -1
  6. package/blockstore/store.test.js.map +1 -1
  7. package/blockstore/transaction.test.js.map +1 -1
  8. package/fireproof/all-gateway.test.js.map +1 -1
  9. package/fireproof/attachable.test.js.map +1 -1
  10. package/fireproof/cars/bafkreidxwt2nhvbl4fnqfw3ctlt6zbrir4kqwmjo5im6rf4q5si27kgo2i.js.map +1 -1
  11. package/fireproof/charwise-boolean.test.js.map +1 -1
  12. package/fireproof/compact-strategy.test.js.map +1 -1
  13. package/fireproof/concurrent.test.js.map +1 -1
  14. package/fireproof/crdt.test.js.map +1 -1
  15. package/fireproof/database.test.js.map +1 -1
  16. package/fireproof/deleted-docs-handling.test.js.map +1 -1
  17. package/fireproof/fireproof.test.fixture.js.map +1 -1
  18. package/fireproof/fireproof.test.js.map +1 -1
  19. package/fireproof/hello.test.js.map +1 -1
  20. package/fireproof/indexer.test.js.map +1 -1
  21. package/fireproof/multiple-ledger.test.js.map +1 -1
  22. package/fireproof/query-docs.test.js.map +1 -1
  23. package/fireproof/query-limit-issue.test.js.map +1 -1
  24. package/fireproof/query-property-inconsistency.test.js.map +1 -1
  25. package/fireproof/query-result-properties.test.js.map +1 -1
  26. package/fireproof/stable-cid.test.js.map +1 -1
  27. package/fireproof/utils.test.js.map +1 -1
  28. package/gateway/file/loader-config.test.js.map +1 -1
  29. package/gateway/indexeddb/create-db-on-write.test.js.map +1 -1
  30. package/gateway/indexeddb/loader-config.test.js.map +1 -1
  31. package/global-setup.js.map +1 -1
  32. package/helpers.js.map +1 -1
  33. package/package.json +19 -19
  34. package/protocols/cloud/msger.test.js.map +1 -1
  35. package/runtime/fp-envelope-serialize.test.js.map +1 -1
  36. package/runtime/key-bag.test.js.map +1 -1
  37. package/runtime/meta-key-hack.test.js.map +1 -1
  38. package/setup.file.js.map +1 -1
  39. package/setup.indexeddb.js.map +1 -1
  40. package/setup.memory.js.map +1 -1
  41. package/vitest.config.js.map +1 -1
  42. package/vitest.file.config.js.map +1 -1
  43. package/vitest.indexeddb.config.js.map +1 -1
  44. package/vitest.memory.config.js.map +1 -1
  45. package/blockstore/fp-envelope.test.ts-off +0 -65
  46. package/blockstore/fragment-gateway.test.ts-off +0 -106
  47. package/blockstore/interceptor-gateway.test.ts +0 -259
  48. package/blockstore/keyed-crypto-indexeddb-file.test.ts +0 -134
  49. package/blockstore/keyed-crypto.test.ts +0 -381
  50. package/blockstore/loader.test.ts +0 -313
  51. package/blockstore/standalone.test.ts +0 -156
  52. package/blockstore/store.test.ts +0 -199
  53. package/blockstore/transaction.test.ts +0 -132
  54. package/fireproof/all-gateway.test.ts +0 -477
  55. package/fireproof/attachable.test.ts +0 -677
  56. package/fireproof/cars/bafkreidxwt2nhvbl4fnqfw3ctlt6zbrir4kqwmjo5im6rf4q5si27kgo2i.car +0 -0
  57. package/fireproof/cars/bafkreidxwt2nhvbl4fnqfw3ctlt6zbrir4kqwmjo5im6rf4q5si27kgo2i.ts +0 -324
  58. package/fireproof/charwise-boolean.test.ts +0 -68
  59. package/fireproof/compact-strategy.test.ts +0 -40
  60. package/fireproof/concurrent.test.ts +0 -37
  61. package/fireproof/crdt.test.ts +0 -572
  62. package/fireproof/database.test.ts +0 -772
  63. package/fireproof/deleted-docs-handling.test.ts +0 -112
  64. package/fireproof/fireproof.test.fixture.ts +0 -133
  65. package/fireproof/fireproof.test.ts +0 -767
  66. package/fireproof/hello.test.ts +0 -75
  67. package/fireproof/indexer.test.ts +0 -459
  68. package/fireproof/multiple-ledger.test.ts +0 -67
  69. package/fireproof/query-docs.test.ts +0 -117
  70. package/fireproof/query-limit-issue.test.ts +0 -147
  71. package/fireproof/query-property-inconsistency.test.ts +0 -90
  72. package/fireproof/query-result-properties.test.ts +0 -43
  73. package/fireproof/stable-cid.test.ts +0 -72
  74. package/fireproof/utils.test.ts +0 -137
  75. package/gateway/file/loader-config.test.ts +0 -309
  76. package/gateway/indexeddb/create-db-on-write.test.ts +0 -202
  77. package/gateway/indexeddb/loader-config.test.ts +0 -80
  78. package/global-setup.ts +0 -11
  79. package/helpers.ts +0 -177
  80. package/protocols/cloud/msger.test.ts +0 -559
  81. package/runtime/fp-envelope-serialize.test.ts +0 -266
  82. package/runtime/key-bag.test.ts +0 -243
  83. package/runtime/meta-key-hack.test.ts +0 -103
  84. package/setup.file.ts +0 -1
  85. package/setup.indexeddb.ts +0 -0
  86. package/setup.memory.ts +0 -2
  87. package/tsconfig.json +0 -18
  88. package/vitest.config.ts +0 -8
  89. package/vitest.file.config.ts +0 -11
  90. package/vitest.indexeddb.config.ts +0 -34
  91. package/vitest.memory.config.ts +0 -24
@@ -1,477 +0,0 @@
1
- import { Database, Ledger, LedgerFactory, PARAM, fireproof } from "@fireproof/core";
2
-
3
- import { fileContent } from "./cars/bafkreidxwt2nhvbl4fnqfw3ctlt6zbrir4kqwmjo5im6rf4q5si27kgo2i.js";
4
- import { simpleCID } from "../helpers.js";
5
- import { BuildURI, Future } from "@adviser/cement";
6
- import { ensureSuperThis } from "@fireproof/core-runtime";
7
- import {
8
- CarStore,
9
- MetaStore,
10
- FileStore,
11
- WALStore,
12
- SerdeGateway,
13
- Loadable,
14
- FPEnvelopeTypes,
15
- WALState,
16
- SerdeGatewayCtx,
17
- FPEnvelopeMeta,
18
- UnsubscribeResult,
19
- DbMetaEvent,
20
- } from "@fireproof/core-types-blockstore";
21
- import { describe, afterEach, beforeEach, it, expect } from "vitest";
22
-
23
- describe("noop Gateway", function () {
24
- let db: Ledger;
25
- let carStore: CarStore;
26
- let metaStore: MetaStore;
27
- let fileStore: FileStore;
28
- let walStore: WALStore;
29
- let carGateway: SerdeGateway;
30
- let metaGateway: SerdeGateway;
31
- let fileGateway: SerdeGateway;
32
- let walGateway: SerdeGateway;
33
- const sthis = ensureSuperThis();
34
- let ctx: { loader: Loadable };
35
-
36
- afterEach(async () => {
37
- await db.close();
38
- await db.destroy();
39
- });
40
- beforeEach(async () => {
41
- db = LedgerFactory("test-gateway-" + sthis.nextId().str, {
42
- logger: sthis.logger,
43
- });
44
- await db.ready();
45
- ctx = { loader: db.crdt.blockstore.loader };
46
-
47
- // Extract stores from the loader
48
- carStore = ctx.loader.attachedStores.local().active.car;
49
- metaStore = ctx.loader.attachedStores.local().active.meta;
50
- fileStore = ctx.loader.attachedStores.local().active.file;
51
- walStore = ctx.loader.attachedStores.local().active.wal;
52
-
53
- // Extract and log gateways
54
- carGateway = carStore.realGateway;
55
- metaGateway = metaStore.realGateway;
56
- fileGateway = fileStore.realGateway;
57
- walGateway = walStore.realGateway;
58
- });
59
-
60
- it("should have valid stores and gateways", async () => {
61
- // Add assertions
62
- expect(carStore).toBeTruthy();
63
- expect(metaStore).toBeTruthy();
64
- expect(fileStore).toBeTruthy();
65
- expect(walStore).toBeTruthy();
66
-
67
- expect(carGateway).toBeTruthy();
68
- expect(metaGateway).toBeTruthy();
69
- expect(fileGateway).toBeTruthy();
70
- expect(walGateway).toBeTruthy();
71
- });
72
-
73
- it("should have correct store names", async () => {
74
- // Check that all stores have the correct name
75
- expect(carStore.url().getParam(PARAM.NAME)).toContain("test-gateway");
76
- expect(metaStore.url().getParam(PARAM.NAME)).toContain("test-gateway");
77
- expect(fileStore.url().getParam(PARAM.NAME)).toContain("test-gateway");
78
- expect(walStore.url().getParam(PARAM.NAME)).toContain("test-gateway");
79
- });
80
-
81
- it("should have correct store types in URLs", async () => {
82
- // Check that all stores have the correct store type in their URL
83
- expect(carStore.url().toString()).toContain("store=car");
84
- expect(carStore.url().toString()).toContain("suffix=.car");
85
- expect(metaStore.url().toString()).toContain("store=meta");
86
- expect(fileStore.url().toString()).toContain("store=file");
87
- expect(walStore.url().toString()).toContain("store=wal");
88
- });
89
-
90
- it("should have version specified in URLs", async () => {
91
- // Verify that all stores have a version specified
92
- expect(carStore.url().toString()).toContain("version=");
93
- expect(metaStore.url().toString()).toContain("version=");
94
- expect(fileStore.url().toString()).toContain("version=");
95
- expect(walStore.url().toString()).toContain("version=");
96
- });
97
-
98
- it("should have correct gateway types", async () => {
99
- // Check that all gateways are instances of the expected gateway class
100
- expect(typeof carGateway).toBe("object");
101
- expect(typeof metaGateway).toBe("object");
102
- expect(typeof fileGateway).toBe("object");
103
- expect(typeof walGateway).toBe("object");
104
- });
105
-
106
- it("should build CAR Gateway URL", async () => {
107
- const testKey = "bafkreidxwt2nhvbl4fnqfw3ctlt6zbrir4kqwmjo5im6rf4q5si27kgo2i";
108
- const carUrl = await carGateway.buildUrl(ctx, carStore.url(), testKey);
109
- expect(carUrl.Ok().hasParam("key")).toBeTruthy();
110
- });
111
-
112
- it("should start CAR Gateway", async () => {
113
- const url = await carGateway.start(ctx, carStore.url());
114
- expect(url.Ok().asObj()).toEqual(carStore.url().asObj());
115
- });
116
-
117
- it("should put data in CAR Gateway", async () => {
118
- const carUrl = await carGateway.buildUrl(ctx, carStore.url(), fileContent.cid);
119
- await carGateway.start(ctx, carStore.url());
120
- const carPutResult = await carGateway.put(ctx, carUrl.Ok(), {
121
- type: FPEnvelopeTypes.CAR,
122
- payload: fileContent.block,
123
- });
124
- expect(carPutResult.isOk()).toBeTruthy();
125
- });
126
-
127
- it("should get data from CAR Gateway", async () => {
128
- const carUrl = await carGateway.buildUrl(ctx, carStore.url(), fileContent.cid);
129
- await carGateway.start(ctx, carStore.url());
130
- await carGateway.put(ctx, carUrl.Ok(), {
131
- type: FPEnvelopeTypes.CAR,
132
- payload: fileContent.block,
133
- });
134
- const carGetResult = await carGateway.get(ctx, carUrl.Ok());
135
- expect(carGetResult.Ok().type).toEqual("car");
136
- expect(carGetResult.Ok().payload).toEqual(fileContent.block);
137
- // customExpect(carGetResult.Ok(), (v) => expect(v).toEqual(testData), "carGetResult should match testData");
138
- });
139
-
140
- it("should delete data from CAR Gateway", async () => {
141
- const carUrl = await carGateway.buildUrl(ctx, carStore.url(), fileContent.cid);
142
- await carGateway.start(ctx, carStore.url());
143
- await carGateway.put(ctx, carUrl.Ok(), {
144
- type: FPEnvelopeTypes.CAR,
145
- payload: fileContent.block,
146
- });
147
- const carDeleteResult = await carGateway.delete(ctx, carUrl.Ok());
148
- expect(carDeleteResult.isOk()).toBeTruthy();
149
- });
150
-
151
- it("should close CAR Gateway", async () => {
152
- await carGateway.close(ctx, carStore.url());
153
- });
154
- it("should build Meta Gateway URL", async () => {
155
- const metaUrl = await metaGateway.buildUrl(ctx, metaStore.url(), "main");
156
- expect(metaUrl.Ok()).toBeTruthy();
157
- });
158
-
159
- it("should start Meta Gateway", async () => {
160
- await metaGateway.start(ctx, metaStore.url());
161
- });
162
-
163
- it("should close Meta Gateway", async () => {
164
- await metaGateway.start(ctx, metaStore.url());
165
- await metaGateway.close(ctx, metaStore.url());
166
- });
167
-
168
- it("should build File Gateway URL", async () => {
169
- const fileUrl = await fileGateway.buildUrl(ctx, fileStore.url(), fileContent.cid);
170
- expect(fileUrl.Ok()).toBeTruthy();
171
- });
172
-
173
- it("should start File Gateway", async () => {
174
- await fileGateway.start(ctx, fileStore.url());
175
- });
176
-
177
- it("should put data to File Gateway", async () => {
178
- const fileUrl = await fileGateway.buildUrl(ctx, fileStore.url(), fileContent.cid);
179
- await fileGateway.start(ctx, fileStore.url());
180
- const filePutResult = await fileGateway.put(ctx, fileUrl.Ok(), {
181
- type: FPEnvelopeTypes.FILE,
182
- payload: fileContent.block,
183
- });
184
- expect(filePutResult.Ok()).toBeFalsy();
185
- });
186
-
187
- it("should get data from File Gateway", async () => {
188
- const fileUrl = await fileGateway.buildUrl(ctx, fileStore.url(), fileContent.cid);
189
- await fileGateway.start(ctx, fileStore.url());
190
- await fileGateway.put(ctx, fileUrl.Ok(), {
191
- type: FPEnvelopeTypes.FILE,
192
- payload: fileContent.block,
193
- });
194
- const fileGetResult = await fileGateway.get(ctx, fileUrl.Ok());
195
- expect(fileGetResult.Ok().type).toEqual("file");
196
- expect(fileGetResult.Ok().payload).toEqual(fileContent.block);
197
- });
198
-
199
- it("should delete data from File Gateway", async () => {
200
- const fileUrl = await fileGateway.buildUrl(ctx, fileStore.url(), fileContent.cid);
201
- await fileGateway.start(ctx, fileStore.url());
202
- await fileGateway.put(ctx, fileUrl.Ok(), {
203
- type: FPEnvelopeTypes.FILE,
204
- payload: fileContent.block,
205
- });
206
- const fileDeleteResult = await fileGateway.delete(ctx, fileUrl.Ok());
207
- expect(fileDeleteResult.isOk()).toBeTruthy();
208
- });
209
-
210
- it("should close File Gateway", async () => {
211
- await fileGateway.close(ctx, fileStore.url());
212
- });
213
- it("should build WAL Gateway URL", async () => {
214
- const testKey = "bafkreidxwt2nhvbl4fnqfw3ctlt6zbrir4kqwmjo5im6rf4q5si27kgo2i";
215
- const walUrl = await walGateway.buildUrl(ctx, walStore.url(), testKey);
216
- expect(walUrl.Ok()).toBeTruthy();
217
- });
218
-
219
- it("should start WAL Gateway", async () => {
220
- await walGateway.start(ctx, walStore.url());
221
- });
222
-
223
- it("should put data to WAL Gateway", async () => {
224
- const testKey = "bafkreidxwt2nhvbl4fnqfw3ctlt6zbrir4kqwmjo5im6rf4q5si27kgo2i";
225
- const walUrl = await walGateway.buildUrl(ctx, walStore.url(), testKey);
226
- await walGateway.start(ctx, walStore.url());
227
- // const walTestDataString = JSON.stringify();
228
- // const walTestData = sthis.txt.encode(walTestDataString);
229
- const walPutResult = await walGateway.put(ctx, walUrl.Ok(), {
230
- type: FPEnvelopeTypes.WAL,
231
- payload: {
232
- operations: [],
233
- noLoaderOps: [],
234
- fileOperations: [],
235
- },
236
- });
237
- expect(walPutResult.Ok()).toBeFalsy();
238
- });
239
-
240
- it("should get data from WAL Gateway", async () => {
241
- const testKey = "bafkreidxwt2nhvbl4fnqfw3ctlt6zbrir4kqwmjo5im6rf4q5si27kgo2i";
242
- const walUrl = await walGateway.buildUrl(ctx, walStore.url(), testKey);
243
- await walGateway.start(ctx, walStore.url());
244
- const ref: WALState = {
245
- operations: [
246
- {
247
- cars: [await simpleCID(sthis)],
248
- },
249
- ],
250
- noLoaderOps: [
251
- {
252
- cars: [await simpleCID(sthis)],
253
- },
254
- ],
255
- fileOperations: [
256
- {
257
- cid: await simpleCID(sthis),
258
- public: false,
259
- },
260
- ],
261
- };
262
- // const walTestDataString = JSON.stringify({
263
- // operations: [],
264
- // noLoaderOps: [],
265
- // fileOperations: [],
266
- // });
267
- // const walTestData = sthis.txt.encode(walTestDataString);
268
- await walGateway.put(ctx, walUrl.Ok(), {
269
- type: FPEnvelopeTypes.WAL,
270
- payload: ref,
271
- });
272
- const walGetResult = await walGateway.get(ctx, walUrl.Ok());
273
- expect(walGetResult.isOk()).toBeTruthy();
274
- // const okResult = walGetResult.Ok();
275
- // const decodedResult = sthis.txt.decode(okResult);
276
- expect(ref).toEqual(walGetResult.Ok().payload);
277
- });
278
-
279
- it("should delete data from WAL Gateway", async () => {
280
- const testKey = "bafkreidxwt2nhvbl4fnqfw3ctlt6zbrir4kqwmjo5im6rf4q5si27kgo2i";
281
- const walUrl = await walGateway.buildUrl(ctx, walStore.url(), testKey);
282
- await walGateway.start(ctx, walStore.url());
283
- const ref: WALState = {
284
- operations: [
285
- {
286
- cars: [await simpleCID(sthis)],
287
- },
288
- ],
289
- noLoaderOps: [
290
- {
291
- cars: [await simpleCID(sthis)],
292
- },
293
- ],
294
- fileOperations: [
295
- {
296
- cid: await simpleCID(sthis),
297
- public: false,
298
- },
299
- ],
300
- };
301
- await walGateway.put(ctx, walUrl.Ok(), {
302
- type: FPEnvelopeTypes.WAL,
303
- payload: ref,
304
- });
305
- const walDeleteResult = await walGateway.delete(ctx, walUrl.Ok());
306
- expect(walDeleteResult.isOk()).toBeTruthy();
307
- });
308
-
309
- it("should close WAL Gateway", async () => {
310
- await walGateway.start(ctx, walStore.url());
311
- await walGateway.close(ctx, walStore.url());
312
- });
313
-
314
- // it("should have correct CAR Gateway properties", async () =>{
315
- // // CAR Gateway assertions
316
- // expect(carGateway.fidLength).toBe(4);
317
- // expect(carGateway.headerSize).toBe(36);
318
- // carGateway.logger.Error().Msg("CAR Gateway properties");
319
- // await sthis.logger.Flush();
320
- // const last = sthis.ctx.logCollector.Logs().slice(-1)[0];
321
- // expect(last).toHaveProperty("module");
322
- // expect(carStore.).toHaveProperty("url");
323
- // });
324
-
325
- // it("should have correct Meta Gateway properties", async () =>{
326
- // // Meta Gateway assertions
327
- // expect(metaGateway.fidLength).toBe(4);
328
- // expect(metaGateway.headerSize).toBe(36);
329
- // metaGateway.logger.Error().Msg("CAR Gateway properties");
330
- // await sthis.logger.Flush();
331
- // const last = sthis.ctx.logCollector.Logs().slice(-1)[0];
332
- // expect(last).toHaveProperty("module");
333
- // expect(last).not.toHaveProperty("url");
334
- // });
335
-
336
- // it("should have correct File Gateway properties", async () =>{
337
- // // File Gateway assertions
338
- // expect(fileGateway.fidLength).toBe(4);
339
- // expect(fileGateway.headerSize).toBe(36);
340
- // fileGateway.logger.Error().Msg("CAR Gateway properties");
341
- // await sthis.logger.Flush();
342
- // const last = sthis.ctx.logCollector.Logs().slice(-1)[0];
343
- // expect(last).toHaveProperty("module");
344
- // expect(last).toHaveProperty("url");
345
- // });
346
-
347
- // it("should have correct WAL Gateway properties", async () =>{
348
- // // WAL Gateway assertions
349
- // expect(walGateway.fidLength).toBe(4);
350
- // expect(walGateway.headerSize).toBe(36);
351
- // walGateway.logger.Error().Msg("CAR Gateway properties");
352
- // await sthis.logger.Flush();
353
- // const last = sthis.ctx.logCollector.Logs().slice(-1)[0];
354
- // expect(last).toHaveProperty("module");
355
- // expect(last).not.toHaveProperty("url");
356
- // });
357
- });
358
-
359
- describe("noop Gateway subscribe", function () {
360
- let db: Database;
361
-
362
- let metaStore: MetaStore;
363
-
364
- let metaGateway: SerdeGateway;
365
- const sthis = ensureSuperThis();
366
- let ctx: SerdeGatewayCtx;
367
-
368
- afterEach(async () => {
369
- await db.close();
370
- await db.destroy();
371
- });
372
- beforeEach(async () => {
373
- db = fireproof("test-gateway-" + sthis.nextId().str);
374
- await db.close();
375
-
376
- db = fireproof("test-gateway-" + sthis.nextId().str, {
377
- storeUrls: {
378
- ...db.ledger.opts.storeUrls,
379
- data: {
380
- ...db.ledger.opts.storeUrls.data,
381
- meta: BuildURI.from(db.ledger.opts.storeUrls.data.meta).setParam(PARAM.SELF_REFLECT, "x").URI(),
382
- },
383
- },
384
- });
385
-
386
- await db.ready();
387
-
388
- ctx = { loader: db.ledger.crdt.blockstore.loader };
389
- // Extract stores from the loader
390
- metaStore = db.ledger.crdt.blockstore.loader.attachedStores.local().active.meta;
391
-
392
- metaGateway = metaStore.realGateway;
393
- });
394
- it("should subscribe to meta Gateway", async () => {
395
- const metaUrl = await metaGateway.buildUrl(ctx, metaStore.url(), "main");
396
- await metaGateway.start(ctx, metaStore.url());
397
-
398
- let didCall = false;
399
- const p = new Future<void>();
400
-
401
- const metaSubscribeResult = (await metaGateway.subscribe(
402
- ctx,
403
- metaUrl.Ok().build().setParam(PARAM.SELF_REFLECT, "x").URI(),
404
- async (data: FPEnvelopeMeta) => {
405
- // const decodedData = sthis.txt.decode(data);
406
- expect(Array.isArray(data.payload)).toBeTruthy();
407
- didCall = true;
408
- p.resolve();
409
- },
410
- )) as UnsubscribeResult;
411
- expect(metaSubscribeResult.isOk()).toBeTruthy();
412
- const ok = await db.put({ _id: "key1", hello: "world1" });
413
- expect(ok).toBeTruthy();
414
- expect(ok.id).toBe("key1");
415
- await p.asPromise();
416
- expect(didCall).toBeTruthy();
417
- });
418
- });
419
-
420
- describe("Gateway", function () {
421
- let db: Database;
422
- // let carStore: ExtendedStore;
423
- let metaStore: MetaStore;
424
- // let fileStore: ExtendedStore;
425
- // let walStore: ExtendedStore;
426
- // let carGateway: ExtendedGateway;
427
- let metaGateway: SerdeGateway;
428
- // let fileGateway: ExtendedGateway;
429
- // let walGateway: ExtendedGateway;
430
- const sthis = ensureSuperThis();
431
-
432
- let ctx: SerdeGatewayCtx;
433
-
434
- afterEach(async () => {
435
- await db.close();
436
- await db.destroy();
437
- });
438
- beforeEach(async () => {
439
- db = fireproof("test-gateway-" + sthis.nextId().str);
440
- ctx = { loader: db.ledger.crdt.blockstore.loader };
441
- const ok = await db.put({ _id: "test", foo: "bar" });
442
- expect(ok).toBeTruthy();
443
- expect(ok.id).toBe("test");
444
-
445
- // Extract stores from the loader
446
- // carStore = (await db.blockstore.loader.carStore()) as unknown as ExtendedStore;
447
- metaStore = db.ledger.crdt.blockstore.loader.attachedStores.local().active.meta;
448
- // fileStore = (await db.blockstore.loader.fileStore()) as unknown as ExtendedStore;
449
- // walStore = (await db.blockstore.loader.WALStore()) as unknown as ExtendedStore;
450
-
451
- // Extract and log gateways
452
- // carGateway = carStore.gateway;
453
- metaGateway = metaStore.realGateway;
454
- // fileGateway = fileStore.gateway;
455
- // walGateway = walStore.gateway;
456
- });
457
-
458
- it("should get data from Meta Gateway", async () => {
459
- const metaUrl = await metaGateway.buildUrl(ctx, metaStore.url(), "main");
460
- await metaGateway.start(ctx, metaStore.url());
461
- const metaGetResult = await metaGateway.get(ctx, metaUrl.Ok());
462
- expect(metaGetResult.isOk()).toBeTruthy();
463
- const meta = metaGetResult.Ok().payload as DbMetaEvent[];
464
- // const metaGetResultOk = metaGetResult.Ok();
465
- // const decodedMetaGetResultOk = sthis.txt.decode(metaGetResultOk);
466
- expect(meta.length).toBe(1);
467
- expect(Object.keys(meta[0])).toEqual(["eventCid", "parents", "dbMeta"]);
468
- });
469
-
470
- it("should delete data from Meta Gateway", async () => {
471
- const metaUrl = await metaGateway.buildUrl(ctx, metaStore.url(), "main");
472
- await metaGateway.start(ctx, metaStore.url());
473
- // should we be testing .destroy() instead?
474
- const metaDeleteResult = await metaGateway.delete(ctx, metaUrl.Ok());
475
- expect(metaDeleteResult.isOk()).toBeTruthy();
476
- });
477
- });