OXYGENHUB
# dac6876e4d08 oxygen-vscode / test / tlog.test.mjs
2.0 KiB · last changed Withdraw tags, verify the transparency log, shallow clones, keep a side or both sides of a conflict, commit and amend by paths, merge remote bookmarks (closes #11) 6 days ago source blame history raw
1
// The Trust view's transparency log lines, from `oxy tlog verify --json`.
2
3
import { test } from "node:test";
4
import assert from "node:assert/strict";
5
import { tlogLines } from "../out/tlog.mjs";
6
7
const ago = (ms) => `at ${ms}`;
8
const info = {
9
  hub: "https://oxygenhub.io",
10
  origin: "oxygenhub.io/log",
11
  size: 15553,
12
  root: "6f8b13148d40652127b016ec332166f45cd47c5aa2b51fe5fa8fb12f54d978a5",
13
  witnesses: [
14
    { name: "plex.witness", time_ms: 1793297007000 },
15
    { name: "narvi.witness", time_ms: 1793297007000 },
16
  ],
17
  entries: [{ index: 19, kind: "ref", repo: "3ad24d80c177396edd83fe470e431ec6", object: "ff04", signers: ["5506"], received_ms: 1792280811530 }],
18
};
19
20
test("not checked yet: one line offering the check", () => {
21
  const [line, ...rest] = tlogLines(undefined, ago);
22
  assert.equal(rest.length, 0);
23
  assert.equal(line.label, "Transparency log not checked");
24
  assert.equal(line.icon, "shield");
25
});
26
27
test("verified: the checkpoint, this repository's entries, and each witness", () => {
28
  const lines = tlogLines({ info, when_ms: 5 }, ago);
29
  assert.deepEqual(
30
    lines.map((l) => [l.label, l.description, l.icon]),
31
    [
32
      ["Transparency log verified up to checkpoint 15553", "oxygenhub.io/log · 1 entry for this repository · at 5", "verified"],
33
      ["Cosigned by plex.witness", "at 1793297007000", "key"],
34
      ["Cosigned by narvi.witness", "at 1793297007000", "key"],
35
    ],
36
  );
37
});
38
39
test("no witness is a warning, and a failure shows oxy's error", () => {
40
  const lines = tlogLines({ info: { ...info, witnesses: [], entries: [] }, when_ms: 5 }, ago);
41
  assert.match(lines[0].description, /0 entries/);
42
  assert.deepEqual([lines[1].label, lines[1].icon], ["Cosigned by no witness you trust", "warning"]);
43
  const [failed] = tlogLines({ error: "the checkpoint does not extend the one seen before\nmore", when_ms: 5 }, ago);
44
  assert.deepEqual([failed.label, failed.description, failed.icon], ["Transparency log NOT verified", "the checkpoint does not extend the one seen before", "error"]);
45
});