1
0
forked from mico/idle_moloch

Raid increases total minted now

This commit is contained in:
mic0 2024-10-20 19:46:05 +02:00
parent 7567cc6789
commit 48602ccd9b
Signed by: mico
GPG Key ID: A3F8023524CF1C8D
2 changed files with 10 additions and 1 deletions

View File

@ -73,7 +73,11 @@ contract Geld is ERC20, Ownable {
require(block.timestamp >= players[msg.sender].last_raided_at + RAID_WAIT, "Tried minting too soon");
// TODO: Make real calculation based on army
_mint(msg.sender, 50 * 10 ** decimals());
uint256 new_geld = 50 * 10 ** decimals();
_mint(msg.sender, new_geld);
total_minted += new_geld;
players[msg.sender].last_raided_at = block.timestamp;
}

View File

@ -107,13 +107,16 @@ contract GeldTest is Test {
registerPlayer();
uint256 balance = geld.balanceOf(player1);
uint256 total_minted = geld.total_minted();
// Trigger raid funds minting
geld.raid();
// New balance should be larger
uint256 newBalance = geld.balanceOf(player1);
uint256 newTotalMinted = geld.total_minted();
assertLt(balance, newBalance);
assertLt(total_minted, newTotalMinted);
// Expect fail if we raid again, we need to wait a bit
vm.expectRevert();
@ -125,6 +128,8 @@ contract GeldTest is Test {
// Balance should reflect that
uint256 newestBalance = geld.balanceOf(player1);
uint256 newestTotalMinted = geld.total_minted();
assertLt(newTotalMinted, newestTotalMinted);
assertLt(newBalance, newestBalance);
}
}