harb/onchain/test/ModularComponentsTest.t.sol
giteadmin eac7360ff9 Consolidate duplicate helper functions and improve test maintainability
- Create shared MockVWAPTracker.sol to eliminate duplicate mock implementations
- Add TestBase.sol with shared utilities (getDefaultParams, bp, denormTR)
- Update CSVHelper.sol to use Forge's vm.toString() instead of manual conversion
- Standardize tick calculation function names across test files
- Update test files to use consolidated utilities
- Remove helper function inventory (consolidation complete)

Eliminates 200-300 lines of duplicate code while maintaining 100% test compatibility.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-18 20:30:50 +02:00

57 lines
No EOL
2.1 KiB
Solidity

// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.19;
import "forge-std/Test.sol";
import "../src/libraries/UniswapMath.sol";
import "../src/abstracts/PriceOracle.sol";
import "../src/abstracts/ThreePositionStrategy.sol";
import "./helpers/TestBase.sol";
/**
* @title Modular Components Test
* @notice Quick validation that all modular components compile and basic functions work
*/
// Simple test implementations
contract TestUniswapMath is UniswapMath, Test {
function testTickAtPrice(bool t0isWeth, uint256 tokenAmount, uint256 ethAmount) external {
// Bound inputs to reasonable ranges to avoid overflow in ABDKMath64x64 conversions
tokenAmount = bound(tokenAmount, 1, 1e18);
ethAmount = bound(ethAmount, 1, 1e18);
int24 tick = _tickAtPrice(t0isWeth, tokenAmount, ethAmount);
// Verify tick is within valid bounds
assertGe(tick, -887272, "Tick should be >= MIN_TICK");
assertLe(tick, 887272, "Tick should be <= MAX_TICK");
}
function tickAtPrice(bool t0isWeth, uint256 tokenAmount, uint256 ethAmount) external pure returns (int24) {
return _tickAtPrice(t0isWeth, tokenAmount, ethAmount);
}
}
contract ModularComponentsTest is TestUtilities {
TestUniswapMath testMath;
function setUp() public {
testMath = new TestUniswapMath();
}
function testUniswapMathCompilation() public {
// Test that mathematical utilities work
int24 tick = testMath.tickAtPrice(true, 1 ether, 1 ether);
// Should get a reasonable tick for 1:1 ratio
assertGt(tick, -10000, "Tick should be reasonable");
assertLt(tick, 10000, "Tick should be reasonable");
console.log("UniswapMath component test passed");
}
function testModularArchitectureCompiles() public {
// If this test runs, it means all modular components compiled successfully
assertTrue(true, "Modular architecture compiles successfully");
console.log("All modular components compiled successfully");
}
}