T01.i: remove dead ensureReposOpen (batch open-repo helper)
Its only callers were its own definition and its dedicated test block; no production code used it since the read-union removal (T01.f). The one test that exercised readDocumentSubjects' real integration path (not ensureReposOpen itself) is kept, moved under the ensureRepoOpen describe block it actually belongs to.
This commit is contained in:
@@ -285,14 +285,3 @@ export async function openRepoUnguarded(nuri: Nuri): Promise<void> {
|
|||||||
inFlight.set(nuri, p);
|
inFlight.set(nuri, p);
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Open a SET of repos before an anchored batch read, in parallel, each tolerant
|
|
||||||
* ({@link ensureRepoOpen} never throws). Empty / falsy entries are ignored.
|
|
||||||
*/
|
|
||||||
// @provenance ensureReposOpen kind=aligned level=2 ref=sdk/js/lib-wasm/src/lib.rs:doc_subscribe — the batch form, with per-doc isolation
|
|
||||||
export async function ensureReposOpen(nuris: Nuri[]): Promise<void> {
|
|
||||||
const unique = [...new Set(nuris.filter(Boolean))];
|
|
||||||
if (unique.length === 0) return;
|
|
||||||
await Promise.all(unique.map((n) => ensureRepoOpen(n)));
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* open-repo.test.ts — behavioral tests for ensureRepoOpen / ensureReposOpen
|
* open-repo.test.ts — behavioral tests for ensureRepoOpen (src/open-repo.ts).
|
||||||
* (src/open-repo.ts).
|
|
||||||
*
|
*
|
||||||
* Core invariant: on a fresh session over a persistent wallet, a scope-index
|
* Core invariant: on a fresh session over a persistent wallet, a scope-index
|
||||||
* or entity repo is NOT yet in `self.repos`, so an anchored sparql_query returns
|
* or entity repo is NOT yet in `self.repos`, so an anchored sparql_query returns
|
||||||
@@ -21,7 +20,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { describe, it, expect, mock, beforeEach, afterAll } from "bun:test";
|
import { describe, it, expect, mock, beforeEach, afterAll } from "bun:test";
|
||||||
import { ensureRepoOpen, ensureReposOpen, resetOpenedRepos } from "../src/emulated-verifier/open-repo";
|
import { ensureRepoOpen, resetOpenedRepos } from "../src/emulated-verifier/open-repo";
|
||||||
import { readDocumentSubjects } from "../src/surface/read-document";
|
import { readDocumentSubjects } from "../src/surface/read-document";
|
||||||
import { configure } from "../src/index";
|
import { configure } from "../src/index";
|
||||||
import { configureStoreRegistry, setCurrentUser } from "../src/shared-wallet/bootstrap";
|
import { configureStoreRegistry, setCurrentUser } from "../src/shared-wallet/bootstrap";
|
||||||
@@ -168,43 +167,6 @@ describe("ensureRepoOpen", () => {
|
|||||||
// Calling again should also be a no-op (idempotent, already in opened)
|
// Calling again should also be a no-op (idempotent, already in opened)
|
||||||
await expect(ensureRepoOpen("did:ng:o:c")).resolves.toBeUndefined();
|
await expect(ensureRepoOpen("did:ng:o:c")).resolves.toBeUndefined();
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
describe("ensureReposOpen", () => {
|
|
||||||
it("opens all provided nuris in parallel (one subscribe per unique nuri)", async () => {
|
|
||||||
const ng = makeFakeNgWithSubscribe({
|
|
||||||
"did:ng:o:x": [[TYPE, `${FP}Event`]],
|
|
||||||
"did:ng:o:y": [[TYPE, `${FP}Event`]],
|
|
||||||
});
|
|
||||||
inject(ng);
|
|
||||||
|
|
||||||
await ensureReposOpen(["did:ng:o:x", "did:ng:o:y"]);
|
|
||||||
|
|
||||||
expect(ng.doc_subscribe).toHaveBeenCalledTimes(2);
|
|
||||||
expect(ng.subscribed.has("did:ng:o:x")).toBe(true);
|
|
||||||
expect(ng.subscribed.has("did:ng:o:y")).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("deduplicates: repeated nuri in input leads to exactly one subscribe", async () => {
|
|
||||||
const ng = makeFakeNgWithSubscribe({
|
|
||||||
"did:ng:o:dup": [[TYPE, `${FP}Event`]],
|
|
||||||
});
|
|
||||||
inject(ng);
|
|
||||||
|
|
||||||
await ensureReposOpen(["did:ng:o:dup", "did:ng:o:dup", "did:ng:o:dup"]);
|
|
||||||
|
|
||||||
expect(ng.doc_subscribe).toHaveBeenCalledTimes(1);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("empty or all-falsy input is a no-op (no subscribe calls)", async () => {
|
|
||||||
const ng = makeFakeNgWithSubscribe({});
|
|
||||||
inject(ng);
|
|
||||||
|
|
||||||
await ensureReposOpen([]);
|
|
||||||
await ensureReposOpen(["" as any]);
|
|
||||||
|
|
||||||
expect(ng.doc_subscribe).toHaveBeenCalledTimes(0);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("the anchored document read triggers doc_subscribe then returns data (integration path)", async () => {
|
it("the anchored document read triggers doc_subscribe then returns data (integration path)", async () => {
|
||||||
const ng = makeFakeNgWithSubscribe({
|
const ng = makeFakeNgWithSubscribe({
|
||||||
|
|||||||
Reference in New Issue
Block a user