fix: make payment event reduction monotonic
Quality / quality (ubuntu-latest) (push) Failing after 9m53s
Quality / quality (windows-latest) (push) Canceled after 0s

This commit is contained in:
2026-08-23 21:34:59 +05:30
parent 98e0813061
commit fe44bc2091
11 changed files with 458 additions and 16 deletions
+12 -8
View File
@@ -20,7 +20,10 @@ test("payment plugin contributes its schema only when configured", async () => {
const runner = createPluginRunner(paymentPlugin(), context);
await runner.configure({ payment: { default: "sandbox", sandbox: true } } as any);
const contributions = await runner.contributions();
expect(contributions.migrations.map((row) => row.id)).toEqual(["wrnexus-payment-001"]);
expect(contributions.migrations.map((row) => row.id)).toEqual([
"wrnexus-payment-001",
"wrnexus-payment-002-event-order",
]);
expect(contributions.componentDirs).toHaveLength(1);
expect(contributions.routes.map((row) => row.path)).toEqual(["/api/payments/webhook/:gateway"]);
const off = createPluginRunner(paymentPlugin(), { ...context, metadata: new Map() });
@@ -41,13 +44,14 @@ test("database store persists append-only events and atomically caps refunds", a
warn() {},
});
await runner.configure({ payment: { default: "sandbox" } } as any);
const source = (await runner.contributions()).migrations[0].source!;
const up = source.split("-- +down")[0].replace("-- +up", "");
for (const statement of up
.split(";")
.map((x) => x.trim())
.filter(Boolean))
await db.exec(statement);
for (const migration of (await runner.contributions()).migrations) {
const up = migration.source!.split("-- +down")[0].replace("-- +up", "");
for (const statement of up
.split(";")
.map((x) => x.trim())
.filter(Boolean))
await db.exec(statement);
}
const store = databasePaymentStore();
const intent = {
id: "pay-1",