fix: expose client fetch and signed adjustments
Quality / quality (ubuntu-latest) (push) Failing after 9m49s
Quality / quality (windows-latest) (push) Canceled after 0s

This commit is contained in:
2026-08-23 18:56:05 +05:30
parent 6258495b67
commit 4be4b2c346
8 changed files with 64 additions and 8 deletions
+24
View File
@@ -40,3 +40,27 @@ test("meter distinguishes refusals from storage faults", async () => {
fault: true,
});
});
test("adjust accepts signed non-zero amounts while other additions stay positive", async () => {
const writes: number[] = [];
const meter = defineMeter({
store: {
balance: async () => 0,
reserve: async () => true,
write: async (_subject, units) => {
writes.push(units);
},
},
});
expect(await meter.adjust("u1", -25, "correction")).toEqual({ ok: true });
expect(await meter.adjust("u1", 10, "correction")).toEqual({ ok: true });
expect(await meter.adjust("u1", 0, "correction")).toEqual({
ok: false,
reason: "units adjustment must be a non-zero whole number",
});
expect(await meter.grant("u1", -1, "invalid")).toEqual({
ok: false,
reason: "units must be a positive whole number",
});
expect(writes).toEqual([-25, 10]);
});