Files
openclaw/extensions/reef/src/flow-send.test.ts
Peter Steinberger 83d82c9302 refactor(channels): persist runtime state in plugin SQLite (#109380)
* refactor(channels): move reef, msteams, matrix, zalouser file state to SQLite with doctor imports

* fix(channels): harden SQLite state migrations

* test(reef): use SQLite flow stores in receipt suites

* fix(reef): validate restored request policy

* fix(reef): retain replay state through relay window

* docs(reef): describe durable state import

* fix(reef): honor configured legacy state path

* chore: leave changelog to release flow

* fix(reef): use managed temp root in flow tests

* fix(matrix): omit undefined device id from state
2026-07-16 17:05:28 -07:00

56 lines
1.7 KiB
TypeScript

import { afterEach, beforeEach, describe, expect, it } from "vitest";
import { generateIdentity, MemoryAuditStore, MemoryReplayStore } from "../protocol/index.js";
import { ReefMessageFlow } from "./flow.js";
import {
allow,
config,
flowStores,
guard,
peerTrust,
reefKeys,
resetFlowStoresForTests,
transport,
trust,
} from "./flow.test-helpers.js";
import { reefPeerIdentity } from "./friend-types.js";
import { reefMessageTextHash } from "./rejection-resend.js";
import type { ReefTransportClient } from "./transport.js";
beforeEach(resetFlowStoresForTests);
afterEach(resetFlowStoresForTests);
describe("ReefMessageFlow send recovery", () => {
it("persists automatic resends as non-resendable deliveries", async () => {
const alice = reefKeys();
const bob = generateIdentity();
const cfg = config();
cfg.handle = "alice";
const trustedPeer = peerTrust(bob);
const trusted = trust({ bob: trustedPeer });
const relay = transport();
const flow = new ReefMessageFlow({
config: cfg,
trust: trusted.store,
keys: alice,
transport: relay as unknown as ReefTransportClient,
guard: guard(allow),
audit: new MemoryAuditStore(new Uint8Array(32).fill(7)),
replay: new MemoryReplayStore(),
...flowStores(),
onIngress: async () => {},
onOwnerNotice: async () => {},
});
const id = await flow.send("bob", " rephrased coordination ", { resendDisabled: true });
expect(trusted.deliveries.get(`bob:${id}`)).toEqual({
bodyHash: expect.any(String),
textHash: reefMessageTextHash("rephrased coordination"),
recipient: reefPeerIdentity(trustedPeer),
resendDisabled: true,
});
expect(relay.sendEnvelope).toHaveBeenCalledOnce();
});
});