refactor: Move code check to CallbackVerificationDispatcher
[copied from exact same reasoning with execution code-checking] I was inspired to do this because, when disabling the slither check for the staticcall when calling the callback verifier, I realized it's not clear from the same contract that we have already checked for contract code existence when setting the verifier. This made me feel uneasy, as this contract can then not stand alone and must rely on the higher level contract to safely check for code existence, otherwise the staticcall is unsafe. Keeping this logic in a separate contract seems error-prone to me, as we may remove the check for code existence without immediately realizing the implications of doing so. For this reason I have organized it as follows: - Logic/tests relating to proper roles/access control in the main TychoRouter. - Lower-level logic/tests that check contract validity before setting the callback verifier in the CallbackVerificationDispatcher
This commit is contained in:
@@ -26,6 +26,14 @@ contract TychoRouterTest is TychoRouterTestSetup {
|
||||
assert(tychoRouter.executors(DUMMY) == true);
|
||||
}
|
||||
|
||||
function testRemoveExecutorValidRole() public {
|
||||
vm.startPrank(executorSetter);
|
||||
tychoRouter.setExecutor(DUMMY);
|
||||
tychoRouter.removeExecutor(DUMMY);
|
||||
vm.stopPrank();
|
||||
assert(tychoRouter.executors(DUMMY) == false);
|
||||
}
|
||||
|
||||
function testRemoveExecutorMissingSetterRole() public {
|
||||
vm.expectRevert();
|
||||
tychoRouter.removeExecutor(BOB);
|
||||
@@ -36,19 +44,14 @@ contract TychoRouterTest is TychoRouterTestSetup {
|
||||
tychoRouter.setExecutor(DUMMY);
|
||||
}
|
||||
|
||||
function testSetValidVerifier() public {
|
||||
function testSetVerifierValidRole() public {
|
||||
vm.startPrank(executorSetter);
|
||||
vm.expectEmit();
|
||||
// Define the event we expect to be emitted at the next step
|
||||
emit CallbackVerifierSet(DUMMY);
|
||||
|
||||
tychoRouter.setCallbackVerifier(DUMMY);
|
||||
vm.stopPrank();
|
||||
|
||||
assert(tychoRouter.callbackVerifiers(DUMMY) == true);
|
||||
}
|
||||
|
||||
function testRemoveVerifier() public {
|
||||
function testRemoveVerifierValidRole() public {
|
||||
vm.startPrank(executorSetter);
|
||||
tychoRouter.setCallbackVerifier(DUMMY);
|
||||
tychoRouter.removeCallbackVerifier(DUMMY);
|
||||
@@ -56,13 +59,6 @@ contract TychoRouterTest is TychoRouterTestSetup {
|
||||
assert(tychoRouter.callbackVerifiers(DUMMY) == false);
|
||||
}
|
||||
|
||||
function testRemoveUnSetVerifier() public {
|
||||
vm.startPrank(executorSetter);
|
||||
tychoRouter.removeCallbackVerifier(BOB);
|
||||
vm.stopPrank();
|
||||
assert(tychoRouter.callbackVerifiers(BOB) == false);
|
||||
}
|
||||
|
||||
function testRemoveVerifierMissingSetterRole() public {
|
||||
vm.expectRevert();
|
||||
tychoRouter.removeCallbackVerifier(BOB);
|
||||
@@ -73,15 +69,6 @@ contract TychoRouterTest is TychoRouterTestSetup {
|
||||
tychoRouter.setCallbackVerifier(DUMMY);
|
||||
}
|
||||
|
||||
function testSetVerifierNonContract() public {
|
||||
vm.startPrank(executorSetter);
|
||||
vm.expectRevert(
|
||||
abi.encodeWithSelector(TychoRouter__NonContractVerifier.selector)
|
||||
);
|
||||
tychoRouter.setCallbackVerifier(BOB);
|
||||
vm.stopPrank();
|
||||
}
|
||||
|
||||
function testWithdrawNative() public {
|
||||
vm.startPrank(FUND_RESCUER);
|
||||
// Send 100 ether to tychoRouter
|
||||
|
||||
Reference in New Issue
Block a user