- Node.js v16+ installed
- npm or pnpm package manager
- PowerShell execution policy configured (or use Command Prompt)
Open Command Prompt (cmd.exe) and run:
cd "C:\Users\machintosh\Documents\Fouth Wave\acbu-backend"
npm install --save-dev fast-checkIf you prefer PowerShell, first enable script execution:
# Run PowerShell as Administrator
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
# Then install
cd "C:\Users\machintosh\Documents\Fouth Wave\acbu-backend"
npm install --save-dev fast-checkcd "C:\Users\machintosh\Documents\Fouth Wave\acbu-backend"
pnpm add -D fast-checkAfter installation, verify fast-check is in package.json:
type package.json | findstr fast-checkExpected output:
"fast-check": "^3.x.x"
npm test -- src/services/feePolicy/__tests__/feePolicyService.test.tsExpected output:
PASS src/services/feePolicy/__tests__/feePolicyService.test.ts
getBurnFeeBps
Standard Unit Tests
✓ returns high burn fee (200 BPS) when reserve is below 85% of target
✓ returns low burn fee (5 BPS) when reserve is above 115% of target
✓ returns base burn fee (10 BPS) when reserve is between 85% and 115%
✓ throws error when currency not found in reserve status
✓ throws error when target weight is zero or negative
Boundary Tests
✓ returns high fee at exactly 84.99% (just below low threshold)
✓ returns base fee at exactly 85% (at low threshold)
✓ returns base fee at exactly 85.01% (just above low threshold)
✓ returns base fee at exactly 114.99% (just below high threshold)
✓ returns base fee at exactly 115% (at high threshold)
✓ returns low fee at exactly 115.01% (just above high threshold)
Monotonicity Tests
✓ maintains correct fee structure as reserves decrease
✓ fees follow step function without unexpected jumps
getMintFeeBps
Standard Unit Tests
✓ returns base mint fee (30 BPS) when reserve ratio is healthy
✓ returns stressed mint fee (50 BPS) when reserve ratio is below minimum
✓ caps mint fee at maximum (100 BPS)
Boundary Tests
✓ returns stressed fee at exactly minRatio - 0.001
✓ returns base fee at exactly minRatio
✓ returns base fee at exactly minRatio + 0.001
Monotonicity Tests
✓ maintains correct fee structure as reserve ratio changes
Test Suites: 1 passed, 1 total
Tests: 19 passed, 19 total
npm test -- src/services/feePolicy/__tests__/feePolicyService.pbt.test.tsExpected output:
PASS src/services/feePolicy/__tests__/feePolicyService.pbt.test.ts
Property-Based Tests: getBurnFeeBps
✓ PROPERTY: Fee is always within sanity bounds [1, 500] BPS (100 runs)
✓ PROPERTY: Fee is one of exactly three valid values [5, 10, 200] (100 runs)
✓ PROPERTY: Monotonicity - fee decreases as reserve weight increases (100 runs)
✓ PROPERTY: Boundary consistency - fees at thresholds are deterministic (120 runs)
✓ PROPERTY: Fee calculation is deterministic for same inputs (50 runs)
✓ PROPERTY: Total fee never exceeds maximum cap (100 runs)
Property-Based Tests: getMintFeeBps
✓ PROPERTY: Fee is always within sanity bounds [1, 500] BPS (100 runs)
✓ PROPERTY: Fee is one of exactly two valid values [30, 50] (100 runs)
✓ PROPERTY: Fee never exceeds maximum cap of 100 BPS (100 runs)
✓ PROPERTY: Monotonicity - fee decreases as reserve ratio increases (100 runs)
✓ PROPERTY: Boundary consistency at minRatio threshold
✓ PROPERTY: Fee calculation is deterministic for same inputs (50 runs)
Test Suites: 1 passed, 1 total
Tests: 12 passed, 12 total
npm testnpm run test:coverageExpected coverage for fee policy service:
File | % Stmts | % Branch | % Funcs | % Lines |
----------------------------------|---------|----------|---------|---------|
feePolicyService.ts | 95.83 | 91.67 | 100 | 95.65 |
Solution: Ensure fast-check is installed:
npm list fast-checkIf not installed, run:
npm install --save-dev fast-checkSolution: Clear node_modules and reinstall:
rmdir /s /q node_modules
npm installSolution: Ensure jest is properly configured. Check jest.config.js has:
preset: 'ts-jest',
testEnvironment: 'node',Solution: Use Command Prompt (cmd.exe) instead, or enable PowerShell scripts:
# Run as Administrator
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUserAfter installation and testing, verify:
- fast-check installed in package.json devDependencies
- All standard unit tests pass (19 tests)
- All property-based tests pass (12 tests)
- Test coverage ≥ 95% for feePolicyService.ts
- No console errors or warnings
- All boundary tests pass at exact thresholds
- Monotonicity properties verified
Once all tests pass:
- Review
FEE_AUDIT_SUMMARY.mdfor detailed findings - Review
docs/fees.mdfor fee tier documentation - Schedule code review with senior engineer
- Schedule financial review of fee changes
- Deploy to staging environment
- Run integration tests in staging
- Monitor fee calculations for anomalies
- Deploy to production with monitoring
For issues or questions:
- Technical: Backend Engineering Team
- Testing: QA Team
- Business Logic: Product/Finance Team