Files
tycho-execution/foundry/test/TestUtils.sol
Diana Carvalho 0ff4aef0c7 chore: Write encoding rust calldata to file and read in solidity test
This way we can automatically replace the calldata when something changes. We don't need to manually replace the string ourselves.

--- don't change below this line ---
ENG-4453 Took 3 hours 26 minutes
2025-04-29 10:23:47 +01:00

30 lines
797 B
Solidity

// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.10;
import "forge-std/Test.sol";
contract TestUtils is Test {
constructor() {}
function loadCallDataFromFile(string memory testName)
internal
view
returns (bytes memory)
{
string memory fileContent = vm.readFile("./test/assets/calldata.txt");
string[] memory lines = vm.split(fileContent, "\n");
for (uint256 i = 0; i < lines.length; i++) {
string[] memory parts = vm.split(lines[i], ":");
if (
parts.length >= 2
&& keccak256(bytes(parts[0])) == keccak256(bytes(testName))
) {
return vm.parseBytes(parts[1]);
}
}
revert("Test calldata not found");
}
}