Skip to content

Commit ba9df0e

Browse files
authored
Merge pull request #180 from Mosas2000/test/fee-edge-cases
Add edge case tests for maximum fee limit
2 parents 1dcc15f + 0e9c1ba commit ba9df0e

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

tests/tipstream.test.ts

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,62 @@ describe("TipStream Contract Tests", () => {
336336

337337
expect(result).toBeOk(Cl.uint(20000));
338338
});
339+
340+
it("accepts fee at exactly the maximum limit of 1000 basis points", () => {
341+
const { result } = simnet.callPublicFn(
342+
"tipstream",
343+
"set-fee-basis-points",
344+
[Cl.uint(1000)],
345+
deployer
346+
);
347+
expect(result).toBeOk(Cl.bool(true));
348+
349+
const { result: fee } = simnet.callReadOnlyFn(
350+
"tipstream",
351+
"get-fee-for-amount",
352+
[Cl.uint(1000000)],
353+
wallet1
354+
);
355+
expect(fee).toBeOk(Cl.uint(100000));
356+
});
357+
358+
it("rejects fee above the maximum limit of 1000 basis points", () => {
359+
const { result } = simnet.callPublicFn(
360+
"tipstream",
361+
"set-fee-basis-points",
362+
[Cl.uint(1001)],
363+
deployer
364+
);
365+
expect(result).toBeErr(Cl.uint(101));
366+
});
367+
368+
it("accepts zero fee to disable platform fees", () => {
369+
const { result } = simnet.callPublicFn(
370+
"tipstream",
371+
"set-fee-basis-points",
372+
[Cl.uint(0)],
373+
deployer
374+
);
375+
expect(result).toBeOk(Cl.bool(true));
376+
377+
const { result: fee } = simnet.callReadOnlyFn(
378+
"tipstream",
379+
"get-fee-for-amount",
380+
[Cl.uint(1000000)],
381+
wallet1
382+
);
383+
expect(fee).toBeOk(Cl.uint(0));
384+
});
385+
386+
it("non-owner cannot change fee", () => {
387+
const { result } = simnet.callPublicFn(
388+
"tipstream",
389+
"set-fee-basis-points",
390+
[Cl.uint(100)],
391+
wallet1
392+
);
393+
expect(result).toBeErr(Cl.uint(100));
394+
});
339395
});
340396

341397
describe("Batch Tipping", () => {

0 commit comments

Comments
 (0)