Skip to content

Commit

Permalink
adapt tests
Browse files Browse the repository at this point in the history
  • Loading branch information
franzns committed Dec 13, 2024
1 parent fa2ee61 commit 9a64d5b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/token/Beets.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {Ownable} from "openzeppelin-contracts/access/Ownable.sol";

contract Beets is ERC20, ERC20Permit, Ownable {
uint256 public constant YEAR_IN_SECONDS = 365 days;
// 10% per year is the hardcoded max inflation rate, as defined in BIP-##
// 10% per year is the hardcoded max inflation rate, as defined in BIP-77
uint256 public constant MAX_INFLATION_PER_YEAR = 1e17;

// The initial start timestamp is defined on deployment. This is the start time of the current year
Expand Down
17 changes: 8 additions & 9 deletions test/BeetsTest.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,8 @@ contract BeetsTest is Test {
assertEq(beetsToken.totalSupply(), INITIAL_SUPPLY);
assertEq(beetsToken.owner(), TOKEN_MINTER_ADDRESS);
assertEq(beetsToken.startTimestampCurrentYear(), block.timestamp);
assertEq(beetsToken.startingSupplyCurrentYear(), INITIAL_SUPPLY);
assertEq(beetsToken.amountMintedCurrentYear(), 0);
assertEq(beetsToken.getMaxAllowedSupplyCurrentYear(), 220_000_000 ether);
assertEq(beetsToken.maxAmountMintableCurrentYear(), MAX_MINTABLE_FIRST_YEAR);
assertEq(beetsToken.balanceOf(TOKEN_MINTER_TARGET), INITIAL_SUPPLY);
assertEq(beetsToken.getEndTimestampCurrentYear(), block.timestamp + 365 days);
}
Expand All @@ -48,7 +47,7 @@ contract BeetsTest is Test {
new Beets(INITIAL_SUPPLY, address(0));
}

function testMint() public {
function testFullMint() public {
uint256 amount = 1000 ether;

vm.prank(TOKEN_MINTER_ADDRESS);
Expand All @@ -57,7 +56,7 @@ contract BeetsTest is Test {
assertEq(beetsToken.balanceOf(TOKEN_MINTER_ADDRESS), amount);
assertEq(beetsToken.amountMintedCurrentYear(), amount);
assertEq(beetsToken.totalSupply(), INITIAL_SUPPLY + amount);
assertEq(beetsToken.getMaxAllowedSupplyCurrentYear(), 220_000_000 ether);
assertEq(beetsToken.maxAmountMintableCurrentYear(), MAX_MINTABLE_FIRST_YEAR);
}

function testMintUnAuthorized() public {
Expand Down Expand Up @@ -116,10 +115,10 @@ contract BeetsTest is Test {

assertEq(beetsToken.balanceOf(TOKEN_MINTER_ADDRESS), maxAmountYearTwo);
assertEq(beetsToken.totalSupply(), INITIAL_SUPPLY + maxAmountYearTwo);
assertEq(beetsToken.getMaxAllowedSupplyCurrentYear(), INITIAL_SUPPLY + maxAmountYearTwo);
assertEq(beetsToken.maxAmountMintableCurrentYear(), MAX_MINTABLE_FIRST_YEAR);
}

function testIncrementYear() public {
function testIncrementYearWithMints() public {
uint256 amountYearOne = 20_000_000 ether;
uint256 amountYearTwo = 10_000_000 ether;

Expand All @@ -132,14 +131,14 @@ contract BeetsTest is Test {

assertEq(beetsToken.startTimestampCurrentYear(), block.timestamp - 1);
assertEq(beetsToken.amountMintedCurrentYear(), 0);
assertEq(beetsToken.startingSupplyCurrentYear(), INITIAL_SUPPLY + amountYearOne);
assertEq(beetsToken.maxAmountMintableCurrentYear(), 22_000_000 ether);

vm.prank(TOKEN_MINTER_ADDRESS);
beetsToken.mint(TOKEN_MINTER_ADDRESS, amountYearTwo);

assertEq(beetsToken.startTimestampCurrentYear(), block.timestamp - 1);
assertEq(beetsToken.amountMintedCurrentYear(), amountYearTwo);
assertEq(beetsToken.startingSupplyCurrentYear(), INITIAL_SUPPLY + amountYearOne);
assertEq(beetsToken.maxAmountMintableCurrentYear(), 22_000_000 ether);
}

function testIncrementYearNoMints() public {
Expand All @@ -149,7 +148,7 @@ contract BeetsTest is Test {

assertEq(beetsToken.startTimestampCurrentYear(), block.timestamp - 1);
assertEq(beetsToken.amountMintedCurrentYear(), 0);
assertEq(beetsToken.startingSupplyCurrentYear(), INITIAL_SUPPLY);
assertEq(beetsToken.maxAmountMintableCurrentYear(), MAX_MINTABLE_FIRST_YEAR);
}

function testIncrementYearNotEndedError() public {
Expand Down

0 comments on commit 9a64d5b

Please sign in to comment.