From e18f161fb0367231b4a00abfb9dd28f4f70b05a2 Mon Sep 17 00:00:00 2001 From: korrrba <88761781+gitcoindev@users.noreply.github.com> Date: Wed, 22 Nov 2023 19:58:59 +0100 Subject: [PATCH] test: increase ChefFacet test coverage to 100% (#837) --- .../test/diamond/facets/ChefFacet.t.sol | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/packages/contracts/test/diamond/facets/ChefFacet.t.sol b/packages/contracts/test/diamond/facets/ChefFacet.t.sol index e51488260..f8a6ac5c7 100644 --- a/packages/contracts/test/diamond/facets/ChefFacet.t.sol +++ b/packages/contracts/test/diamond/facets/ChefFacet.t.sol @@ -195,12 +195,33 @@ contract ZeroStateChefTest is ZeroStateChef { assertEq(chefFacet.governancePerBlock(), governancePerBlock); } + // test setGovernancePerBlock function should revert if not admin + function testSetGovernancePerBlock_ShouldRevertWhenNotAdmin() public { + vm.prank(secondAccount); + vm.expectRevert("MasterChef: not Governance Token manager"); + chefFacet.setGovernancePerBlock(100); + } + function testSetGovernanceDiv(uint256 div) public { vm.prank(admin); chefFacet.setGovernanceShareForTreasury(div); assertEq(chefFacet.governanceDivider(), div); } + function testGetInitialGovernanceMul() public { + vm.prank(admin); + assertEq(chefFacet.governanceMultiplier(), 1e18); + } + + // test setGovernanceShareForTreasury function should revert if not admin + function testSetGovernanceShareForTreasury_ShouldRevertWhenNotAdmin() + public + { + vm.prank(secondAccount); + vm.expectRevert("MasterChef: not Governance Token manager"); + chefFacet.setGovernanceShareForTreasury(100); + } + function testSetMinPriceDiff(uint256 minPriceDiff) public { vm.expectEmit(true, false, false, true, address(chefFacet)); emit MinPriceDiffToUpdateMultiplierModified(minPriceDiff); @@ -209,6 +230,15 @@ contract ZeroStateChefTest is ZeroStateChef { assertEq(chefFacet.minPriceDiffToUpdateMultiplier(), minPriceDiff); } + // test setMinPriceDiffToUpdateMultiplier function should revert if not admin + function testSetMinPriceDiffToUpdateMultiplier_ShouldRevertWhenNotAdmin() + public + { + vm.prank(secondAccount); + vm.expectRevert("MasterChef: not Governance Token manager"); + chefFacet.setMinPriceDiffToUpdateMultiplier(100); + } + function testDepositFromZeroState(uint256 lpAmount) public { uint256 LPBalance = metapool.balanceOf(fourthAccount); lpAmount = bound(lpAmount, 1, LPBalance);