diff --git a/foundry.toml b/foundry.toml index 2444e38..1897827 100644 --- a/foundry.toml +++ b/foundry.toml @@ -3,6 +3,11 @@ src = "src" out = "out" libs = ["lib"] +# fuzz test times +fuzz_runs = 2048 +# fuzz test max time +fuzz_max_time = 60 + ffi = true ast = true build_info = true diff --git a/lcov.info b/lcov.info index d3dad5e..3b09204 100644 --- a/lcov.info +++ b/lcov.info @@ -1,12 +1,12 @@ TN: SF:script/DeployContracts.s.sol FN:48,DeployContracts.run -FNDA:29,DeployContracts.run -DA:50,29 -BRDA:50,0,0,29 +FNDA:34,DeployContracts.run +DA:50,34 +BRDA:50,0,0,34 BRDA:50,0,1,- -DA:51,29 -DA:52,29 +DA:51,34 +DA:52,34 DA:53,0 BRDA:53,1,0,- BRDA:53,1,1,- @@ -16,26 +16,26 @@ DA:69,0 BRDA:69,2,0,- DA:70,0 DA:72,0 -DA:87,29 +DA:87,34 FN:91,DeployContracts.deploymentsOnLocalNetwork FNDA:0,DeployContracts.deploymentsOnLocalNetwork -DA:92,29 -DA:93,29 -DA:94,29 -DA:95,29 -DA:96,29 -DA:97,29 -DA:108,29 -DA:109,29 -DA:116,29 -DA:119,29 -DA:122,29 -DA:125,29 -DA:127,29 -DA:129,29 -DA:131,29 -DA:132,29 -DA:134,29 +DA:92,34 +DA:93,34 +DA:94,34 +DA:95,34 +DA:96,34 +DA:97,34 +DA:108,34 +DA:109,34 +DA:116,34 +DA:119,34 +DA:122,34 +DA:125,34 +DA:127,34 +DA:129,34 +DA:131,34 +DA:132,34 +DA:134,34 FNF:2 FNH:1 LF:27 @@ -78,23 +78,23 @@ end_of_record TN: SF:src/ERC20UpgradeableTokenV1.sol FN:34,ERC20UpgradeableTokenV1. -FNDA:42,ERC20UpgradeableTokenV1. -DA:35,42 +FNDA:47,ERC20UpgradeableTokenV1. +DA:35,47 FN:38,ERC20UpgradeableTokenV1.initialize -FNDA:41,ERC20UpgradeableTokenV1.initialize -DA:47,41 +FNDA:46,ERC20UpgradeableTokenV1.initialize +DA:47,46 BRDA:47,0,0,- -DA:48,41 -DA:49,41 -DA:50,41 -DA:51,41 -DA:52,41 -DA:53,41 -DA:55,41 -DA:56,41 -DA:57,41 -DA:58,41 -DA:59,41 +DA:48,46 +DA:49,46 +DA:50,46 +DA:51,46 +DA:52,46 +DA:53,46 +DA:55,46 +DA:56,46 +DA:57,46 +DA:58,46 +DA:59,46 FN:62,ERC20UpgradeableTokenV1.pause FNDA:1,ERC20UpgradeableTokenV1.pause DA:63,1 @@ -102,16 +102,16 @@ FN:66,ERC20UpgradeableTokenV1.unpause FNDA:1,ERC20UpgradeableTokenV1.unpause DA:67,1 FN:70,ERC20UpgradeableTokenV1.mint -FNDA:104,ERC20UpgradeableTokenV1.mint -DA:71,104 +FNDA:120,ERC20UpgradeableTokenV1.mint +DA:71,120 FN:79,ERC20UpgradeableTokenV1.burnByBurner -FNDA:12,ERC20UpgradeableTokenV1.burnByBurner -DA:80,10 +FNDA:13,ERC20UpgradeableTokenV1.burnByBurner +DA:80,11 FN:83,ERC20UpgradeableTokenV1._authorizeUpgrade FNDA:1,ERC20UpgradeableTokenV1._authorizeUpgrade FN:86,ERC20UpgradeableTokenV1._update -FNDA:121,ERC20UpgradeableTokenV1._update -DA:90,121 +FNDA:138,ERC20UpgradeableTokenV1._update +DA:90,138 FNF:8 FNH:8 LF:18 @@ -122,33 +122,33 @@ end_of_record TN: SF:src/GovToken.sol FN:27,GovToken. -FNDA:41,GovToken. -DA:35,41 +FNDA:46,GovToken. +DA:35,46 BRDA:35,0,0,- -DA:37,41 -DA:38,41 -DA:39,41 -DA:40,41 -DA:41,41 +DA:37,46 +DA:38,46 +DA:39,46 +DA:40,46 +DA:41,46 FN:49,GovToken._update -FNDA:74,GovToken._update -DA:52,74 +FNDA:81,GovToken._update +DA:52,81 BRDA:52,1,0,4 DA:53,4 -DA:55,70 +DA:55,77 FN:65,GovToken.burnByBurner FNDA:7,GovToken.burnByBurner DA:66,5 FN:69,GovToken.mint -FNDA:67,GovToken.mint -DA:70,65 +FNDA:74,GovToken.mint +DA:70,72 FN:79,GovToken.setBurnedAmountOfUtilToken -FNDA:13,GovToken.setBurnedAmountOfUtilToken -DA:83,11 -DA:84,11 +FNDA:14,GovToken.setBurnedAmountOfUtilToken +DA:83,12 +DA:84,12 FN:87,GovToken.clock FNDA:0,GovToken.clock -DA:88,70 +DA:88,77 FN:92,GovToken.CLOCK_MODE FNDA:0,GovToken.CLOCK_MODE DA:93,0 @@ -217,48 +217,48 @@ end_of_record TN: SF:src/VotingPowerExchange.sol FN:66,VotingPowerExchange. -FNDA:40,VotingPowerExchange. -DA:69,40 -BRDA:69,0,0,1 -DA:70,39 -BRDA:70,1,0,- -DA:71,0 -DA:74,39 -DA:75,39 -DA:76,39 -DA:77,39 -DA:78,39 -DA:79,39 +FNDA:49,VotingPowerExchange. +DA:69,49 +BRDA:69,0,0,2 +DA:70,47 +BRDA:70,1,0,2 +DA:71,2 +DA:74,45 +DA:75,45 +DA:76,45 +DA:77,45 +DA:78,45 +DA:79,45 FN:98,VotingPowerExchange.exchange -FNDA:11,VotingPowerExchange.exchange -DA:102,11 +FNDA:16,VotingPowerExchange.exchange +DA:102,16 BRDA:102,2,0,1 -DA:103,10 -BRDA:103,3,0,- -DA:104,10 -BRDA:104,4,0,- -DA:105,10 +DA:103,15 +BRDA:103,3,0,1 +DA:104,14 +BRDA:104,4,0,1 +DA:105,13 BRDA:105,5,0,1 -DA:107,9 -DA:108,9 -BRDA:108,6,0,1 -DA:109,1 -DA:113,8 -DA:114,8 -BRDA:114,7,0,1 -DA:115,1 -DA:119,7 -DA:121,7 -DA:125,7 -DA:127,7 -DA:129,7 +DA:107,12 +DA:108,12 +BRDA:108,6,0,2 +DA:109,2 +DA:113,10 +DA:114,10 +BRDA:114,7,0,2 +DA:115,2 +DA:119,8 +DA:121,8 +DA:125,8 +DA:127,8 +DA:129,8 BRDA:129,8,0,1 DA:131,1 DA:133,1 -DA:137,7 -DA:140,7 -DA:143,7 -DA:144,7 +DA:137,8 +DA:140,8 +DA:143,8 +DA:144,8 FN:152,VotingPowerExchange.setVotingPowerCap FNDA:4,VotingPowerExchange.setVotingPowerCap DA:153,3 @@ -266,21 +266,21 @@ BRDA:153,9,0,2 DA:154,1 FN:160,VotingPowerExchange.authorizationState FNDA:8,VotingPowerExchange.authorizationState -DA:161,18 +DA:161,22 FN:172,VotingPowerExchange._setVotingPowerCap -FNDA:40,VotingPowerExchange._setVotingPowerCap -DA:173,40 -DA:174,40 +FNDA:46,VotingPowerExchange._setVotingPowerCap +DA:173,46 +DA:174,46 FN:187,VotingPowerExchange.calculateIncrementedVotingPower FNDA:26,VotingPowerExchange.calculateIncrementedVotingPower -DA:192,33 -DA:193,33 +DA:192,34 +DA:193,34 FN:204,VotingPowerExchange.calculateVotingPowerFromBurnedAmount FNDA:117,VotingPowerExchange.calculateVotingPowerFromBurnedAmount -DA:206,183 -DA:208,183 -DA:210,183 -DA:211,183 +DA:206,185 +DA:208,185 +DA:210,185 +DA:211,185 FN:221,VotingPowerExchange.calculateIncrementedBurningAmount FNDA:26,VotingPowerExchange.calculateIncrementedBurningAmount DA:226,27 @@ -300,27 +300,27 @@ DA:261,1 DA:262,1 DA:263,1 FN:270,VotingPowerExchange.getTokenAddresses -FNDA:0,VotingPowerExchange.getTokenAddresses -DA:271,0 -DA:272,0 +FNDA:1,VotingPowerExchange.getTokenAddresses +DA:271,1 +DA:272,1 FNF:12 -FNH:11 +FNH:12 LF:53 -LH:50 +LH:53 BRF:10 -BRH:7 +BRH:10 end_of_record TN: SF:test/integration/utils/VotingPowerExchangeTestHelper.t.sol FN:15,VotingPowerExchangeTestHelper.generateSignatureFromPrivateKey -FNDA:10,VotingPowerExchangeTestHelper.generateSignatureFromPrivateKey -DA:22,10 -DA:23,10 -DA:24,10 -DA:26,10 -DA:36,10 -DA:38,10 -DA:40,10 +FNDA:15,VotingPowerExchangeTestHelper.generateSignatureFromPrivateKey +DA:22,15 +DA:23,15 +DA:24,15 +DA:26,15 +DA:36,15 +DA:38,15 +DA:40,15 FNF:1 FNH:1 LF:7 diff --git a/test/fuzz/FuzzVotingPowerExchange.t.sol b/test/fuzz/FuzzVotingPowerExchange.t.sol new file mode 100644 index 0000000..f4d88d7 --- /dev/null +++ b/test/fuzz/FuzzVotingPowerExchange.t.sol @@ -0,0 +1,80 @@ +// SPDX-License-Identifier: MIT + +pragma solidity 0.8.24; + +import {Test, console} from "forge-std/Test.sol"; +import {PausableUpgradeable} from "@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol"; +import {AmbassadorNft} from "src/AmbassadorNft.sol"; +import {DeployContracts, DeploymentResult} from "script/DeployContracts.s.sol"; +import {ERC20UpgradeableTokenV1} from "src/ERC20UpgradeableTokenV1.sol"; +import {GovToken} from "src/GovToken.sol"; +import {VotingPowerExchange} from "src/VotingPowerExchange.sol"; +import {VotingPowerExchangeTestHelper} from "../integration/utils/VotingPowerExchangeTestHelper.t.sol"; +import {MessageHashUtils} from "lib/openzeppelin-contracts/contracts/utils/cryptography/MessageHashUtils.sol"; + +contract VotingPwoerExchangeTest is Test { + // instances + GovToken public govToken; + ERC20UpgradeableTokenV1 public utilityToken; + VotingPowerExchange public votingPowerExchange; + DeployContracts public dc; + VotingPowerExchangeTestHelper public helper; + + DeploymentResult result; + + // admin roles + address admin; + address pauser; + address minter; + address burner; + address manager; + address exchanger; + + // users for testing + address public user = makeAddr("user"); + address public user2 = makeAddr("user2"); + + // user for testing exchange + address public participant = makeAddr("levelUpper2"); + address public participant2; + + // private key + uint256 public default_anvil_key2 = 0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d; + + // deploy scripts + function setUp() public { + dc = new DeployContracts(); + result = dc.run(); + + utilityToken = ERC20UpgradeableTokenV1(result.utilityToken); + govToken = GovToken(result.govToken); + votingPowerExchange = VotingPowerExchange(result.exchange); + admin = result.admin; + pauser = result.pauser; + minter = result.minter; + burner = result.burner; + manager = result.manager; + exchanger = result.exchanger; + participant2 = vm.addr(dc.DEFAULT_ANVIL_KEY2()); + + vm.startPrank(minter); + govToken.mint(user, 15 * 1e17); + utilityToken.mint(user, 1_000 * 1e18); + utilityToken.mint(participant, 100_000 * 1e18); + utilityToken.mint(participant2, 10_000 * 1e18); + vm.stopPrank(); + + // set up the roles for exchange contract + + helper = new VotingPowerExchangeTestHelper(); + + // other setup + vm.label(participant, "participant"); + vm.label(participant2, "participant2"); + vm.label(user, "user"); + vm.label(user2, "user2"); + } + + function testFuzz_exchange(uint256 amount) public { + } +} diff --git a/test/unit/GovToken.t.sol b/test/unit/GovToken.t.sol index 2dd0342..f2b3fa7 100644 --- a/test/unit/GovToken.t.sol +++ b/test/unit/GovToken.t.sol @@ -200,7 +200,7 @@ contract GovTokenTest is Test { assertEq(govToken.burnedAmountOfUtilToken(user2), 100 ether); } - function testNonRoleCannnotCallSetBurnedAmountOfUtilToken() public { + function testNonRoleCannotCallSetBurnedAmountOfUtilToken() public { vm.startPrank(user); vm.expectRevert(); govToken.setBurnedAmountOfUtilToken(user, 100 ether);