fix: pr comments
This commit is contained in:
@@ -1,8 +0,0 @@
|
|||||||
// SPDX-License-Identifier: UNLICENSED
|
|
||||||
pragma solidity ^0.8.13;
|
|
||||||
|
|
||||||
import {Script, console} from "forge-std/Script.sol";
|
|
||||||
|
|
||||||
contract DeployScript is Script {
|
|
||||||
// TODO: implement deploy script
|
|
||||||
}
|
|
||||||
@@ -10,4 +10,5 @@ contract Constants is Test {
|
|||||||
address FEE_SETTER = makeAddr("feeSetter");
|
address FEE_SETTER = makeAddr("feeSetter");
|
||||||
// dummy contracts
|
// dummy contracts
|
||||||
address DUMMY = makeAddr("dummy");
|
address DUMMY = makeAddr("dummy");
|
||||||
|
address FEE_RECEIVER = makeAddr("feeReceiver");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ contract TychoRouterTest is TychoRouterTestSetup {
|
|||||||
vm.stopPrank();
|
vm.stopPrank();
|
||||||
}
|
}
|
||||||
|
|
||||||
function testWithdrawNativeOtherCases() public {
|
function testWithdrawNativeFailures() public {
|
||||||
vm.deal(address(tychoRouter), 100 ether);
|
vm.deal(address(tychoRouter), 100 ether);
|
||||||
vm.startPrank(FUND_RESCUER);
|
vm.startPrank(FUND_RESCUER);
|
||||||
vm.expectRevert(TychoRouter__AddressZero.selector);
|
vm.expectRevert(TychoRouter__AddressZero.selector);
|
||||||
@@ -142,21 +142,7 @@ contract TychoRouterTest is TychoRouterTestSetup {
|
|||||||
|
|
||||||
function testWithdrawERC20Tokens() public {
|
function testWithdrawERC20Tokens() public {
|
||||||
vm.startPrank(BOB);
|
vm.startPrank(BOB);
|
||||||
// Check balances before minting
|
mintTokens(100 ether, address(tychoRouter));
|
||||||
for (uint256 i = 0; i < tokens.length; i++) {
|
|
||||||
// slither-disable-next-line calls-loop
|
|
||||||
assertEq(tokens[i].balanceOf(address(tychoRouter)), 0);
|
|
||||||
}
|
|
||||||
// Mint tokens to tychoRouter
|
|
||||||
for (uint256 i = 0; i < tokens.length; i++) {
|
|
||||||
// slither-disable-next-line calls-loop
|
|
||||||
tokens[i].mint(address(tychoRouter), 100 ether);
|
|
||||||
}
|
|
||||||
// Check balances after minting
|
|
||||||
for (uint256 i = 0; i < tokens.length; i++) {
|
|
||||||
// slither-disable-next-line calls-loop
|
|
||||||
assertEq(tokens[i].balanceOf(address(tychoRouter)), 100 ether);
|
|
||||||
}
|
|
||||||
vm.stopPrank();
|
vm.stopPrank();
|
||||||
|
|
||||||
vm.startPrank(FUND_RESCUER);
|
vm.startPrank(FUND_RESCUER);
|
||||||
@@ -174,19 +160,28 @@ contract TychoRouterTest is TychoRouterTestSetup {
|
|||||||
assertEq(tokens[i].balanceOf(FUND_RESCUER), 100 ether);
|
assertEq(tokens[i].balanceOf(FUND_RESCUER), 100 ether);
|
||||||
}
|
}
|
||||||
vm.stopPrank();
|
vm.stopPrank();
|
||||||
|
}
|
||||||
|
|
||||||
|
function testWithdrawERC20TokensFailures() public {
|
||||||
|
mintTokens(100 ether, address(tychoRouter));
|
||||||
|
IERC20[] memory tokensArray = new IERC20[](3);
|
||||||
|
tokensArray[0] = IERC20(address(tokens[0]));
|
||||||
|
tokensArray[1] = IERC20(address(tokens[1]));
|
||||||
|
tokensArray[2] = IERC20(address(tokens[2]));
|
||||||
|
|
||||||
vm.startPrank(FUND_RESCUER);
|
vm.startPrank(FUND_RESCUER);
|
||||||
vm.expectRevert();
|
vm.expectRevert(TychoRouter__AddressZero.selector);
|
||||||
tychoRouter.withdraw(tokensArray, address(0));
|
tychoRouter.withdraw(tokensArray, address(0));
|
||||||
vm.stopPrank();
|
vm.stopPrank();
|
||||||
|
|
||||||
|
// Not role FUND_RESCUER
|
||||||
vm.startPrank(BOB);
|
vm.startPrank(BOB);
|
||||||
vm.expectRevert();
|
vm.expectRevert();
|
||||||
tychoRouter.withdraw(tokensArray, FUND_RESCUER);
|
tychoRouter.withdraw(tokensArray, FUND_RESCUER);
|
||||||
vm.stopPrank();
|
vm.stopPrank();
|
||||||
}
|
}
|
||||||
|
|
||||||
function testFeeSetterRole() public {
|
function testFeeSetting() public {
|
||||||
vm.startPrank(FEE_SETTER);
|
vm.startPrank(FEE_SETTER);
|
||||||
assertEq(tychoRouter.fee(), 0);
|
assertEq(tychoRouter.fee(), 0);
|
||||||
tychoRouter.setFee(100);
|
tychoRouter.setFee(100);
|
||||||
@@ -198,4 +193,17 @@ contract TychoRouterTest is TychoRouterTestSetup {
|
|||||||
tychoRouter.setFee(200);
|
tychoRouter.setFee(200);
|
||||||
vm.stopPrank();
|
vm.stopPrank();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function testFeeReceiverSetting() public {
|
||||||
|
vm.startPrank(FEE_SETTER);
|
||||||
|
assertEq(tychoRouter.feeReceiver(), address(0));
|
||||||
|
tychoRouter.setFeeReceiver(FEE_RECEIVER);
|
||||||
|
assertEq(tychoRouter.feeReceiver(), FEE_RECEIVER);
|
||||||
|
vm.stopPrank();
|
||||||
|
|
||||||
|
vm.startPrank(BOB);
|
||||||
|
vm.expectRevert();
|
||||||
|
tychoRouter.setFeeReceiver(FEE_RECEIVER);
|
||||||
|
vm.stopPrank();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,4 +35,16 @@ contract TychoRouterTestSetup is Test, Constants {
|
|||||||
bytes memory minimalBytecode = hex"01"; // Single-byte bytecode
|
bytes memory minimalBytecode = hex"01"; // Single-byte bytecode
|
||||||
vm.etch(DUMMY, minimalBytecode); // Deploy minimal bytecode
|
vm.etch(DUMMY, minimalBytecode); // Deploy minimal bytecode
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dev Mints tokens to the given address
|
||||||
|
* @param amount The amount of tokens to mint
|
||||||
|
* @param to The address to mint tokens to
|
||||||
|
*/
|
||||||
|
function mintTokens(uint256 amount, address to) internal {
|
||||||
|
for (uint256 i = 0; i < tokens.length; i++) {
|
||||||
|
// slither-disable-next-line calls-loop
|
||||||
|
tokens[i].mint(to, amount);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user