aboutsummaryrefslogtreecommitdiffstats
path: root/src/api/dashboard/check.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/api/dashboard/check.js')
-rw-r--r--src/api/dashboard/check.js52
1 files changed, 50 insertions, 2 deletions
diff --git a/src/api/dashboard/check.js b/src/api/dashboard/check.js
index 95f805a..4292e7d 100644
--- a/src/api/dashboard/check.js
+++ b/src/api/dashboard/check.js
@@ -2,8 +2,9 @@
// dashboard_in_a_browser -- --ignored`, which serves this the page as the node does): the
// page loads without errors; the peers table has a row per peer, and an update changes
// cells without making the rows anew (`morphChildren`); the map draws a node per member;
-// and with 300 members, laid out by round trip, the first drawing doesn't hold the page up
-// for long (`LAYOUT_FOR_MS`).
+// with 300 members, laid out by round trip, the first drawing doesn't hold the page up
+// for long (`LAYOUT_FOR_MS`); and in a swarm holding a store, the document box shows the
+// federation: who writes at a place, what a proposal changes, and the votes.
//
// Needs Node.js, Playwright's library (`playwright-core`) and its Chromium; `check.nix`
// gives all three from nixpkgs.
@@ -77,6 +78,53 @@ const check = (ok, what) => {
check(map.ms < budget, `${n} members drawn in ${map.ms.toFixed(0)} ms (under ${budget})`);
}
+ // The federation, as the node would answer (`GET /events`, `/events/counts`, …).
+ const federated = await tab.evaluate(() => {
+ const rules = [{ path: "home/{party}/**", writer: "{party}" },
+ { path: "names/*", writer: "tv" }, { path: "names/**", writer: false }];
+ const writers = ["home/tv/motd", "home/tv", "home/makefu/motd", "names/r", "names/r/s"]
+ .map(path => writerAt(rules, ["tv", "lass"], path));
+ const version = { federation: 1, number: 0, changes: null,
+ keys: { tv: { since: 0, keys: ["ssh-ed25519 AAAA1"] },
+ lass: { since: 0, keys: ["ssh-ed25519 AAAA2"] } },
+ nodes: { tv: { since: 0, nodes: ["continuum:a"] }, lass: { since: 0, nodes: [] } },
+ rules };
+ const next = { ...version, number: 1, changes: "11",
+ keys: { ...version.keys, lass: { since: 1, keys: ["ssh-ed25519 AAAA3"] } } };
+ state = { node: { id: "continuum:a", alias: "a", party: "tv" }, stats: {},
+ peers: { localReaches: [], peers: {} }, graph: { members: {}, intended: {}, measured: {} } };
+ federationTimer = 1;
+ federation.summary = { store: "aa", checkpoint: "aa", heads: ["bb"], taken: 3,
+ party: "tv", votesByItself: true };
+ federation.heads = "bb";
+ federation.counts = { version: { number: 0, hash: "11", version },
+ parties: { tv: { keys: ["ssh-ed25519 AAAA1"], nodes: ["continuum:a"] },
+ lass: { keys: ["ssh-ed25519 AAAA2"], nodes: [] } },
+ values: { "home/tv/motd": "hello", "home/tv/hosts/laptop": { ip6: "42::1" } },
+ members: [["continuum:a", "tv"]],
+ proposals: { "22": { proposals: ["cc"], votes: ["dd"], yes: ["tv"], no: [],
+ passed: false, dead: false } } };
+ federation.refused = { own: [], dropped: [], refused: [] };
+ federation.versions.set("22", next);
+ showFederation();
+ renderFederation(true);
+ const tree = document.getElementById("federation");
+ return { writers, title: document.getElementById("document-title").textContent,
+ shown: !document.getElementById("federation-scroll").hidden
+ && document.getElementById("document-scroll").hidden,
+ text: tree.textContent, votes: tree.querySelectorAll(".votes button").length };
+ });
+ check(JSON.stringify(federated.writers) === JSON.stringify(["tv", null, null, "tv", null]),
+ "who writes at a place is the first rule matching it: " + JSON.stringify(federated.writers));
+ check(federated.title === "Federation" && federated.shown,
+ "in a swarm holding a store, the document box shows the federation");
+ check(federated.text.includes("motd: \"hello\" by tv"), "a value, with who writes there");
+ check(federated.text.includes("can still pass") && federated.text.includes("number: 0 -> 1")
+ && federated.text.includes('keys.lass: {"keys":["ssh-ed25519 AAAA2"],"since":0} -> '
+ + '{"keys":["ssh-ed25519 AAAA3"],"since":1}'),
+ "a proposal: where it stands, and what its version changes, party by party");
+ check(federated.votes === 2, "a proposal that can still pass has a vote of each kind");
+
await tab.waitForTimeout(500);
check(errors.length === 0, "no errors on the page" + (errors.length ? ": " + errors : ""));
await browser.close();