From 48602ccd9ba87c730f9355fcf15e15196129fcb2 Mon Sep 17 00:00:00 2001 From: Mitja Belak Date: Sun, 20 Oct 2024 19:46:05 +0200 Subject: [PATCH] Raid increases total minted now --- src/Geld.sol | 6 +++++- test/Geld.t.sol | 5 +++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Geld.sol b/src/Geld.sol index fb693ca..77ebbac 100644 --- a/src/Geld.sol +++ b/src/Geld.sol @@ -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; } diff --git a/test/Geld.t.sol b/test/Geld.t.sol index b5bfb6e..79d09a8 100644 --- a/test/Geld.t.sol +++ b/test/Geld.t.sol @@ -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); } }