fix: un second doc_subscribe tuait le premier, et les inbox n'étaient lues qu'à la connexion

This commit is contained in:
Sylvain Duchesne
2026-08-17 11:11:04 +02:00
parent 6dfdf2f036
commit 935cce4d7b
14 changed files with 1284 additions and 115 deletions
+13 -4
View File
@@ -145,21 +145,30 @@ test("a public store serves every asker, not only the first", async () => {
test("asked once per document: the outcome is memoised, in both directions", async () => {
const { sparql_query } = inject();
// Counted PER DOCUMENT (the read is anchored on the one being asked about), not over
// every read the process makes. `setCurrentUser` fires the connection work, which reads
// on its own account in the background — none of it about this document — so a total
// makes the memo's arithmetic depend on whatever else happens to be in flight. This is
// the same assertion, about the read it is actually about.
const asks = (nuri: string): number =>
sparql_query.mock.calls.filter((c) => c[3] === nuri).length;
setCurrentUser("alice");
await aliceExposesHerNote();
armEmulation();
setCurrentUser("bob");
await fetchReadCap(PUB);
const afterHit = sparql_query.mock.calls.length;
const afterHit = asks(PUB);
await fetchReadCap(PUB); // held now → not even the memo is consulted
expect(sparql_query.mock.calls.length).toBe(afterHit);
expect(asks(PUB)).toBe(afterHit);
const absent = "did:ng:o:nothing-here" as Nuri;
await fetchReadCap(absent);
const afterMiss = sparql_query.mock.calls.length;
const afterMiss = asks(absent);
expect(afterMiss).toBe(1); // it WAS asked once — a memo over nothing proves nothing
await fetchReadCap(absent); // a miss is remembered too
expect(sparql_query.mock.calls.length).toBe(afterMiss);
expect(asks(absent)).toBe(afterMiss);
});
test("resetting the caps forgets the memo — a stale yes would hand back what is no longer held", async () => {