harb/onchain/analysis/CSVManager.sol
giteadmin 6a158150b1 Clean up test suite organization and eliminate duplicate code
- Remove duplicate test files with overlapping functionality:
  * Delete VWAPDoubleOverflowAnalysis.t.sol (155 lines) - functionality already covered by VWAPTracker.t.sol with proper assertions
  * Delete ModularComponentsTest.t.sol (57 lines) - meaningless tests redundant with build process

- Improve code organization:
  * Move CSVHelper.sol and CSVManager.sol from test/helpers/ to analysis/ folder to reflect actual usage
  * Update import path in SimpleAnalysis.s.sol from ../test/helpers/CSVManager.sol to ./CSVManager.sol
  * Remove deprecated uintToStr() and intToStr() wrapper functions from CSVHelper.sol

- Update documentation:
  * Mark completed cleanup tasks in testing_todos.md
  * Add code organization improvements section showing eliminated duplicate functionality

Result: Cleaner test suite with 92 meaningful tests (vs 95 with noise), better file organization reflecting actual usage patterns, and zero dead code remaining.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-19 19:58:41 +02:00

44 lines
1.2 KiB
Solidity

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;
import "forge-std/Test.sol";
import "./CSVHelper.sol";
/**
* @title CSVManager
* @dev An abstract contract that manages CSV creation, row appending, and writing to file.
* Contracts that inherit this contract can use the CSV functionality without managing the CSV string directly.
*/
abstract contract CSVManager is Test {
using CSVHelper for *;
string internal csv;
/**
* @notice Creates the header for the CSV file.
* This function should be called in the `setUp` function of derived contracts.
*/
function initializePositionsCSV() internal {
csv = CSVHelper.createPositionsHeader();
}
function initializeTimeSeriesCSV() internal {
csv = CSVHelper.createTimeSeriesHeader();
}
/**
* @notice Appends a new row to the CSV string.
* @param newRow The new row to append.
*/
function appendCSVRow(string memory newRow) internal {
csv = CSVHelper.appendRow(csv, newRow);
}
/**
* @notice Writes the CSV string to a file.
* @param filePath The path where the CSV file will be saved.
*/
function writeCSVToFile(string memory filePath) internal {
vm.writeFile(filePath, csv);
}
}