feat: replace setExecutor with batchSetExecutor
This commit is contained in:
@@ -235,13 +235,15 @@ contract TychoRouter is
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @dev Entrypoint to add or replace an approved executor contract address
|
* @dev Entrypoint to add or replace an approved executor contract address
|
||||||
* @param target address of the executor contract
|
* @param targets address of the executor contract
|
||||||
*/
|
*/
|
||||||
function setExecutor(address target)
|
function batchSetExecutor(address[] memory targets)
|
||||||
external
|
external
|
||||||
onlyRole(EXECUTOR_SETTER_ROLE)
|
onlyRole(EXECUTOR_SETTER_ROLE)
|
||||||
{
|
{
|
||||||
_setExecutor(target);
|
for (uint256 i = 0; i < targets.length; i++) {
|
||||||
|
_setExecutor(targets[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ contract Constants is Test {
|
|||||||
|
|
||||||
// Dummy contracts
|
// Dummy contracts
|
||||||
address DUMMY = makeAddr("dummy");
|
address DUMMY = makeAddr("dummy");
|
||||||
|
address DUMMY2 = makeAddr("dummy2");
|
||||||
address PAUSER = makeAddr("pauser");
|
address PAUSER = makeAddr("pauser");
|
||||||
address UNPAUSER = makeAddr("unpauser");
|
address UNPAUSER = makeAddr("unpauser");
|
||||||
|
|
||||||
@@ -37,6 +38,8 @@ contract Constants is Test {
|
|||||||
*/
|
*/
|
||||||
function deployDummyContract() internal {
|
function deployDummyContract() internal {
|
||||||
bytes memory minimalBytecode = hex"01"; // Single-byte bytecode
|
bytes memory minimalBytecode = hex"01"; // Single-byte bytecode
|
||||||
vm.etch(DUMMY, minimalBytecode); // Deploy minimal bytecode
|
// Deploy minimal bytecode
|
||||||
|
vm.etch(DUMMY, minimalBytecode);
|
||||||
|
vm.etch(DUMMY2, minimalBytecode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -20,15 +20,32 @@ contract TychoRouterTest is TychoRouterTestSetup {
|
|||||||
);
|
);
|
||||||
|
|
||||||
function testSetExecutorValidRole() public {
|
function testSetExecutorValidRole() public {
|
||||||
|
// Set single executor
|
||||||
|
address[] memory executors = new address[](1);
|
||||||
|
executors[0] = DUMMY;
|
||||||
vm.startPrank(EXECUTOR_SETTER);
|
vm.startPrank(EXECUTOR_SETTER);
|
||||||
tychoRouter.setExecutor(DUMMY);
|
tychoRouter.batchSetExecutor(executors);
|
||||||
vm.stopPrank();
|
vm.stopPrank();
|
||||||
assert(tychoRouter.executors(DUMMY) == true);
|
assert(tychoRouter.executors(DUMMY) == true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function testSetExecutorMultipleValidRole() public {
|
||||||
|
// Set multiple executors
|
||||||
|
address[] memory executors = new address[](2);
|
||||||
|
executors[0] = DUMMY;
|
||||||
|
executors[1] = DUMMY2;
|
||||||
|
vm.startPrank(EXECUTOR_SETTER);
|
||||||
|
tychoRouter.batchSetExecutor(executors);
|
||||||
|
vm.stopPrank();
|
||||||
|
assert(tychoRouter.executors(DUMMY) == true);
|
||||||
|
assert(tychoRouter.executors(DUMMY2) == true);
|
||||||
|
}
|
||||||
|
|
||||||
function testRemoveExecutorValidRole() public {
|
function testRemoveExecutorValidRole() public {
|
||||||
vm.startPrank(EXECUTOR_SETTER);
|
vm.startPrank(EXECUTOR_SETTER);
|
||||||
tychoRouter.setExecutor(DUMMY);
|
address[] memory executors = new address[](1);
|
||||||
|
executors[0] = DUMMY;
|
||||||
|
tychoRouter.batchSetExecutor(executors);
|
||||||
tychoRouter.removeExecutor(DUMMY);
|
tychoRouter.removeExecutor(DUMMY);
|
||||||
vm.stopPrank();
|
vm.stopPrank();
|
||||||
assert(tychoRouter.executors(DUMMY) == false);
|
assert(tychoRouter.executors(DUMMY) == false);
|
||||||
@@ -41,7 +58,9 @@ contract TychoRouterTest is TychoRouterTestSetup {
|
|||||||
|
|
||||||
function testSetExecutorMissingSetterRole() public {
|
function testSetExecutorMissingSetterRole() public {
|
||||||
vm.expectRevert();
|
vm.expectRevert();
|
||||||
tychoRouter.setExecutor(DUMMY);
|
address[] memory executors = new address[](1);
|
||||||
|
executors[0] = DUMMY;
|
||||||
|
tychoRouter.batchSetExecutor(executors);
|
||||||
}
|
}
|
||||||
|
|
||||||
function testSetVerifierValidRole() public {
|
function testSetVerifierValidRole() public {
|
||||||
|
|||||||
@@ -56,7 +56,9 @@ contract TychoRouterTestSetup is Test, Constants {
|
|||||||
|
|
||||||
usv2Executor = new UniswapV2Executor();
|
usv2Executor = new UniswapV2Executor();
|
||||||
vm.startPrank(EXECUTOR_SETTER);
|
vm.startPrank(EXECUTOR_SETTER);
|
||||||
tychoRouter.setExecutor(address(usv2Executor));
|
address[] memory executors = new address[](1);
|
||||||
|
executors[0] = address(usv2Executor);
|
||||||
|
tychoRouter.batchSetExecutor(executors);
|
||||||
vm.stopPrank();
|
vm.stopPrank();
|
||||||
|
|
||||||
vm.startPrank(BOB);
|
vm.startPrank(BOB);
|
||||||
|
|||||||
Reference in New Issue
Block a user