initial raid time is now set to block.timestamp to prevent silly things happening
Some checks are pending
CI / Foundry project (push) Waiting to run
Some checks are pending
CI / Foundry project (push) Waiting to run
This commit is contained in:
parent
4a5354f092
commit
799d9ae435
@ -91,6 +91,8 @@ const PlayerProvider = ({ children }: { children: ReactNode }) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
console.log(player)
|
||||||
|
|
||||||
const register = useCallback(() => {
|
const register = useCallback(() => {
|
||||||
writeContract({
|
writeContract({
|
||||||
abi,
|
abi,
|
||||||
|
|||||||
@ -3,7 +3,7 @@ pragma solidity ^0.8.13;
|
|||||||
|
|
||||||
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
|
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
|
||||||
import "@openzeppelin/contracts/access/Ownable.sol";
|
import "@openzeppelin/contracts/access/Ownable.sol";
|
||||||
import { RaidGeldUtils } from "../src/RaidGeldUtils.sol";
|
import {RaidGeldUtils} from "../src/RaidGeldUtils.sol";
|
||||||
|
|
||||||
struct Raider {
|
struct Raider {
|
||||||
uint16 level;
|
uint16 level;
|
||||||
@ -49,7 +49,8 @@ contract RaidGeld is ERC20, Ownable {
|
|||||||
_mint(msg.sender, INITIAL_GELD);
|
_mint(msg.sender, INITIAL_GELD);
|
||||||
|
|
||||||
// Set initial states
|
// Set initial states
|
||||||
players[msg.sender] = Player({total_minted: INITIAL_GELD, created_at: block.timestamp, last_raided_at: 0});
|
players[msg.sender] =
|
||||||
|
Player({total_minted: INITIAL_GELD, created_at: block.timestamp, last_raided_at: block.timestamp});
|
||||||
armies[msg.sender] = Army({
|
armies[msg.sender] = Army({
|
||||||
moloch_denier: Raider({level: 0}),
|
moloch_denier: Raider({level: 0}),
|
||||||
apprentice: Raider({level: 0}),
|
apprentice: Raider({level: 0}),
|
||||||
|
|||||||
@ -28,7 +28,7 @@ contract raid_geldTest is Test {
|
|||||||
function test_00_no_fallback() public {
|
function test_00_no_fallback() public {
|
||||||
vm.expectRevert();
|
vm.expectRevert();
|
||||||
// Send Ether with some data to trigger fallback
|
// Send Ether with some data to trigger fallback
|
||||||
(bool success, ) = address(raid_geld).call{value: 0.1 ether}("0x1234");
|
(bool success,) = address(raid_geld).call{value: 0.1 ether}("0x1234");
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_01_no_receive() public {
|
function test_01_no_receive() public {
|
||||||
@ -55,7 +55,7 @@ contract raid_geldTest is Test {
|
|||||||
Player memory player = raid_geld.getPlayer(player1);
|
Player memory player = raid_geld.getPlayer(player1);
|
||||||
assertEq(player.total_minted, raid_geld.INITIAL_GELD());
|
assertEq(player.total_minted, raid_geld.INITIAL_GELD());
|
||||||
assertEq(player.created_at, block.timestamp);
|
assertEq(player.created_at, block.timestamp);
|
||||||
assertEq(player.last_raided_at, 0);
|
assertEq(player.last_raided_at, block.timestamp);
|
||||||
|
|
||||||
Army memory army = raid_geld.getArmy(player1);
|
Army memory army = raid_geld.getArmy(player1);
|
||||||
|
|
||||||
@ -119,7 +119,7 @@ contract raid_geldTest is Test {
|
|||||||
Army memory army = raid_geld.getArmy(player1);
|
Army memory army = raid_geld.getArmy(player1);
|
||||||
uint256 unit_level = army.moloch_denier.level;
|
uint256 unit_level = army.moloch_denier.level;
|
||||||
uint256 balance = raid_geld.balanceOf(player1);
|
uint256 balance = raid_geld.balanceOf(player1);
|
||||||
uint256 income_per_sec = army.profit_per_second;
|
uint256 income_per_sec = army.profit_per_second;
|
||||||
raid_geld.addUnit(0, 2);
|
raid_geld.addUnit(0, 2);
|
||||||
|
|
||||||
// TODO: maybe try to test against exact values we want here
|
// TODO: maybe try to test against exact values we want here
|
||||||
@ -134,7 +134,7 @@ contract raid_geldTest is Test {
|
|||||||
assertEq(new_unit_level, unit_level + 2);
|
assertEq(new_unit_level, unit_level + 2);
|
||||||
|
|
||||||
// Check that user income per second increased
|
// Check that user income per second increased
|
||||||
uint256 new_income_per_sec = army.profit_per_second;
|
uint256 new_income_per_sec = army.profit_per_second;
|
||||||
assertLt(income_per_sec, new_income_per_sec);
|
assertLt(income_per_sec, new_income_per_sec);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -149,6 +149,8 @@ contract raid_geldTest is Test {
|
|||||||
|
|
||||||
uint256 balance = raid_geld.balanceOf(player1);
|
uint256 balance = raid_geld.balanceOf(player1);
|
||||||
|
|
||||||
|
// Warp time a bit so first raid doesnt fail
|
||||||
|
vm.warp(block.timestamp + raid_geld.RAID_WAIT());
|
||||||
// Trigger raid funds minting
|
// Trigger raid funds minting
|
||||||
raid_geld.raid();
|
raid_geld.raid();
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user