this pull request: - creates a unit test that can take any scenario file (default: `out/scenario.json` and play it back on the deployment - during the playback a debug trace generated in `timeSeries.csv` - extracts the sentimenter into a separate upgradeable contract Co-authored-by: JulesCrown <admin@noip.localhost> Co-authored-by: giteadmin <gite@admin.com> Reviewed-on: http://gitea.loseyourip.com:4000/dark-meme-society/harb/pulls/11
44 lines
1.2 KiB
Solidity
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);
|
|
}
|
|
}
|