Skip to content

Commit

Permalink
test: increase ChefFacet test coverage to 100% (#837)
Browse files Browse the repository at this point in the history
  • Loading branch information
gitcoindev authored Nov 22, 2023
1 parent a7946df commit e18f161
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions packages/contracts/test/diamond/facets/ChefFacet.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down

1 comment on commit e18f161

@ubiquibot
Copy link

@ubiquibot ubiquibot bot commented on e18f161 Nov 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.