Commit 76e632cd authored by Maurelian's avatar Maurelian

feat(ctb): Update tests and add comments for queuedAt selector clash

parent 7cd55c4b
...@@ -7,6 +7,9 @@ import { ISemver } from "src/universal/ISemver.sol"; ...@@ -7,6 +7,9 @@ import { ISemver } from "src/universal/ISemver.sol";
/// @notice This contract enables a delay before a call is forwarded to a target contract, and during the delay period /// @notice This contract enables a delay before a call is forwarded to a target contract, and during the delay period
/// the call can be vetoed by the authorized vetoer. /// the call can be vetoed by the authorized vetoer.
/// This contract does not support value transfers, only data is forwarded. /// This contract does not support value transfers, only data is forwarded.
/// Additionally, this contract cannot be used to forward calls with data beginning with the function selector
/// of the queuedAt(bytes32) function. This is because of input validation checks which solidity performs at
/// runtime on functions which take an argument.
contract DelayedVetoable is ISemver { contract DelayedVetoable is ISemver {
/// @notice Error for when the delay has already been set. /// @notice Error for when the delay has already been set.
error AlreadyDelayed(); error AlreadyDelayed();
......
...@@ -81,12 +81,15 @@ contract DelayedVetoable_HandleCall_Test is DelayedVetoable_Init { ...@@ -81,12 +81,15 @@ contract DelayedVetoable_HandleCall_Test is DelayedVetoable_Init {
/// @dev The delay is inititially set to zero and the call is immediately forwarded. /// @dev The delay is inititially set to zero and the call is immediately forwarded.
function testFuzz_handleCall_initialForwardingImmediately_succeeds( function testFuzz_handleCall_initialForwardingImmediately_succeeds(
bytes memory inData, bytes calldata inData,
bytes memory outData bytes calldata outData
) )
external external
{ {
assumeNonzeroData(inData); assumeNonzeroData(inData);
if (inData.length >= 4) {
vm.assume(bytes4(inData[0:4]) != bytes4(keccak256("queuedAt(bytes32)")));
}
// Reset the delay to zero // Reset the delay to zero
vm.store(address(delayedVetoable), bytes32(uint256(0)), bytes32(uint256(0))); vm.store(address(delayedVetoable), bytes32(uint256(0)), bytes32(uint256(0)));
...@@ -181,4 +184,18 @@ contract DelayedVetoable_HandleCall_TestFail is DelayedVetoable_Init { ...@@ -181,4 +184,18 @@ contract DelayedVetoable_HandleCall_TestFail is DelayedVetoable_Init {
vm.expectRevert(outData); vm.expectRevert(outData);
(bool success2,) = address(delayedVetoable).call(inData); (bool success2,) = address(delayedVetoable).call(inData);
} }
/// @dev A test documenting the single instance in which the contract is not 'transparent' to the initiator.
function testFuzz_handleCall_queuedAtClash_reverts(bytes memory outData) external {
// This will get us calldata with the same function selector as the queuedAt function, but
// with the incorrect input data length.
bytes memory inData = abi.encodePacked(keccak256("queuedAt(bytes32)"));
// Reset the delay to zero
vm.store(address(delayedVetoable), bytes32(uint256(0)), bytes32(uint256(0)));
vm.prank(initiator);
vm.expectRevert(outData);
(bool success,) = address(delayedVetoable).call(inData);
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment