Skip to content

Instantly share code, notes, and snippets.

@veridelisi
Created December 31, 2022 06:31
Show Gist options
  • Save veridelisi/1ed7720284010647e80119d731f4fa79 to your computer and use it in GitHub Desktop.
Save veridelisi/1ed7720284010647e80119d731f4fa79 to your computer and use it in GitHub Desktop.
// SPDX-License-Identifier:GPL-3.0-or-later
pragma solidity ^0.8.7;
import "src/Dots.sol";
import "forge-std/Test.sol";
contract DotsTest is Test {
Dots public dots;
address alice;
address bob;
address owner;
address attacker;
function setUp() public {
dots = new Dots();
//Treasury
owner = dots.owner();
//emit log_named_address("Treasury 1 ", owner);
//emit log_named_address("Treasury 2 ", address(this));
//emit log_named_address("Treasury 3 ", msg.sender);
emit log_named_address("Treasury", address(dots));
emit log_named_decimal_uint("Treasury balance is ", address(dots).balance, 18);
//Game Starting 00 01 10 11 We have 4 dots
//If you dont start this, you gives the GameIsNotActive() error
vm.prank(owner);
dots.startGame(2, 2, 0.1 ether, 0.0001 ether);
//Alice
//alice = vm.addr(1);
alice = makeAddr("Alice");
vm.deal(alice, 100 ether);
emit log_named_address("Alice", alice);
emit log_named_decimal_uint("Alice balance is", address(alice).balance, 18);
//Bob
//bob = vm.addr(2);
bob = makeAddr("Bob");
vm.deal(bob, 100 ether);
emit log_named_address("Bob", bob);
emit log_named_decimal_uint("Bob balance is", address(bob).balance, 18);
//Attacker
//attacker = vm.addr(3);
attacker = makeAddr("Attacker");
vm.deal(attacker, 100 ether);
emit log_named_address("Attacker ", attacker);
emit log_named_decimal_uint("Attacker balance is", address(attacker).balance, 18);
}
function testVesting() public {
vm.startPrank(bob);
dots.claimLocation{value: 1 ether}(1,1,6);
emit log_named_decimal_uint(" G New Bob balance is", address(bob).balance, 18);
vm.stopPrank();
vm.startPrank(attacker);
dots.claimLocation{value: 1 ether}(1,0,6);
vm.stopPrank();
vm.startPrank(alice);
dots.claimLocation{value: 2 ether}(0,1,6);
vm.stopPrank();
vm.startPrank(alice);
dots.claimLocation{value: 1 ether}(0,0,6);
emit log_named_decimal_uint("New Alice balance is", address(alice).balance, 18);
vm.stopPrank();
vm.startPrank(attacker);
dots.withdrawVesting((dots.activeGameIndex())-1);
emit log_named_decimal_uint("G New Attacker balance is", address(attacker).balance, 18);
vm.stopPrank();
vm.startPrank(alice);
dots.withdrawVesting((dots.activeGameIndex())-1);
emit log_named_decimal_uint("G New Alice balance is", address(alice).balance, 18);
vm.stopPrank();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment