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
30 lines
797 B
Solidity
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");
|
|
}
|
|
}
|