Skip to content

Commit

Permalink
add decode fuzz test
Browse files Browse the repository at this point in the history
  • Loading branch information
snreynolds committed Oct 20, 2024
1 parent 0070fcd commit d643d65
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
7 changes: 7 additions & 0 deletions test/libraries/CalldataDecoder.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,13 @@ contract CalldataDecoderTest is Test {
assertEq(amount, _amount);
}

function test_fuzz_decodeUint256(uint256 _amount) public {
bytes memory params = abi.encode(_amount);
(uint256 amount) = decoder.decodeUint256(params);

assertEq(amount, _amount);
}

function _assertEq(PathKey[] memory path1, PathKey[] memory path2) internal pure {
assertEq(path1.length, path2.length);
for (uint256 i = 0; i < path1.length; i++) {
Expand Down
4 changes: 4 additions & 0 deletions test/mocks/MockCalldataDecoder.sol
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,8 @@ contract MockCalldataDecoder {
{
return params.decodeCurrencyAddressAndUint256();
}

function decodeUint256(bytes calldata params) external pure returns (uint256) {
return params.decodeUint256();
}
}

0 comments on commit d643d65

Please sign in to comment.