import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; import { describe, expect, it } from "vitest"; import type { PluginRuntime } from "../runtime-api.js"; import {
readNostrBusState,
readNostrProfileState,
writeNostrBusState,
writeNostrProfileState,
computeSinceTimestamp,
} from "./nostr-state-store.js"; import { setNostrRuntime } from "./runtime.js";
describe("nostr bus state store", () => {
it("persists and reloads state across restarts", async () => {
await withTempStateDir(async () => { // Fresh start - no state
expect(await readNostrBusState({ accountId: "test-bot" })).toBeNull();
it("uses the max of both timestamps", () => { const state: Parameters<typeof computeSinceTimestamp>[0] = {
version: 2,
lastProcessedAt: 1699999000,
gatewayStartedAt: 1699998000,
recentEventIds: [],
};
expect(computeSinceTimestamp(state, 1700000000)).toBe(1699999000);
});
it("falls back to now if both are null", () => { const state: Parameters<typeof computeSinceTimestamp>[0] = {
version: 2,
lastProcessedAt: null,
gatewayStartedAt: null,
recentEventIds: [],
};
expect(computeSinceTimestamp(state, 1700000000)).toBe(1700000000);
});
});
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.11 Sekunden
(vorverarbeitet am 2026-06-10)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.