logicsrc/packages/sdk/src/openrental.test.ts
Anthony Ettinger 68f3151699 Merge master; OpenFleet keeps its name, PR 177's rental descriptor becomes OpenRental
PR 177 shipped a second OpenFleet under the same slug: a published listing of OpenAgent profiles and ipfile swarms with CoinPay rental offers. Anthony ruled that OpenFleet means the human-controlled fleet and the record of who spawned whom, so the rental contract is renamed OpenRental (slug openrental, catalogs family, group noun listing): docs/openrental.md, logicsrc-openrental.schema.json with type logicsrc.openrental and scope kind listing, fixtures/openrental, createOpenRental and OpenRental* types in the SDK, the openrental validator kind. Minor bumps because an export moved: @logicsrc/schemas 0.2.0, @logicsrc/validators 0.2.0, @logicsrc/sdk 0.2.0. The discovery contract test now covers openfleet, openrental and openwall, one per family, and accepts a landing-page link in llms.txt.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

Claude-Session: https://claude.ai/code/session_01RZV4zJ2pDZLNN3kE5jFCmV
2026-09-13 08:45:33 +00:00

35 lines
1.6 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { createOpenRental, type OpenRentalMember } from "./index.js";
const members: OpenRentalMember[] = [
{ kind: "openagent", id: "analyst.coinpay", url: "https://example.com/agent.json" },
{ kind: "openswarm", id: `ed25519:${"a".repeat(64)}`, url: "https://example.com/manifest.json" }
];
describe("createOpenRental", () => {
it.each([members.slice(0, 1), members.slice(1), members])("constructs single-kind and mixed listings", (...fleetMembers) => {
const listing = createOpenRental({
id: "https://example.com/listings/research", name: "Research", owner_did: "operator.coinpay",
members: fleetMembers
});
expect(listing.type).toBe("logicsrc.openrental");
expect(listing.version).toBe("0.1");
expect(listing.members).toEqual(fleetMembers);
expect(listing.rentals).toBeUndefined();
});
it("keeps rental amounts as decimal strings and preserves metadata", () => {
const input: Parameters<typeof createOpenRental>[0] = {
id: "https://example.com/listings/research", name: "Research", owner_did: "operator.coinpay", members,
metadata: { support: { languages: ["en", "fr"] } },
rentals: [{
id: "hourly", scope: { kind: "listing" },
rate: { amount: "9007199254740993.123456", currency: "USD", unit: "hour" },
payment: { provider: "coinpay", payee_did: "operator.coinpay", checkout_url: "https://example.com/rent" }
}]
};
const snapshot = structuredClone(input);
expect(createOpenRental(input)).toEqual({ ...input, type: "logicsrc.openrental", version: "0.1" });
expect(input).toEqual(snapshot);
});
});