cojson-storage-do-sqlite 0.19.16 → 0.19.17
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 +6 -0
- package/package.json +2 -2
- package/src/tests/vitest.config.ts +1 -0
- package/tsconfig.json +1 -1
- package/dist/tests/dosqlite.d.ts +0 -89
- package/dist/tests/dosqlite.d.ts.map +0 -1
- package/dist/tests/dosqlite.js +0 -489
- package/dist/tests/dosqlite.js.map +0 -1
- package/dist/tests/dosqlite.test.d.ts +0 -2
- package/dist/tests/dosqlite.test.d.ts.map +0 -1
- package/dist/tests/dosqlite.test.js +0 -285
- package/dist/tests/dosqlite.test.js.map +0 -1
- package/dist/tests/messagesTestUtils.d.ts +0 -10
- package/dist/tests/messagesTestUtils.d.ts.map +0 -1
- package/dist/tests/messagesTestUtils.js +0 -42
- package/dist/tests/messagesTestUtils.js.map +0 -1
- package/dist/tests/testUtils.d.ts +0 -10
- package/dist/tests/testUtils.d.ts.map +0 -1
- package/dist/tests/testUtils.js +0 -88
- package/dist/tests/testUtils.js.map +0 -1
- package/dist/tests/vitest.config.d.ts +0 -3
- package/dist/tests/vitest.config.d.ts.map +0 -1
- package/dist/tests/vitest.config.js +0 -8
- package/dist/tests/vitest.config.js.map +0 -1
package/.turbo/turbo-build.log
CHANGED
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cojson-storage-do-sqlite",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.19.
|
|
4
|
+
"version": "0.19.17",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"cojson": "0.19.
|
|
9
|
+
"cojson": "0.19.17"
|
|
10
10
|
},
|
|
11
11
|
"devDependencies": {
|
|
12
12
|
"@cloudflare/workers-types": "^4.20250214.0",
|
package/tsconfig.json
CHANGED
package/dist/tests/dosqlite.d.ts
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import "jazz-tools/load-edge-wasm";
|
|
2
|
-
import { DurableObject, WorkerEntrypoint } from "cloudflare:workers";
|
|
3
|
-
import { SyncMessage } from "cojson";
|
|
4
|
-
export declare function trackMessages(): {
|
|
5
|
-
messages: {
|
|
6
|
-
from: "client" | "server" | "storage";
|
|
7
|
-
msg: SyncMessage;
|
|
8
|
-
}[];
|
|
9
|
-
restore: () => void;
|
|
10
|
-
};
|
|
11
|
-
/**
|
|
12
|
-
* Due to issues with @cloudflare/vitest-pool-workers and loading wasm modules
|
|
13
|
-
* implementing the test logic in the durable object and running full server
|
|
14
|
-
* with wrangler.
|
|
15
|
-
*
|
|
16
|
-
*/
|
|
17
|
-
export declare class DoSqlStoreTest extends DurableObject {
|
|
18
|
-
/**
|
|
19
|
-
* Test case from cojson-storage-sqlite: "should sync and load data from storage"
|
|
20
|
-
*/
|
|
21
|
-
storeLoadTest(): Promise<{
|
|
22
|
-
messageRes1: string[];
|
|
23
|
-
messageRes2: string[];
|
|
24
|
-
map2Hello: import("cojson").JsonValue | undefined;
|
|
25
|
-
}>;
|
|
26
|
-
/**
|
|
27
|
-
* Test case from cojson-storage-sqlite: "should send an empty content message if there is no content"
|
|
28
|
-
*/
|
|
29
|
-
storeLoadEmptyTest(): Promise<{
|
|
30
|
-
messageRes1: string[];
|
|
31
|
-
messageRes2: string[];
|
|
32
|
-
}>;
|
|
33
|
-
/**
|
|
34
|
-
* Test case from cojson-storage-sqlite: "should load dependencies correctly (group inheritance)"
|
|
35
|
-
*/
|
|
36
|
-
loadDependenciesTest(): Promise<{
|
|
37
|
-
messageRes1: string[];
|
|
38
|
-
messageRes2: string[];
|
|
39
|
-
mapLoaded: boolean;
|
|
40
|
-
groupLoaded: boolean;
|
|
41
|
-
parentGroupLoaded: boolean;
|
|
42
|
-
}>;
|
|
43
|
-
/**
|
|
44
|
-
* Test case from cojson-storage-sqlite: "should not send the same dependency value twice"
|
|
45
|
-
*/
|
|
46
|
-
duplicateDependencyTest(): Promise<{
|
|
47
|
-
messageRes1: string[];
|
|
48
|
-
mapLoaded: boolean;
|
|
49
|
-
mapFromParentLoaded: boolean;
|
|
50
|
-
groupLoaded: boolean;
|
|
51
|
-
parentGroupLoaded: boolean;
|
|
52
|
-
}>;
|
|
53
|
-
/**
|
|
54
|
-
* Test case from cojson-storage-sqlite: "should recover from data loss"
|
|
55
|
-
*/
|
|
56
|
-
dataLossRecoverTest(): Promise<{
|
|
57
|
-
messageRes1: string[];
|
|
58
|
-
messageRes2: string[];
|
|
59
|
-
mapContent: {
|
|
60
|
-
[x: string]: import("cojson").JsonValue | undefined;
|
|
61
|
-
};
|
|
62
|
-
}>;
|
|
63
|
-
/**
|
|
64
|
-
* Test case from cojson-storage-sqlite: "should recover missing dependencies from storage"
|
|
65
|
-
*/
|
|
66
|
-
recoverMissingDependenciesTest(): Promise<{
|
|
67
|
-
mapContent: {
|
|
68
|
-
[x: string]: import("cojson").JsonValue | undefined;
|
|
69
|
-
};
|
|
70
|
-
}>;
|
|
71
|
-
/**
|
|
72
|
-
* Test case from cojson-storage-sqlite: "should sync multiple sessions in a single content message"
|
|
73
|
-
*/
|
|
74
|
-
multipleSessionsSingleContentMessageTest(): Promise<{
|
|
75
|
-
messageRes1: string[];
|
|
76
|
-
map2Hello: import("cojson").JsonValue | undefined;
|
|
77
|
-
map3Hello: import("cojson").JsonValue | undefined;
|
|
78
|
-
}>;
|
|
79
|
-
/**
|
|
80
|
-
* Test case from cojson-storage-sqlite: "large coValue upload streaming"
|
|
81
|
-
*/
|
|
82
|
-
largeCoValueUploadTest(): Promise<{
|
|
83
|
-
messageRes1: string[];
|
|
84
|
-
}>;
|
|
85
|
-
}
|
|
86
|
-
export default class EntryPoint extends WorkerEntrypoint {
|
|
87
|
-
fetch(request: Request): Promise<Response>;
|
|
88
|
-
}
|
|
89
|
-
//# sourceMappingURL=dosqlite.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dosqlite.d.ts","sourceRoot":"","sources":["../../src/tests/dosqlite.ts"],"names":[],"mappings":"AAAA,OAAO,2BAA2B,CAAC;AACnC,OAAO,EAAO,aAAa,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC1E,OAAO,EAIL,WAAW,EAEZ,MAAM,QAAQ,CAAC;AAShB,wBAAgB,aAAa;;cAEnB,QAAQ,GAAG,QAAQ,GAAG,SAAS;aAChC,WAAW;;;EAuEnB;AAgCD;;;;;GAKG;AACH,qBAAa,cAAe,SAAQ,aAAa;IAC/C;;OAEG;IACG,aAAa;;;;;IA8DnB;;OAEG;IACG,kBAAkB;;;;IA2DxB;;OAEG;IACG,oBAAoB;;;;;;;IAoE1B;;OAEG;IACG,uBAAuB;;;;;;;IAkE7B;;OAEG;IACG,mBAAmB;;;;;;;IA8EzB;;OAEG;IACG,8BAA8B;;;;;IAmFpC;;OAEG;IACG,wCAAwC;;;;;IA8E9C;;OAEG;IACG,sBAAsB;;;CAqE7B;AAED,MAAM,CAAC,OAAO,OAAO,UAAW,SAAQ,gBAAgB;IAChD,KAAK,CAAC,OAAO,EAAE,OAAO;CAkD7B"}
|
package/dist/tests/dosqlite.js
DELETED
|
@@ -1,489 +0,0 @@
|
|
|
1
|
-
import "jazz-tools/load-edge-wasm";
|
|
2
|
-
import { env, DurableObject, WorkerEntrypoint } from "cloudflare:workers";
|
|
3
|
-
import { LocalNode, StorageApiSync, cojsonInternals, } from "cojson";
|
|
4
|
-
import { WasmCrypto } from "cojson/crypto/WasmCrypto";
|
|
5
|
-
import { toSimplifiedMessages } from "./messagesTestUtils.js";
|
|
6
|
-
import { getDurableObjectSqlStorage } from "../index.js";
|
|
7
|
-
const Crypto = await WasmCrypto.create();
|
|
8
|
-
// Adopted from cojson-storage-sqlite/src/tests/testUtils.js
|
|
9
|
-
export function trackMessages() {
|
|
10
|
-
const messages = [];
|
|
11
|
-
const originalLoad = StorageApiSync.prototype.load;
|
|
12
|
-
const originalStore = StorageApiSync.prototype.store;
|
|
13
|
-
StorageApiSync.prototype.load = async function (id, callback, done) {
|
|
14
|
-
messages.push({
|
|
15
|
-
from: "client",
|
|
16
|
-
msg: {
|
|
17
|
-
action: "load",
|
|
18
|
-
id: id,
|
|
19
|
-
header: false,
|
|
20
|
-
sessions: {},
|
|
21
|
-
},
|
|
22
|
-
});
|
|
23
|
-
return originalLoad.call(this, id, (msg) => {
|
|
24
|
-
messages.push({
|
|
25
|
-
from: "storage",
|
|
26
|
-
msg,
|
|
27
|
-
});
|
|
28
|
-
callback(msg);
|
|
29
|
-
}, done);
|
|
30
|
-
};
|
|
31
|
-
StorageApiSync.prototype.store = function (data, correctionCallback) {
|
|
32
|
-
messages.push({
|
|
33
|
-
from: "client",
|
|
34
|
-
msg: data,
|
|
35
|
-
});
|
|
36
|
-
return originalStore.call(this, data, (msg) => {
|
|
37
|
-
messages.push({
|
|
38
|
-
from: "storage",
|
|
39
|
-
msg: {
|
|
40
|
-
action: "known",
|
|
41
|
-
isCorrection: true,
|
|
42
|
-
...msg,
|
|
43
|
-
},
|
|
44
|
-
});
|
|
45
|
-
const correctionMessages = correctionCallback(msg);
|
|
46
|
-
if (correctionMessages) {
|
|
47
|
-
for (const msg of correctionMessages) {
|
|
48
|
-
messages.push({
|
|
49
|
-
from: "client",
|
|
50
|
-
msg,
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
return correctionMessages;
|
|
55
|
-
});
|
|
56
|
-
};
|
|
57
|
-
const restore = () => {
|
|
58
|
-
StorageApiSync.prototype.load = originalLoad;
|
|
59
|
-
StorageApiSync.prototype.store = originalStore;
|
|
60
|
-
messages.length = 0;
|
|
61
|
-
};
|
|
62
|
-
return {
|
|
63
|
-
messages,
|
|
64
|
-
restore,
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
function waitFor(callback) {
|
|
68
|
-
return new Promise((resolve, reject) => {
|
|
69
|
-
const checkPassed = async () => {
|
|
70
|
-
try {
|
|
71
|
-
return { ok: await callback(), error: null };
|
|
72
|
-
}
|
|
73
|
-
catch (error) {
|
|
74
|
-
return { ok: false, error };
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
let retries = 0;
|
|
78
|
-
const interval = setInterval(async () => {
|
|
79
|
-
const { ok, error } = await checkPassed();
|
|
80
|
-
if (ok !== false) {
|
|
81
|
-
clearInterval(interval);
|
|
82
|
-
resolve();
|
|
83
|
-
}
|
|
84
|
-
if (++retries > 10) {
|
|
85
|
-
clearInterval(interval);
|
|
86
|
-
reject(error);
|
|
87
|
-
}
|
|
88
|
-
}, 100);
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Due to issues with @cloudflare/vitest-pool-workers and loading wasm modules
|
|
93
|
-
* implementing the test logic in the durable object and running full server
|
|
94
|
-
* with wrangler.
|
|
95
|
-
*
|
|
96
|
-
*/
|
|
97
|
-
export class DoSqlStoreTest extends DurableObject {
|
|
98
|
-
/**
|
|
99
|
-
* Test case from cojson-storage-sqlite: "should sync and load data from storage"
|
|
100
|
-
*/
|
|
101
|
-
async storeLoadTest() {
|
|
102
|
-
const agentSecret = Crypto.newRandomAgentSecret();
|
|
103
|
-
const node1 = new LocalNode(agentSecret, Crypto.newRandomSessionID(Crypto.getAgentID(agentSecret)), Crypto);
|
|
104
|
-
const node1Sync = trackMessages();
|
|
105
|
-
const storage1 = getDurableObjectSqlStorage(this.ctx.storage);
|
|
106
|
-
node1.setStorage(storage1);
|
|
107
|
-
const group = node1.createGroup();
|
|
108
|
-
const map = group.createMap();
|
|
109
|
-
map.set("hello", "world");
|
|
110
|
-
await new Promise((resolve) => setTimeout(resolve, 200));
|
|
111
|
-
const messageRes1 = toSimplifiedMessages({
|
|
112
|
-
Map: map.core,
|
|
113
|
-
Group: group.core,
|
|
114
|
-
}, node1Sync.messages);
|
|
115
|
-
node1Sync.restore();
|
|
116
|
-
const node2 = new LocalNode(agentSecret, Crypto.newRandomSessionID(Crypto.getAgentID(agentSecret)), Crypto);
|
|
117
|
-
const node2Sync = trackMessages();
|
|
118
|
-
const storage2 = getDurableObjectSqlStorage(this.ctx.storage);
|
|
119
|
-
node2.setStorage(storage2);
|
|
120
|
-
const map2 = await node2.load(map.id);
|
|
121
|
-
if (map2 === "unavailable") {
|
|
122
|
-
throw new Error("Map is unavailable");
|
|
123
|
-
}
|
|
124
|
-
const messageRes2 = toSimplifiedMessages({
|
|
125
|
-
Map: map.core,
|
|
126
|
-
Group: group.core,
|
|
127
|
-
}, node2Sync.messages);
|
|
128
|
-
node2Sync.restore();
|
|
129
|
-
return {
|
|
130
|
-
messageRes1,
|
|
131
|
-
messageRes2,
|
|
132
|
-
map2Hello: map2.get("hello"),
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
/**
|
|
136
|
-
* Test case from cojson-storage-sqlite: "should send an empty content message if there is no content"
|
|
137
|
-
*/
|
|
138
|
-
async storeLoadEmptyTest() {
|
|
139
|
-
const agentSecret = Crypto.newRandomAgentSecret();
|
|
140
|
-
const node1 = new LocalNode(agentSecret, Crypto.newRandomSessionID(Crypto.getAgentID(agentSecret)), Crypto);
|
|
141
|
-
const node1Sync = trackMessages();
|
|
142
|
-
const storage1 = getDurableObjectSqlStorage(this.ctx.storage);
|
|
143
|
-
node1.setStorage(storage1);
|
|
144
|
-
const group = node1.createGroup();
|
|
145
|
-
const map = group.createMap();
|
|
146
|
-
await new Promise((resolve) => setTimeout(resolve, 200));
|
|
147
|
-
const messageRes1 = toSimplifiedMessages({
|
|
148
|
-
Map: map.core,
|
|
149
|
-
Group: group.core,
|
|
150
|
-
}, node1Sync.messages);
|
|
151
|
-
node1Sync.restore();
|
|
152
|
-
const node2 = new LocalNode(agentSecret, Crypto.newRandomSessionID(Crypto.getAgentID(agentSecret)), Crypto);
|
|
153
|
-
const node2Sync = trackMessages();
|
|
154
|
-
const storage2 = getDurableObjectSqlStorage(this.ctx.storage);
|
|
155
|
-
node2.setStorage(storage2);
|
|
156
|
-
const map2 = await node2.load(map.id);
|
|
157
|
-
if (map2 === "unavailable") {
|
|
158
|
-
throw new Error("Map is unavailable");
|
|
159
|
-
}
|
|
160
|
-
const messageRes2 = toSimplifiedMessages({
|
|
161
|
-
Map: map.core,
|
|
162
|
-
Group: group.core,
|
|
163
|
-
}, node2Sync.messages);
|
|
164
|
-
node2Sync.restore();
|
|
165
|
-
return {
|
|
166
|
-
messageRes1,
|
|
167
|
-
messageRes2,
|
|
168
|
-
};
|
|
169
|
-
}
|
|
170
|
-
/**
|
|
171
|
-
* Test case from cojson-storage-sqlite: "should load dependencies correctly (group inheritance)"
|
|
172
|
-
*/
|
|
173
|
-
async loadDependenciesTest() {
|
|
174
|
-
const agentSecret = Crypto.newRandomAgentSecret();
|
|
175
|
-
const node1 = new LocalNode(agentSecret, Crypto.newRandomSessionID(Crypto.getAgentID(agentSecret)), Crypto);
|
|
176
|
-
const node1Sync = trackMessages();
|
|
177
|
-
const storage1 = getDurableObjectSqlStorage(this.ctx.storage);
|
|
178
|
-
node1.setStorage(storage1);
|
|
179
|
-
const group = node1.createGroup();
|
|
180
|
-
const parentGroup = node1.createGroup();
|
|
181
|
-
group.extend(parentGroup);
|
|
182
|
-
const map = group.createMap();
|
|
183
|
-
map.set("hello", "world");
|
|
184
|
-
await new Promise((resolve) => setTimeout(resolve, 200));
|
|
185
|
-
const messageRes1 = toSimplifiedMessages({
|
|
186
|
-
Map: map.core,
|
|
187
|
-
Group: group.core,
|
|
188
|
-
ParentGroup: parentGroup.core,
|
|
189
|
-
}, node1Sync.messages);
|
|
190
|
-
node1Sync.restore();
|
|
191
|
-
const node2 = new LocalNode(agentSecret, Crypto.newRandomSessionID(Crypto.getAgentID(agentSecret)), Crypto);
|
|
192
|
-
const node2Sync = trackMessages();
|
|
193
|
-
const storage2 = getDurableObjectSqlStorage(this.ctx.storage);
|
|
194
|
-
node2.setStorage(storage2);
|
|
195
|
-
await node2.load(map.id);
|
|
196
|
-
const mapLoaded = !!node2.expectCoValueLoaded(map.id);
|
|
197
|
-
const groupLoaded = !!node2.expectCoValueLoaded(group.id);
|
|
198
|
-
const parentGroupLoaded = !!node2.expectCoValueLoaded(parentGroup.id);
|
|
199
|
-
const messageRes2 = toSimplifiedMessages({
|
|
200
|
-
Map: map.core,
|
|
201
|
-
Group: group.core,
|
|
202
|
-
ParentGroup: parentGroup.core,
|
|
203
|
-
}, node2Sync.messages);
|
|
204
|
-
return {
|
|
205
|
-
messageRes1,
|
|
206
|
-
messageRes2,
|
|
207
|
-
mapLoaded,
|
|
208
|
-
groupLoaded,
|
|
209
|
-
parentGroupLoaded,
|
|
210
|
-
};
|
|
211
|
-
}
|
|
212
|
-
/**
|
|
213
|
-
* Test case from cojson-storage-sqlite: "should not send the same dependency value twice"
|
|
214
|
-
*/
|
|
215
|
-
async duplicateDependencyTest() {
|
|
216
|
-
const agentSecret = Crypto.newRandomAgentSecret();
|
|
217
|
-
const node1 = new LocalNode(agentSecret, Crypto.newRandomSessionID(Crypto.getAgentID(agentSecret)), Crypto);
|
|
218
|
-
const node1Sync = trackMessages();
|
|
219
|
-
const storage1 = getDurableObjectSqlStorage(this.ctx.storage);
|
|
220
|
-
node1.setStorage(storage1);
|
|
221
|
-
const group = node1.createGroup();
|
|
222
|
-
const parentGroup = node1.createGroup();
|
|
223
|
-
group.extend(parentGroup);
|
|
224
|
-
const mapFromParent = parentGroup.createMap();
|
|
225
|
-
const map = group.createMap();
|
|
226
|
-
map.set("hello", "world");
|
|
227
|
-
mapFromParent.set("hello", "world");
|
|
228
|
-
await new Promise((resolve) => setTimeout(resolve, 200));
|
|
229
|
-
node1Sync.restore();
|
|
230
|
-
const node2 = new LocalNode(agentSecret, Crypto.newRandomSessionID(Crypto.getAgentID(agentSecret)), Crypto);
|
|
231
|
-
const node2Sync = trackMessages();
|
|
232
|
-
const storage2 = getDurableObjectSqlStorage(this.ctx.storage);
|
|
233
|
-
node2.setStorage(storage2);
|
|
234
|
-
await node2.load(map.id);
|
|
235
|
-
await node2.load(mapFromParent.id);
|
|
236
|
-
const mapLoaded = !!node2.expectCoValueLoaded(map.id);
|
|
237
|
-
const mapFromParentLoaded = !!node2.expectCoValueLoaded(mapFromParent.id);
|
|
238
|
-
const groupLoaded = !!node2.expectCoValueLoaded(group.id);
|
|
239
|
-
const parentGroupLoaded = !!node2.expectCoValueLoaded(parentGroup.id);
|
|
240
|
-
const messageRes1 = toSimplifiedMessages({
|
|
241
|
-
Map: map.core,
|
|
242
|
-
Group: group.core,
|
|
243
|
-
ParentGroup: parentGroup.core,
|
|
244
|
-
MapFromParent: mapFromParent.core,
|
|
245
|
-
}, node2Sync.messages);
|
|
246
|
-
return {
|
|
247
|
-
messageRes1,
|
|
248
|
-
mapLoaded,
|
|
249
|
-
mapFromParentLoaded,
|
|
250
|
-
groupLoaded,
|
|
251
|
-
parentGroupLoaded,
|
|
252
|
-
};
|
|
253
|
-
}
|
|
254
|
-
/**
|
|
255
|
-
* Test case from cojson-storage-sqlite: "should recover from data loss"
|
|
256
|
-
*/
|
|
257
|
-
async dataLossRecoverTest() {
|
|
258
|
-
const agentSecret = Crypto.newRandomAgentSecret();
|
|
259
|
-
const node1 = new LocalNode(agentSecret, Crypto.newRandomSessionID(Crypto.getAgentID(agentSecret)), Crypto);
|
|
260
|
-
const node1Sync = trackMessages();
|
|
261
|
-
const storage1 = getDurableObjectSqlStorage(this.ctx.storage);
|
|
262
|
-
node1.setStorage(storage1);
|
|
263
|
-
const group = node1.createGroup();
|
|
264
|
-
const map = group.createMap();
|
|
265
|
-
map.set("0", 0);
|
|
266
|
-
await new Promise((resolve) => setTimeout(resolve, 200));
|
|
267
|
-
const originalStore = StorageApiSync.prototype.store;
|
|
268
|
-
StorageApiSync.prototype.store = () => false;
|
|
269
|
-
map.set("1", 1);
|
|
270
|
-
map.set("2", 2);
|
|
271
|
-
await new Promise((resolve) => setTimeout(resolve, 200));
|
|
272
|
-
StorageApiSync.prototype.store = originalStore;
|
|
273
|
-
map.set("3", 3);
|
|
274
|
-
await new Promise((resolve) => setTimeout(resolve, 200));
|
|
275
|
-
const messageRes1 = toSimplifiedMessages({
|
|
276
|
-
Map: map.core,
|
|
277
|
-
Group: group.core,
|
|
278
|
-
}, node1Sync.messages);
|
|
279
|
-
node1Sync.restore();
|
|
280
|
-
const node2 = new LocalNode(agentSecret, Crypto.newRandomSessionID(Crypto.getAgentID(agentSecret)), Crypto);
|
|
281
|
-
const node2Sync = trackMessages();
|
|
282
|
-
const storage2 = getDurableObjectSqlStorage(this.ctx.storage);
|
|
283
|
-
node2.setStorage(storage2);
|
|
284
|
-
const map2 = await node2.load(map.id);
|
|
285
|
-
if (map2 === "unavailable") {
|
|
286
|
-
throw new Error("Map is unavailable");
|
|
287
|
-
}
|
|
288
|
-
const mapContent = map2.toJSON();
|
|
289
|
-
const messageRes2 = toSimplifiedMessages({
|
|
290
|
-
Map: map.core,
|
|
291
|
-
Group: group.core,
|
|
292
|
-
}, node2Sync.messages);
|
|
293
|
-
return {
|
|
294
|
-
messageRes1,
|
|
295
|
-
messageRes2,
|
|
296
|
-
mapContent,
|
|
297
|
-
};
|
|
298
|
-
}
|
|
299
|
-
/**
|
|
300
|
-
* Test case from cojson-storage-sqlite: "should recover missing dependencies from storage"
|
|
301
|
-
*/
|
|
302
|
-
async recoverMissingDependenciesTest() {
|
|
303
|
-
const agentSecret = Crypto.newRandomAgentSecret();
|
|
304
|
-
const account = LocalNode.internalCreateAccount({
|
|
305
|
-
crypto: Crypto,
|
|
306
|
-
});
|
|
307
|
-
const node1 = account.core.node;
|
|
308
|
-
const serverNode = new LocalNode(agentSecret, Crypto.newRandomSessionID(Crypto.getAgentID(agentSecret)), Crypto);
|
|
309
|
-
const [serverPeer, clientPeer] = cojsonInternals.connectedPeers(node1.agentSecret, serverNode.agentSecret, {
|
|
310
|
-
peer1role: "server",
|
|
311
|
-
peer2role: "client",
|
|
312
|
-
});
|
|
313
|
-
node1.syncManager.addPeer(serverPeer);
|
|
314
|
-
serverNode.syncManager.addPeer(clientPeer);
|
|
315
|
-
// manual mock
|
|
316
|
-
const originalStore = StorageApiSync.prototype.store;
|
|
317
|
-
StorageApiSync.prototype.store = function (data, correctionCallback) {
|
|
318
|
-
if ([group.core.id, account.core.id].includes(data.id)) {
|
|
319
|
-
return false;
|
|
320
|
-
}
|
|
321
|
-
return originalStore.call(this, data, correctionCallback);
|
|
322
|
-
};
|
|
323
|
-
const storage1 = getDurableObjectSqlStorage(this.ctx.storage);
|
|
324
|
-
node1.setStorage(storage1);
|
|
325
|
-
const group = node1.createGroup();
|
|
326
|
-
group.addMember("everyone", "writer");
|
|
327
|
-
const map = group.createMap();
|
|
328
|
-
map.set("0", 0);
|
|
329
|
-
StorageApiSync.prototype.store = originalStore;
|
|
330
|
-
await new Promise((resolve) => setTimeout(resolve, 200));
|
|
331
|
-
const node2 = new LocalNode(Crypto.newRandomAgentSecret(), Crypto.newRandomSessionID(Crypto.getAgentID(agentSecret)), Crypto);
|
|
332
|
-
const [serverPeer2, clientPeer2] = cojsonInternals.connectedPeers(node1.agentSecret, serverNode.agentSecret, {
|
|
333
|
-
peer1role: "server",
|
|
334
|
-
peer2role: "client",
|
|
335
|
-
});
|
|
336
|
-
node2.syncManager.addPeer(serverPeer2);
|
|
337
|
-
serverNode.syncManager.addPeer(clientPeer2);
|
|
338
|
-
const storage2 = getDurableObjectSqlStorage(this.ctx.storage);
|
|
339
|
-
node2.setStorage(storage2);
|
|
340
|
-
const map2 = await node2.load(map.id);
|
|
341
|
-
if (map2 === "unavailable") {
|
|
342
|
-
throw new Error("Map is unavailable");
|
|
343
|
-
}
|
|
344
|
-
const mapContent = map2.toJSON();
|
|
345
|
-
return {
|
|
346
|
-
mapContent,
|
|
347
|
-
};
|
|
348
|
-
}
|
|
349
|
-
/**
|
|
350
|
-
* Test case from cojson-storage-sqlite: "should sync multiple sessions in a single content message"
|
|
351
|
-
*/
|
|
352
|
-
async multipleSessionsSingleContentMessageTest() {
|
|
353
|
-
const agentSecret = Crypto.newRandomAgentSecret();
|
|
354
|
-
const node1 = new LocalNode(agentSecret, Crypto.newRandomSessionID(Crypto.getAgentID(agentSecret)), Crypto);
|
|
355
|
-
const storage1 = getDurableObjectSqlStorage(this.ctx.storage);
|
|
356
|
-
node1.setStorage(storage1);
|
|
357
|
-
const group = node1.createGroup();
|
|
358
|
-
const map = group.createMap();
|
|
359
|
-
map.set("hello", "world");
|
|
360
|
-
await new Promise((resolve) => setTimeout(resolve, 200));
|
|
361
|
-
node1.gracefulShutdown();
|
|
362
|
-
const node2 = new LocalNode(agentSecret, Crypto.newRandomSessionID(Crypto.getAgentID(agentSecret)), Crypto);
|
|
363
|
-
const storage2 = getDurableObjectSqlStorage(this.ctx.storage);
|
|
364
|
-
node2.setStorage(storage2);
|
|
365
|
-
const map2 = await node2.load(map.id);
|
|
366
|
-
if (map2 === "unavailable") {
|
|
367
|
-
throw new Error("Map is unavailable");
|
|
368
|
-
}
|
|
369
|
-
const map2Hello = map2.get("hello");
|
|
370
|
-
map2.set("hello", "world2");
|
|
371
|
-
await map2.core.waitForSync();
|
|
372
|
-
node2.gracefulShutdown();
|
|
373
|
-
const node3 = new LocalNode(agentSecret, Crypto.newRandomSessionID(Crypto.getAgentID(agentSecret)), Crypto);
|
|
374
|
-
const node3Sync = trackMessages();
|
|
375
|
-
const storage3 = getDurableObjectSqlStorage(this.ctx.storage);
|
|
376
|
-
node3.setStorage(storage3);
|
|
377
|
-
const map3 = await node3.load(map.id);
|
|
378
|
-
if (map3 === "unavailable") {
|
|
379
|
-
throw new Error("Map is unavailable");
|
|
380
|
-
}
|
|
381
|
-
const map3Hello = map3.get("hello");
|
|
382
|
-
const messageRes1 = toSimplifiedMessages({
|
|
383
|
-
Map: map.core,
|
|
384
|
-
Group: group.core,
|
|
385
|
-
}, node3Sync.messages);
|
|
386
|
-
node3Sync.restore();
|
|
387
|
-
return {
|
|
388
|
-
messageRes1,
|
|
389
|
-
map2Hello,
|
|
390
|
-
map3Hello,
|
|
391
|
-
};
|
|
392
|
-
}
|
|
393
|
-
/**
|
|
394
|
-
* Test case from cojson-storage-sqlite: "large coValue upload streaming"
|
|
395
|
-
*/
|
|
396
|
-
async largeCoValueUploadTest() {
|
|
397
|
-
const agentSecret = Crypto.newRandomAgentSecret();
|
|
398
|
-
const node1 = new LocalNode(agentSecret, Crypto.newRandomSessionID(Crypto.getAgentID(agentSecret)), Crypto);
|
|
399
|
-
const storage1 = getDurableObjectSqlStorage(this.ctx.storage);
|
|
400
|
-
node1.setStorage(storage1);
|
|
401
|
-
const group = node1.createGroup();
|
|
402
|
-
const largeMap = group.createMap();
|
|
403
|
-
const dataSize = 1 * 1024 * 200;
|
|
404
|
-
const chunkSize = 1024; // 1KB chunks
|
|
405
|
-
const chunks = dataSize / chunkSize;
|
|
406
|
-
const value = "a".repeat(chunkSize);
|
|
407
|
-
for (let i = 0; i < chunks; i++) {
|
|
408
|
-
const key = `key${i}`;
|
|
409
|
-
largeMap.set(key, value, "trusting");
|
|
410
|
-
}
|
|
411
|
-
await largeMap.core.waitForSync();
|
|
412
|
-
node1.gracefulShutdown();
|
|
413
|
-
const node2 = new LocalNode(agentSecret, Crypto.newRandomSessionID(Crypto.getAgentID(agentSecret)), Crypto);
|
|
414
|
-
const node2Sync = trackMessages();
|
|
415
|
-
const storage2 = getDurableObjectSqlStorage(this.ctx.storage);
|
|
416
|
-
node2.setStorage(storage2);
|
|
417
|
-
const largeMapOnNode2 = await node2.load(largeMap.id);
|
|
418
|
-
if (largeMapOnNode2 === "unavailable") {
|
|
419
|
-
throw new Error("Map is unavailable");
|
|
420
|
-
}
|
|
421
|
-
await waitFor(() => {
|
|
422
|
-
if (JSON.stringify(largeMapOnNode2.core.knownState()) !==
|
|
423
|
-
JSON.stringify(largeMap.core.knownState())) {
|
|
424
|
-
throw new Error("Map states are not equal");
|
|
425
|
-
}
|
|
426
|
-
return true;
|
|
427
|
-
});
|
|
428
|
-
const messageRes1 = toSimplifiedMessages({
|
|
429
|
-
Map: largeMap.core,
|
|
430
|
-
Group: group.core,
|
|
431
|
-
}, node2Sync.messages);
|
|
432
|
-
return {
|
|
433
|
-
messageRes1,
|
|
434
|
-
};
|
|
435
|
-
}
|
|
436
|
-
}
|
|
437
|
-
export default class EntryPoint extends WorkerEntrypoint {
|
|
438
|
-
async fetch(request) {
|
|
439
|
-
if (request.method !== "POST") {
|
|
440
|
-
return new Response("Method not allowed", { status: 405 });
|
|
441
|
-
}
|
|
442
|
-
const path = new URL(request.url).pathname;
|
|
443
|
-
const body = await request.json();
|
|
444
|
-
if (!(typeof body === "object" &&
|
|
445
|
-
body !== null &&
|
|
446
|
-
"doId" in body &&
|
|
447
|
-
typeof body.doId === "string")) {
|
|
448
|
-
throw new Error("Invalid request body");
|
|
449
|
-
}
|
|
450
|
-
const stub = env.DoSqlStoreTest.getByName(body.doId);
|
|
451
|
-
if (path === "/sync-and-load") {
|
|
452
|
-
const res = await stub.storeLoadTest();
|
|
453
|
-
// @ts-expect-error ts2589 the type initiation is too deep
|
|
454
|
-
return Response.json(res);
|
|
455
|
-
}
|
|
456
|
-
else if (path === "/sync-and-load-empty") {
|
|
457
|
-
const res = await stub.storeLoadEmptyTest();
|
|
458
|
-
return Response.json(res);
|
|
459
|
-
}
|
|
460
|
-
else if (path === "/group-load") {
|
|
461
|
-
const res = await stub.loadDependenciesTest();
|
|
462
|
-
return Response.json(res);
|
|
463
|
-
}
|
|
464
|
-
else if (path === "/group-load-duplicate") {
|
|
465
|
-
const res = await stub.duplicateDependencyTest();
|
|
466
|
-
return Response.json(res);
|
|
467
|
-
}
|
|
468
|
-
else if (path === "/data-loss-recovery") {
|
|
469
|
-
const res = await stub.dataLossRecoverTest();
|
|
470
|
-
return Response.json(res);
|
|
471
|
-
}
|
|
472
|
-
else if (path === "/missing-dependency-recovery") {
|
|
473
|
-
const res = await stub.recoverMissingDependenciesTest();
|
|
474
|
-
return Response.json(res);
|
|
475
|
-
}
|
|
476
|
-
else if (path === "/multiple-sessions") {
|
|
477
|
-
const res = await stub.multipleSessionsSingleContentMessageTest();
|
|
478
|
-
return Response.json(res);
|
|
479
|
-
}
|
|
480
|
-
else if (path === "/large-covalue-upload") {
|
|
481
|
-
const res = await stub.largeCoValueUploadTest();
|
|
482
|
-
return Response.json(res);
|
|
483
|
-
}
|
|
484
|
-
else {
|
|
485
|
-
return new Response("Invalid test method", { status: 400 });
|
|
486
|
-
}
|
|
487
|
-
}
|
|
488
|
-
}
|
|
489
|
-
//# sourceMappingURL=dosqlite.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dosqlite.js","sourceRoot":"","sources":["../../src/tests/dosqlite.ts"],"names":[],"mappings":"AAAA,OAAO,2BAA2B,CAAC;AACnC,OAAO,EAAE,GAAG,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC1E,OAAO,EACL,SAAS,EAET,cAAc,EAEd,eAAe,GAChB,MAAM,QAAQ,CAAC;AAChB,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAEtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC;AAEzD,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,MAAM,EAAE,CAAC;AAEzC,4DAA4D;AAC5D,MAAM,UAAU,aAAa;IAC3B,MAAM,QAAQ,GAGR,EAAE,CAAC;IAET,MAAM,YAAY,GAAG,cAAc,CAAC,SAAS,CAAC,IAAI,CAAC;IACnD,MAAM,aAAa,GAAG,cAAc,CAAC,SAAS,CAAC,KAAK,CAAC;IAErD,cAAc,CAAC,SAAS,CAAC,IAAI,GAAG,KAAK,WAAW,EAAE,EAAE,QAAQ,EAAE,IAAI;QAChE,QAAQ,CAAC,IAAI,CAAC;YACZ,IAAI,EAAE,QAAQ;YACd,GAAG,EAAE;gBACH,MAAM,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,CAAC;CACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dosqlite.test.d.ts","sourceRoot":"","sources":["../../src/tests/dosqlite.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,285 +0,0 @@
|
|
|
1
|
-
import { dirname, join } from "path";
|
|
2
|
-
import { randomUUID } from "node:crypto";
|
|
3
|
-
import { fileURLToPath } from "url";
|
|
4
|
-
import { execa } from "execa";
|
|
5
|
-
import { afterAll, beforeAll, describe, expect, test } from "vitest";
|
|
6
|
-
// @ts-ignore
|
|
7
|
-
const currentDir = dirname(fileURLToPath(import.meta.url));
|
|
8
|
-
const packageRoot = join(currentDir, "../..");
|
|
9
|
-
const projectRoot = join(packageRoot, "../..");
|
|
10
|
-
describe("Cloudflare DurableObject SQL storage", () => {
|
|
11
|
-
let server;
|
|
12
|
-
let url;
|
|
13
|
-
beforeAll(async () => {
|
|
14
|
-
server = execa(join(projectRoot, "node_modules/.bin/wrangler"), ["dev"], {
|
|
15
|
-
cwd: currentDir,
|
|
16
|
-
});
|
|
17
|
-
// Wait for server to be ready
|
|
18
|
-
url = await new Promise((resolve, reject) => {
|
|
19
|
-
server.stdout?.on("data", (data) => {
|
|
20
|
-
console.log("stdout server:", data.toString());
|
|
21
|
-
if (data.toString().includes("Ready on http://localhost:")) {
|
|
22
|
-
resolve(new URL(data.toString().split("Ready on ")[1].trim()));
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
server.stderr?.on("data", (data) => {
|
|
26
|
-
console.log("stderr server:", data.toString());
|
|
27
|
-
});
|
|
28
|
-
// Reject if server fails to start within 10 seconds
|
|
29
|
-
setTimeout(() => {
|
|
30
|
-
reject(new Error("Server failed to start within timeout"));
|
|
31
|
-
}, 10000);
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
afterAll(async () => {
|
|
35
|
-
server.kill();
|
|
36
|
-
});
|
|
37
|
-
test("should sync and load data from storage", async () => {
|
|
38
|
-
const doId = randomUUID();
|
|
39
|
-
const res = await fetch(`${url}sync-and-load`, {
|
|
40
|
-
method: "POST",
|
|
41
|
-
headers: {
|
|
42
|
-
"Content-Type": "application/json",
|
|
43
|
-
},
|
|
44
|
-
body: JSON.stringify({ doId }),
|
|
45
|
-
});
|
|
46
|
-
const json = (await res.json());
|
|
47
|
-
if (!(typeof json === "object" &&
|
|
48
|
-
json !== null &&
|
|
49
|
-
"messageRes1" in json &&
|
|
50
|
-
"messageRes2" in json &&
|
|
51
|
-
"map2Hello" in json)) {
|
|
52
|
-
throw new Error("Invalid response");
|
|
53
|
-
}
|
|
54
|
-
expect(json.messageRes1).toMatchInlineSnapshot(`
|
|
55
|
-
[
|
|
56
|
-
"client -> CONTENT Group header: true new: After: 0 New: 3",
|
|
57
|
-
"client -> CONTENT Map header: true new: After: 0 New: 1",
|
|
58
|
-
]
|
|
59
|
-
`);
|
|
60
|
-
expect(json.map2Hello).toEqual("world");
|
|
61
|
-
expect(json.messageRes2).toMatchInlineSnapshot(`
|
|
62
|
-
[
|
|
63
|
-
"client -> LOAD Map sessions: empty",
|
|
64
|
-
"storage -> CONTENT Group header: true new: After: 0 New: 3",
|
|
65
|
-
"storage -> CONTENT Map header: true new: After: 0 New: 1",
|
|
66
|
-
]
|
|
67
|
-
`);
|
|
68
|
-
});
|
|
69
|
-
test("should send an empty content message if there is no content", async () => {
|
|
70
|
-
const doId = randomUUID();
|
|
71
|
-
const res = await fetch(`${url}sync-and-load-empty`, {
|
|
72
|
-
method: "POST",
|
|
73
|
-
headers: {
|
|
74
|
-
"Content-Type": "application/json",
|
|
75
|
-
},
|
|
76
|
-
body: JSON.stringify({ doId }),
|
|
77
|
-
});
|
|
78
|
-
const json = (await res.json());
|
|
79
|
-
if (!(typeof json === "object" &&
|
|
80
|
-
json !== null &&
|
|
81
|
-
"messageRes1" in json &&
|
|
82
|
-
"messageRes2" in json)) {
|
|
83
|
-
throw new Error("Invalid response");
|
|
84
|
-
}
|
|
85
|
-
expect(json.messageRes1).toMatchInlineSnapshot(`
|
|
86
|
-
[
|
|
87
|
-
"client -> CONTENT Group header: true new: After: 0 New: 3",
|
|
88
|
-
"client -> CONTENT Map header: true new: ",
|
|
89
|
-
]
|
|
90
|
-
`);
|
|
91
|
-
expect(json.messageRes2).toMatchInlineSnapshot(`
|
|
92
|
-
[
|
|
93
|
-
"client -> LOAD Map sessions: empty",
|
|
94
|
-
"storage -> CONTENT Group header: true new: After: 0 New: 3",
|
|
95
|
-
"storage -> CONTENT Map header: true new: ",
|
|
96
|
-
]
|
|
97
|
-
`);
|
|
98
|
-
});
|
|
99
|
-
test("should load dependencies correctly (group inheritance)", async () => {
|
|
100
|
-
const doId = randomUUID();
|
|
101
|
-
const res = await fetch(`${url}group-load`, {
|
|
102
|
-
method: "POST",
|
|
103
|
-
headers: {
|
|
104
|
-
"Content-Type": "application/json",
|
|
105
|
-
},
|
|
106
|
-
body: JSON.stringify({ doId }),
|
|
107
|
-
});
|
|
108
|
-
const json = (await res.json());
|
|
109
|
-
if (!(typeof json === "object" &&
|
|
110
|
-
json !== null &&
|
|
111
|
-
"messageRes1" in json &&
|
|
112
|
-
"messageRes2" in json &&
|
|
113
|
-
"mapLoaded" in json &&
|
|
114
|
-
"groupLoaded" in json &&
|
|
115
|
-
"parentGroupLoaded" in json)) {
|
|
116
|
-
throw new Error("Invalid response");
|
|
117
|
-
}
|
|
118
|
-
expect(json.messageRes1).toMatchInlineSnapshot(`
|
|
119
|
-
[
|
|
120
|
-
"client -> CONTENT Group header: true new: After: 0 New: 3",
|
|
121
|
-
"client -> CONTENT ParentGroup header: true new: After: 0 New: 3",
|
|
122
|
-
"client -> CONTENT Group header: false new: After: 3 New: 2",
|
|
123
|
-
"client -> CONTENT Map header: true new: After: 0 New: 1",
|
|
124
|
-
]
|
|
125
|
-
`);
|
|
126
|
-
expect(json.mapLoaded).toBeTruthy();
|
|
127
|
-
expect(json.groupLoaded).toBeTruthy();
|
|
128
|
-
expect(json.parentGroupLoaded).toBeTruthy();
|
|
129
|
-
expect(json.messageRes2).toMatchInlineSnapshot(`
|
|
130
|
-
[
|
|
131
|
-
"client -> LOAD Map sessions: empty",
|
|
132
|
-
"storage -> CONTENT ParentGroup header: true new: After: 0 New: 3",
|
|
133
|
-
"storage -> CONTENT Group header: true new: After: 0 New: 5",
|
|
134
|
-
"storage -> CONTENT Map header: true new: After: 0 New: 1",
|
|
135
|
-
]
|
|
136
|
-
`);
|
|
137
|
-
});
|
|
138
|
-
test("should not send the same dependency value twice", async () => {
|
|
139
|
-
const doId = randomUUID();
|
|
140
|
-
const res = await fetch(`${url}group-load-duplicate`, {
|
|
141
|
-
method: "POST",
|
|
142
|
-
headers: {
|
|
143
|
-
"Content-Type": "application/json",
|
|
144
|
-
},
|
|
145
|
-
body: JSON.stringify({ doId }),
|
|
146
|
-
});
|
|
147
|
-
const json = (await res.json());
|
|
148
|
-
if (!(typeof json === "object" &&
|
|
149
|
-
json !== null &&
|
|
150
|
-
"messageRes1" in json &&
|
|
151
|
-
"mapLoaded" in json &&
|
|
152
|
-
"mapFromParentLoaded" in json &&
|
|
153
|
-
"groupLoaded" in json &&
|
|
154
|
-
"parentGroupLoaded" in json)) {
|
|
155
|
-
console.log(json);
|
|
156
|
-
throw new Error("Invalid response");
|
|
157
|
-
}
|
|
158
|
-
expect(json.mapLoaded).toBeTruthy();
|
|
159
|
-
expect(json.mapFromParentLoaded).toBeTruthy();
|
|
160
|
-
expect(json.groupLoaded).toBeTruthy();
|
|
161
|
-
expect(json.parentGroupLoaded).toBeTruthy();
|
|
162
|
-
expect(json.messageRes1).toMatchInlineSnapshot(`
|
|
163
|
-
[
|
|
164
|
-
"client -> LOAD Map sessions: empty",
|
|
165
|
-
"storage -> CONTENT ParentGroup header: true new: After: 0 New: 3",
|
|
166
|
-
"storage -> CONTENT Group header: true new: After: 0 New: 5",
|
|
167
|
-
"storage -> CONTENT Map header: true new: After: 0 New: 1",
|
|
168
|
-
"client -> LOAD MapFromParent sessions: empty",
|
|
169
|
-
"storage -> CONTENT MapFromParent header: true new: After: 0 New: 1",
|
|
170
|
-
]
|
|
171
|
-
`);
|
|
172
|
-
});
|
|
173
|
-
test("should recover from data loss", async () => {
|
|
174
|
-
const doId = randomUUID();
|
|
175
|
-
const res = await fetch(`${url}data-loss-recovery`, {
|
|
176
|
-
method: "POST",
|
|
177
|
-
headers: {
|
|
178
|
-
"Content-Type": "application/json",
|
|
179
|
-
},
|
|
180
|
-
body: JSON.stringify({ doId }),
|
|
181
|
-
});
|
|
182
|
-
const json = (await res.json());
|
|
183
|
-
if (!(typeof json === "object" &&
|
|
184
|
-
json !== null &&
|
|
185
|
-
"messageRes1" in json &&
|
|
186
|
-
"messageRes2" in json &&
|
|
187
|
-
"mapContent" in json)) {
|
|
188
|
-
console.log(json);
|
|
189
|
-
throw new Error("Invalid response");
|
|
190
|
-
}
|
|
191
|
-
expect(json.messageRes1).toMatchInlineSnapshot(`
|
|
192
|
-
[
|
|
193
|
-
"client -> CONTENT Group header: true new: After: 0 New: 3",
|
|
194
|
-
"client -> CONTENT Map header: true new: After: 0 New: 1",
|
|
195
|
-
"client -> CONTENT Map header: false new: After: 3 New: 1",
|
|
196
|
-
"storage -> KNOWN CORRECTION Map sessions: header/4",
|
|
197
|
-
"client -> CONTENT Map header: false new: After: 1 New: 3",
|
|
198
|
-
]
|
|
199
|
-
`);
|
|
200
|
-
expect(json.mapContent).toEqual({
|
|
201
|
-
"0": 0,
|
|
202
|
-
"1": 1,
|
|
203
|
-
"2": 2,
|
|
204
|
-
"3": 3,
|
|
205
|
-
});
|
|
206
|
-
expect(json.messageRes2).toMatchInlineSnapshot(`
|
|
207
|
-
[
|
|
208
|
-
"client -> LOAD Map sessions: empty",
|
|
209
|
-
"storage -> CONTENT Group header: true new: After: 0 New: 3",
|
|
210
|
-
"storage -> CONTENT Map header: true new: After: 0 New: 4",
|
|
211
|
-
]
|
|
212
|
-
`);
|
|
213
|
-
});
|
|
214
|
-
test("should recover missing dependencies from storage", async () => {
|
|
215
|
-
const doId = randomUUID();
|
|
216
|
-
const res = await fetch(`${url}missing-dependency-recovery`, {
|
|
217
|
-
method: "POST",
|
|
218
|
-
headers: {
|
|
219
|
-
"Content-Type": "application/json",
|
|
220
|
-
},
|
|
221
|
-
body: JSON.stringify({ doId }),
|
|
222
|
-
});
|
|
223
|
-
const json = (await res.json());
|
|
224
|
-
if (!(typeof json === "object" && json !== null && "mapContent" in json)) {
|
|
225
|
-
console.log(json);
|
|
226
|
-
throw new Error("Invalid response");
|
|
227
|
-
}
|
|
228
|
-
expect(json.mapContent).toEqual({
|
|
229
|
-
"0": 0,
|
|
230
|
-
});
|
|
231
|
-
});
|
|
232
|
-
test("should sync multiple sessions in a single content message", async () => {
|
|
233
|
-
const doId = randomUUID();
|
|
234
|
-
const res = await fetch(`${url}multiple-sessions`, {
|
|
235
|
-
method: "POST",
|
|
236
|
-
headers: {
|
|
237
|
-
"Content-Type": "application/json",
|
|
238
|
-
},
|
|
239
|
-
body: JSON.stringify({ doId }),
|
|
240
|
-
});
|
|
241
|
-
const json = (await res.json());
|
|
242
|
-
if (!(typeof json === "object" &&
|
|
243
|
-
json !== null &&
|
|
244
|
-
"messageRes1" in json &&
|
|
245
|
-
"map2Hello" in json &&
|
|
246
|
-
"map3Hello" in json)) {
|
|
247
|
-
console.log(json);
|
|
248
|
-
throw new Error("Invalid response");
|
|
249
|
-
}
|
|
250
|
-
expect(json.map2Hello).toBe("world");
|
|
251
|
-
expect(json.map3Hello).toBe("world2");
|
|
252
|
-
expect(json.messageRes1).toMatchInlineSnapshot(`
|
|
253
|
-
[
|
|
254
|
-
"client -> LOAD Map sessions: empty",
|
|
255
|
-
"storage -> CONTENT Group header: true new: After: 0 New: 3",
|
|
256
|
-
"storage -> CONTENT Map header: true new: After: 0 New: 1 | After: 0 New: 1",
|
|
257
|
-
]
|
|
258
|
-
`);
|
|
259
|
-
});
|
|
260
|
-
test("large coValue upload streaming", async () => {
|
|
261
|
-
const doId = randomUUID();
|
|
262
|
-
const res = await fetch(`${url}large-covalue-upload`, {
|
|
263
|
-
method: "POST",
|
|
264
|
-
headers: {
|
|
265
|
-
"Content-Type": "application/json",
|
|
266
|
-
},
|
|
267
|
-
body: JSON.stringify({ doId }),
|
|
268
|
-
});
|
|
269
|
-
const json = (await res.json());
|
|
270
|
-
if (!(typeof json === "object" && json !== null && "messageRes1" in json)) {
|
|
271
|
-
console.log(json);
|
|
272
|
-
throw new Error("Invalid response");
|
|
273
|
-
}
|
|
274
|
-
expect(json.messageRes1).toMatchInlineSnapshot(`
|
|
275
|
-
[
|
|
276
|
-
"client -> LOAD Map sessions: empty",
|
|
277
|
-
"storage -> CONTENT Group header: true new: After: 0 New: 3",
|
|
278
|
-
"storage -> CONTENT Map header: true new: After: 0 New: 97",
|
|
279
|
-
"storage -> CONTENT Map header: true new: After: 97 New: 97",
|
|
280
|
-
"storage -> CONTENT Map header: true new: After: 194 New: 6",
|
|
281
|
-
]
|
|
282
|
-
`);
|
|
283
|
-
});
|
|
284
|
-
});
|
|
285
|
-
//# sourceMappingURL=dosqlite.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dosqlite.test.js","sourceRoot":"","sources":["../../src/tests/dosqlite.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAC9B,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAErE,aAAa;AACb,MAAM,UAAU,GAAG,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAC3D,MAAM,WAAW,GAAG,IAAI,CAAC,UAAU,EAAE,OAAO,CA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,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { CoValueCore, SyncMessage } from "cojson";
|
|
2
|
-
export declare function toSimplifiedMessages(coValues: Record<string, CoValueCore>, messages: {
|
|
3
|
-
from: "client" | "server" | "storage";
|
|
4
|
-
msg: SyncMessage;
|
|
5
|
-
}[]): string[];
|
|
6
|
-
export declare function debugMessages(coValues: Record<string, CoValueCore>, messages: {
|
|
7
|
-
from: "client" | "server" | "storage";
|
|
8
|
-
msg: SyncMessage;
|
|
9
|
-
}[]): void;
|
|
10
|
-
//# sourceMappingURL=messagesTestUtils.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"messagesTestUtils.d.ts","sourceRoot":"","sources":["../../src/tests/messagesTestUtils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAuB,WAAW,EAAE,MAAM,QAAQ,CAAC;AA2B5E,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,EACrC,QAAQ,EAAE;IACR,IAAI,EAAE,QAAQ,GAAG,QAAQ,GAAG,SAAS,CAAC;IACtC,GAAG,EAAE,WAAW,CAAC;CAClB,EAAE,YA6BJ;AAED,wBAAgB,aAAa,CAC3B,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,EACrC,QAAQ,EAAE;IACR,IAAI,EAAE,QAAQ,GAAG,QAAQ,GAAG,SAAS,CAAC;IACtC,GAAG,EAAE,WAAW,CAAC;CAClB,EAAE,QAGJ"}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
function simplifySessions(msg) {
|
|
2
|
-
const count = Object.values(msg.sessions).reduce((acc, session) => acc + session, 0);
|
|
3
|
-
if (msg.header) {
|
|
4
|
-
return `header/${count}`;
|
|
5
|
-
}
|
|
6
|
-
return "empty";
|
|
7
|
-
}
|
|
8
|
-
function simplifyNewContent(content) {
|
|
9
|
-
if (!content) {
|
|
10
|
-
return undefined;
|
|
11
|
-
}
|
|
12
|
-
return Object.values(content)
|
|
13
|
-
.map((c) => `After: ${c.after} New: ${c.newTransactions.length}`)
|
|
14
|
-
.join(" | ");
|
|
15
|
-
}
|
|
16
|
-
export function toSimplifiedMessages(coValues, messages) {
|
|
17
|
-
function getCoValue(id) {
|
|
18
|
-
for (const [name, coValue] of Object.entries(coValues)) {
|
|
19
|
-
if (coValue.id === id) {
|
|
20
|
-
return name;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
return `unknown/${id}`;
|
|
24
|
-
}
|
|
25
|
-
function toDebugString(from, msg) {
|
|
26
|
-
switch (msg.action) {
|
|
27
|
-
case "known":
|
|
28
|
-
return `${from} -> KNOWN ${msg.isCorrection ? "CORRECTION " : ""}${getCoValue(msg.id)} sessions: ${simplifySessions(msg)}`;
|
|
29
|
-
case "load":
|
|
30
|
-
return `${from} -> LOAD ${getCoValue(msg.id)} sessions: ${simplifySessions(msg)}`;
|
|
31
|
-
case "done":
|
|
32
|
-
return `${from} -> DONE ${getCoValue(msg.id)}`;
|
|
33
|
-
case "content":
|
|
34
|
-
return `${from} -> CONTENT ${getCoValue(msg.id)} header: ${Boolean(msg.header)} new: ${simplifyNewContent(msg.new)}`;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
return messages.map((m) => toDebugString(m.from, m.msg));
|
|
38
|
-
}
|
|
39
|
-
export function debugMessages(coValues, messages) {
|
|
40
|
-
console.log(toSimplifiedMessages(coValues, messages));
|
|
41
|
-
}
|
|
42
|
-
//# sourceMappingURL=messagesTestUtils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"messagesTestUtils.js","sourceRoot":"","sources":["../../src/tests/messagesTestUtils.ts"],"names":[],"mappings":"AAEA,SAAS,gBAAgB,CAAC,GAA0C;IAClE,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,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GAAG,CAAC,EAAE,CAAC,cAAc,gBAAgB,CAAC,GAAG,CAAC,EAAE,CAAC;YACpF,KAAK,MAAM;gBACT,OAAO,GAAG,IAAI,YAAY,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC;YACjD,KAAK,SAAS;gBACZ,OAAO,GAAG,IAAI,eAAe,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC,YAAY,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,SAAS,kBAAkB,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;QACzH,CAAC;IACH,CAAC;IAED,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;AAC3D,CAAC;AAED,MAAM,UAAU,aAAa,CAC3B,QAAqC,EACrC,QAGG;IAEH,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC;AACxD,CAAC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { SyncMessage } from "cojson";
|
|
2
|
-
export declare function trackMessages(): {
|
|
3
|
-
messages: {
|
|
4
|
-
from: "client" | "server" | "storage";
|
|
5
|
-
msg: SyncMessage;
|
|
6
|
-
}[];
|
|
7
|
-
restore: () => void;
|
|
8
|
-
};
|
|
9
|
-
export declare function waitFor(callback: () => boolean | undefined | Promise<boolean | undefined>): Promise<void>;
|
|
10
|
-
//# sourceMappingURL=testUtils.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"testUtils.d.ts","sourceRoot":"","sources":["../../src/tests/testUtils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAsB,WAAW,EAAE,MAAM,QAAQ,CAAC;AAI9D,wBAAgB,aAAa;;cAEnB,QAAQ,GAAG,QAAQ,GAAG,SAAS;aAChC,WAAW;;;EA2EnB;AACD,wBAAgB,OAAO,CACrB,QAAQ,EAAE,MAAM,OAAO,GAAG,SAAS,GAAG,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC,iBA2BnE"}
|
package/dist/tests/testUtils.js
DELETED
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import { StorageApiSync } from "cojson";
|
|
2
|
-
import { onTestFinished } from "vitest";
|
|
3
|
-
export function trackMessages() {
|
|
4
|
-
const messages = [];
|
|
5
|
-
const originalLoad = StorageApiSync.prototype.load;
|
|
6
|
-
const originalStore = StorageApiSync.prototype.store;
|
|
7
|
-
StorageApiSync.prototype.load = async function (id, callback, done) {
|
|
8
|
-
messages.push({
|
|
9
|
-
from: "client",
|
|
10
|
-
msg: {
|
|
11
|
-
action: "load",
|
|
12
|
-
id: id,
|
|
13
|
-
header: false,
|
|
14
|
-
sessions: {},
|
|
15
|
-
},
|
|
16
|
-
});
|
|
17
|
-
return originalLoad.call(this, id, (msg) => {
|
|
18
|
-
messages.push({
|
|
19
|
-
from: "storage",
|
|
20
|
-
msg,
|
|
21
|
-
});
|
|
22
|
-
callback(msg);
|
|
23
|
-
}, done);
|
|
24
|
-
};
|
|
25
|
-
StorageApiSync.prototype.store = function (data, correctionCallback) {
|
|
26
|
-
messages.push({
|
|
27
|
-
from: "client",
|
|
28
|
-
msg: data,
|
|
29
|
-
});
|
|
30
|
-
return originalStore.call(this, data, (msg) => {
|
|
31
|
-
messages.push({
|
|
32
|
-
from: "storage",
|
|
33
|
-
msg: {
|
|
34
|
-
action: "known",
|
|
35
|
-
isCorrection: true,
|
|
36
|
-
...msg,
|
|
37
|
-
},
|
|
38
|
-
});
|
|
39
|
-
const correctionMessages = correctionCallback(msg);
|
|
40
|
-
if (correctionMessages) {
|
|
41
|
-
for (const msg of correctionMessages) {
|
|
42
|
-
messages.push({
|
|
43
|
-
from: "client",
|
|
44
|
-
msg,
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
return correctionMessages;
|
|
49
|
-
});
|
|
50
|
-
};
|
|
51
|
-
const restore = () => {
|
|
52
|
-
StorageApiSync.prototype.load = originalLoad;
|
|
53
|
-
StorageApiSync.prototype.store = originalStore;
|
|
54
|
-
messages.length = 0;
|
|
55
|
-
};
|
|
56
|
-
onTestFinished(() => {
|
|
57
|
-
restore();
|
|
58
|
-
});
|
|
59
|
-
return {
|
|
60
|
-
messages,
|
|
61
|
-
restore,
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
export function waitFor(callback) {
|
|
65
|
-
return new Promise((resolve, reject) => {
|
|
66
|
-
const checkPassed = async () => {
|
|
67
|
-
try {
|
|
68
|
-
return { ok: await callback(), error: null };
|
|
69
|
-
}
|
|
70
|
-
catch (error) {
|
|
71
|
-
return { ok: false, error };
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
let retries = 0;
|
|
75
|
-
const interval = setInterval(async () => {
|
|
76
|
-
const { ok, error } = await checkPassed();
|
|
77
|
-
if (ok !== false) {
|
|
78
|
-
clearInterval(interval);
|
|
79
|
-
resolve();
|
|
80
|
-
}
|
|
81
|
-
if (++retries > 10) {
|
|
82
|
-
clearInterval(interval);
|
|
83
|
-
reject(error);
|
|
84
|
-
}
|
|
85
|
-
}, 100);
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
//# sourceMappingURL=testUtils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"testUtils.js","sourceRoot":"","sources":["../../src/tests/testUtils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAExC,MAAM,UAAU,aAAa;IAC3B,MAAM,QAAQ,GAGR,EAAE,CAAC;IAET,MAAM,YAAY,GAAG,cAAc,CAAC,SAAS,CAAC,IAAI,CAAC;IACnD,MAAM,aAAa,GAAG,cAAc,CAAC,SAAS,CAAC,KAAK,CAAC;IAErD,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C,CAAC;AACL,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"vitest.config.d.ts","sourceRoot":"","sources":["../../src/tests/vitest.config.ts"],"names":[],"mappings":";AAEA,wBAKG"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"vitest.config.js","sourceRoot":"","sources":["../../src/tests/vitest.config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE9C,eAAe,aAAa,CAAC;IAC3B,IAAI,EAAE;QACJ,IAAI,EAAE,uBAAuB;QAC7B,WAAW,EAAE,KAAM;KACpB;CACF,CAAC,CAAC"}
|