forked from Lilly-Protocol/lily-contracts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwave2_escrow_invariants.test.ts
More file actions
32 lines (27 loc) · 1.13 KB
/
Copy pathwave2_escrow_invariants.test.ts
File metadata and controls
32 lines (27 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/**
* Wave 2 Test Suite: Milestone Settlement and Dispute Invariant Specs
*/
describe('Lily Contracts Escrow Invariant Verification (Wave 2)', () => {
it('should calculate accurate basis point fee splits without precision loss', () => {
const calculateFee = (amountWei: bigint, feeBps: bigint): bigint => {
return (amountWei * feeBps) / 10000n;
};
const payout = 1000000000000000000n; // 1 ETH in Wei
const feeBps = 250n; // 2.5%
const fee = calculateFee(payout, feeBps);
const netPayout = payout - fee;
expect(fee).toBe(25000000000000000n);
expect(netPayout).toBe(975000000000000000n);
expect(netPayout + fee).toBe(payout);
});
it('should ensure dispute challenge period cannot be set to zero', () => {
const MIN_DISPUTE_PERIOD = 86400; // 24 hours in seconds
const validateDisputePeriod = (seconds: number): boolean => {
return seconds >= MIN_DISPUTE_PERIOD;
};
expect(validateDisputePeriod(0)).toBe(false);
expect(validateDisputePeriod(3600)).toBe(false);
expect(validateDisputePeriod(86400)).toBe(true);
expect(validateDisputePeriod(172800)).toBe(true);
});
});