Merge pull request #37 from propeller-heads/router/hr/ENG-4194-Batch-Set-Executor
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
|
||||
* @param target address of the executor contract
|
||||
* @param targets address of the executor contract
|
||||
*/
|
||||
function setExecutor(address target)
|
||||
function setExecutors(address[] memory targets)
|
||||
external
|
||||
onlyRole(EXECUTOR_SETTER_ROLE)
|
||||
{
|
||||
_setExecutor(target);
|
||||
for (uint256 i = 0; i < targets.length; i++) {
|
||||
_setExecutor(targets[i]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -16,6 +16,8 @@ contract Constants is Test {
|
||||
|
||||
// Dummy contracts
|
||||
address DUMMY = makeAddr("dummy");
|
||||
address DUMMY2 = makeAddr("dummy2");
|
||||
address DUMMY3 = makeAddr("dummy3");
|
||||
address PAUSER = makeAddr("pauser");
|
||||
address UNPAUSER = makeAddr("unpauser");
|
||||
|
||||
@@ -40,6 +42,9 @@ contract Constants is Test {
|
||||
*/
|
||||
function deployDummyContract() internal {
|
||||
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);
|
||||
vm.etch(DUMMY3, minimalBytecode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,16 +19,31 @@ contract TychoRouterTest is TychoRouterTestSetup {
|
||||
address indexed token, uint256 amount, address indexed receiver
|
||||
);
|
||||
|
||||
function testSetExecutorValidRole() public {
|
||||
function testSetExecutorsValidRole() public {
|
||||
// Set single executor
|
||||
address[] memory executors = new address[](1);
|
||||
executors[0] = DUMMY;
|
||||
vm.startPrank(EXECUTOR_SETTER);
|
||||
tychoRouter.setExecutor(DUMMY);
|
||||
tychoRouter.setExecutors(executors);
|
||||
vm.stopPrank();
|
||||
assert(tychoRouter.executors(DUMMY) == true);
|
||||
|
||||
// Set multiple executors
|
||||
address[] memory executors2 = new address[](2);
|
||||
executors2[0] = DUMMY2;
|
||||
executors2[1] = DUMMY3;
|
||||
vm.startPrank(EXECUTOR_SETTER);
|
||||
tychoRouter.setExecutors(executors2);
|
||||
vm.stopPrank();
|
||||
assert(tychoRouter.executors(DUMMY2) == true);
|
||||
assert(tychoRouter.executors(DUMMY3) == true);
|
||||
}
|
||||
|
||||
function testRemoveExecutorValidRole() public {
|
||||
vm.startPrank(EXECUTOR_SETTER);
|
||||
tychoRouter.setExecutor(DUMMY);
|
||||
address[] memory executors = new address[](1);
|
||||
executors[0] = DUMMY;
|
||||
tychoRouter.setExecutors(executors);
|
||||
tychoRouter.removeExecutor(DUMMY);
|
||||
vm.stopPrank();
|
||||
assert(tychoRouter.executors(DUMMY) == false);
|
||||
@@ -39,9 +54,11 @@ contract TychoRouterTest is TychoRouterTestSetup {
|
||||
tychoRouter.removeExecutor(BOB);
|
||||
}
|
||||
|
||||
function testSetExecutorMissingSetterRole() public {
|
||||
function testSetExecutorsMissingSetterRole() public {
|
||||
vm.expectRevert();
|
||||
tychoRouter.setExecutor(DUMMY);
|
||||
address[] memory executors = new address[](1);
|
||||
executors[0] = DUMMY;
|
||||
tychoRouter.setExecutors(executors);
|
||||
}
|
||||
|
||||
function testSetVerifierValidRole() public {
|
||||
|
||||
@@ -60,8 +60,10 @@ contract TychoRouterTestSetup is Test, Constants {
|
||||
usv2Executor = new UniswapV2Executor();
|
||||
usv3Executor = new UniswapV3Executor();
|
||||
vm.startPrank(EXECUTOR_SETTER);
|
||||
tychoRouter.setExecutor(address(usv2Executor));
|
||||
tychoRouter.setExecutor(address(usv3Executor));
|
||||
address[] memory executors = new address[](2);
|
||||
executors[0] = address(usv2Executor);
|
||||
executors[1] = address(usv3Executor);
|
||||
tychoRouter.setExecutors(executors);
|
||||
vm.stopPrank();
|
||||
|
||||
vm.startPrank(BOB);
|
||||
|
||||
Reference in New Issue
Block a user