From a4e9a3da983e28c381b16f649ba06ae9a2040ee3 Mon Sep 17 00:00:00 2001 From: Franco NG Date: Fri, 14 Jun 2024 13:38:01 +0200 Subject: [PATCH] Add deny_warnings flag and address all warnings --- foundry.toml | 5 ++++- script/example/L2ClaimTokens.s.sol | 3 ++- test/L1/L1LiskToken.t.sol | 4 ++-- test/L1/L1VestingWallet.t.sol | 2 +- test/L2/L2Claim.t.sol | 9 +++++---- test/L2/L2LiskToken.t.sol | 6 +++--- test/L2/L2LockingPosition.t.sol | 2 +- test/L2/L2Reward.t.sol | 2 +- test/L2/L2VestingWallet.t.sol | 2 +- test/L2/L2VotingPower.t.sol | 4 ++-- 10 files changed, 22 insertions(+), 17 deletions(-) diff --git a/foundry.toml b/foundry.toml index 8847712d..fda160a5 100644 --- a/foundry.toml +++ b/foundry.toml @@ -12,11 +12,14 @@ remappings = [ 'ds-test/=lib/forge-std/lib/ds-test/src/', 'erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/', 'forge-std/=lib/forge-std/src/', - '@openzeppelin/=lib/openzeppelin-contracts/', '@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/', 'openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/', 'openzeppelin-contracts/=lib/openzeppelin-contracts/', + '@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/', + 'openzeppelin-foundry-upgrades/=lib/openzeppelin-foundry-upgrades/src/', + 'solidity-stringutils/=lib/openzeppelin-foundry-upgrades/lib/solidity-stringutils/', ] +deny_warnings = true [fmt] line_length = 120 diff --git a/script/example/L2ClaimTokens.s.sol b/script/example/L2ClaimTokens.s.sol index 397b0896..7d7d9b5a 100644 --- a/script/example/L2ClaimTokens.s.sol +++ b/script/example/L2ClaimTokens.s.sol @@ -31,7 +31,8 @@ contract L2ClaimTokensScript is Script { /// @notice merkle-leaves.json in string format. string public merkleLeavesJson; - /// @notice The contract address created by default mnemonic in Anvil/Ganache when nonce=0. + /// @notice The destination address for claims as `address(uint160(uint256(keccak256("foundry default caller"))))` + /// and `nonce=2`. address public constant destination = address(0x34A1D3fff3958843C43aD80F30b94c510645C316); /// @notice 1 Beddows in LSK Chain = 10 * 10 Beddows in L2 Chain diff --git a/test/L1/L1LiskToken.t.sol b/test/L1/L1LiskToken.t.sol index 681f33f8..5f0ae1e7 100644 --- a/test/L1/L1LiskToken.t.sol +++ b/test/L1/L1LiskToken.t.sol @@ -26,7 +26,7 @@ contract L1LiskTokenTest is Test { l1LiskToken = new L1LiskToken(); } - function test_Initialize() public { + function test_Initialize() public view { assertEq(l1LiskToken.name(), NAME); assertEq(l1LiskToken.symbol(), SYMBOL); assertEq(l1LiskToken.totalSupply(), TOTAL_SUPPLY); @@ -199,7 +199,7 @@ contract L1LiskTokenTest is Test { assertEq(l1LiskToken.pendingOwner(), alice); } - function test_DefaultAdminRoleIsRoleAdminForBurnerRole() public { + function test_DefaultAdminRoleIsRoleAdminForBurnerRole() public view { assertEq(l1LiskToken.DEFAULT_ADMIN_ROLE(), l1LiskToken.getRoleAdmin(l1LiskToken.BURNER_ROLE())); } } diff --git a/test/L1/L1VestingWallet.t.sol b/test/L1/L1VestingWallet.t.sol index e51ee1ee..782f4c17 100644 --- a/test/L1/L1VestingWallet.t.sol +++ b/test/L1/L1VestingWallet.t.sol @@ -77,7 +77,7 @@ contract L1VestingWalletTest is Test { mockToken.transfer(address(l1VestingWallet), vestAmount); } - function test_Initialize() public { + function test_Initialize() public view { assertEq(l1VestingWallet.name(), name); assertEq(l1VestingWallet.start(), startTimestamp); assertEq(l1VestingWallet.duration(), durationSeconds); diff --git a/test/L2/L2Claim.t.sol b/test/L2/L2Claim.t.sol index cc635424..7a0dc0a5 100644 --- a/test/L2/L2Claim.t.sol +++ b/test/L2/L2Claim.t.sol @@ -54,11 +54,12 @@ contract L2ClaimV2Mock is L2Claim { contract L2ClaimTest is Test { using stdJson for string; - // recover LSK tokens after 2 years + /// @notice recover LSK tokens after 2 years uint256 public constant RECOVER_PERIOD = 730 days; - // pre-set destination address for claims - address public constant RECIPIENT_ADDRESS = 0x34A1D3fff3958843C43aD80F30b94c510645C316; + /// @notice The destination address for claims as `address(uint160(uint256(keccak256("foundry default caller"))))` + /// and `nonce=2`. + address public constant RECIPIENT_ADDRESS = address(0x34A1D3fff3958843C43aD80F30b94c510645C316); ERC20 public lsk; L2Claim public l2ClaimImplementation; @@ -190,7 +191,7 @@ contract L2ClaimTest is Test { l2ClaimImplementation.initialize(address(lsk), bytes32(0), block.timestamp + RECOVER_PERIOD); } - function test_Version() public { + function test_Version() public view { assertEq(l2Claim.version(), "1.0.0"); } diff --git a/test/L2/L2LiskToken.t.sol b/test/L2/L2LiskToken.t.sol index b87acbcb..a84a561f 100644 --- a/test/L2/L2LiskToken.t.sol +++ b/test/L2/L2LiskToken.t.sol @@ -44,7 +44,7 @@ contract L2LiskTokenTest is Test { new L2LiskToken(address(0)); } - function test_Initialize() public { + function test_Initialize() public view { assertEq(l2LiskToken.name(), "Lisk"); assertEq(l2LiskToken.symbol(), "LSK"); assertEq(l2LiskToken.decimals(), 18); @@ -176,12 +176,12 @@ contract L2LiskTokenTest is Test { assertNotEq(address(l2LiskTokenSalted), l2LiskTokenAddressCalculated); } - function test_GetBridge() public { + function test_GetBridge() public view { assertEq(l2LiskToken.bridge(), bridge); assertEq(l2LiskToken.BRIDGE(), bridge); } - function test_GetRemoteToken() public { + function test_GetRemoteToken() public view { assertEq(l2LiskToken.remoteToken(), remoteToken); assertEq(l2LiskToken.REMOTE_TOKEN(), remoteToken); } diff --git a/test/L2/L2LockingPosition.t.sol b/test/L2/L2LockingPosition.t.sol index a8bf224f..b83351a1 100644 --- a/test/L2/L2LockingPosition.t.sol +++ b/test/L2/L2LockingPosition.t.sol @@ -517,7 +517,7 @@ contract L2LockingPositionTest is Test { l2LockingPosition.removeLockingPosition(positionId); } - function test_GetLockingPosition_PositionDoesNotExist() public { + function test_GetLockingPosition_PositionDoesNotExist() public view { IL2LockingPosition.LockingPosition memory position = l2LockingPosition.getLockingPosition(1); assertEq(position.creator, address(0)); assertEq(position.amount, 0); diff --git a/test/L2/L2Reward.t.sol b/test/L2/L2Reward.t.sol index 2d3b825b..451492e4 100644 --- a/test/L2/L2Reward.t.sol +++ b/test/L2/L2Reward.t.sol @@ -113,7 +113,7 @@ contract L2RewardTest is Test { l2Staking.addCreator(address(l2Reward)); } - function test_initialize() public { + function test_initialize() public view { assertEq(l2Reward.lastTrsDate(), deploymentDate); assertEq(l2Reward.OFFSET(), 150); assertEq(l2Reward.REWARD_DURATION(), 30); diff --git a/test/L2/L2VestingWallet.t.sol b/test/L2/L2VestingWallet.t.sol index 06defb95..a604a5c5 100644 --- a/test/L2/L2VestingWallet.t.sol +++ b/test/L2/L2VestingWallet.t.sol @@ -76,7 +76,7 @@ contract L2VestingWalletTest is Test { mockToken.transfer(address(l2VestingWallet), vestAmount); } - function test_Initialize() public { + function test_Initialize() public view { assertEq(l2VestingWallet.name(), name); assertEq(l2VestingWallet.start(), startTimestamp); assertEq(l2VestingWallet.duration(), durationSeconds); diff --git a/test/L2/L2VotingPower.t.sol b/test/L2/L2VotingPower.t.sol index 535614be..8239a63a 100644 --- a/test/L2/L2VotingPower.t.sol +++ b/test/L2/L2VotingPower.t.sol @@ -99,7 +99,7 @@ contract L2VotingPowerTest is Test { ); } - function test_Version() public { + function test_Version() public view { assertEq(l2VotingPower.version(), "1.0.0"); } @@ -329,7 +329,7 @@ contract L2VotingPowerTest is Test { assertEq(l2VotingPower.clock(), blockTimestamp + 1); } - function test_ClockMode() public { + function test_ClockMode() public view { assertEq(l2VotingPower.CLOCK_MODE(), "mode=timestamp"); }