You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

114 lines
3.7 KiB
Solidity

// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;
import "forge-std/Test.sol";
2 years ago
import {Main} from "../src/Main.sol";
2 years ago
import {Unaboomer} from "../src/Unaboomer.sol";
import {Mailbomb} from "../src/Mailbomb.sol";
contract UnaboomerTest is Test {
2 years ago
Main public main;
Unaboomer public boomr;
2 years ago
Mailbomb public bomb;
function setUp() public {
2 years ago
main = new Main();
boomr = new Unaboomer();
2 years ago
bomb = new Mailbomb();
2 years ago
boomr.setMainContract(address(main));
bomb.setMainContract(address(main));
main.setUnaboomerContract(address(boomr));
main.setMailbombContract(address(bomb));
}
2 years ago
function testBasicMechanics() public {
address t1 = address(1);
address t2 = address(2);
2 years ago
// mint 20 boomers - should have 20 BOOMR and 40 BOMB
hoax(t1);
2 years ago
main.radicalizeBoomers{value: .2 ether}(20);
assertEq(boomr.totalSupply(), 20);
assertEq(boomr.balanceOf(t1), 20);
2 years ago
assertEq(bomb.bombsAssembled(), 40);
assertEq(bomb.balanceOf(t1, 1), 40);
2 years ago
// mint 20 more bombs - should have 60 BOMB
hoax(t1);
2 years ago
main.assembleBombs{value: .2 ether}(20);
assertEq(bomb.bombsAssembled(), 60);
assertEq(bomb.balanceOf(t1, 1), 60);
// mint 20 more boomers as other address - supplies should line up
hoax(t2);
main.radicalizeBoomers{value: .2 ether}(20);
assertEq(boomr.totalSupply(), 40);
assertEq(boomr.balanceOf(t2), 20);
assertEq(bomb.bombsAssembled(), 100);
assertEq(bomb.balanceOf(t2, 1), 40);
2 years ago
// sending bombs should change supplies and update kill count
hoax(t1);
2 years ago
main.sendBombs(40);
assertEq(bomb.balanceOf(t1, 1), 20);
assertEq(boomr.totalKillCount() > 0, true);
console.log(boomr.totalKillCount());
2 years ago
}
2 years ago
function testSendingBombs() public {
hoax(address(1));
main.radicalizeBoomers{value: .5 ether}(50);
hoax(address(2));
main.radicalizeBoomers{value: .1 ether}(10);
hoax(address(3));
main.radicalizeBoomers{value: .03 ether}(3);
hoax(address(4));
main.radicalizeBoomers{value: .15 ether}(15);
hoax(address(4));
main.sendBombs(10);
hoax(address(3));
main.sendBombs(6);
hoax(address(2));
main.sendBombs(10);
hoax(address(1));
2 years ago
main.sendBombs(20);
2 years ago
uint256 ptr = main.leaderboardPointer();
address leader = main.leaderboard(ptr);
uint256 killcount = main.killCount(leader);
}
2 years ago
function testSendingBombsAgain() public {
hoax(address(1));
2 years ago
main.radicalizeBoomers{value: 99 ether}(9900);
2 years ago
hoax(address(1));
2 years ago
main.sendBombs(15);
2 years ago
}
2 years ago
function testKilling() public {
address t = address(1);
startHoax(t);
main.assembleBombs{value: .1 ether}(10);
vm.expectRevert(bytes("not enough supply"));
main.sendBombs(10);
main.radicalizeBoomers{value: .1 ether}(10);
main.sendBombs(10);
assertEq(bomb.balanceOf(t, 1), 20);
}
function testFailDirectFunctions() public {
address t = address(1);
startHoax(t);
boomr.radicalize(t, 10);
boomr.die(1);
bomb.create(t, 10);
bomb.explode(t, 10);
}
function testURILogic() public {
address t = address(1);
boomr.setAliveURI('ipfs://alive/');
boomr.setDeadURI('ipfs://dead/');
startHoax(t);
main.radicalizeBoomers{value: .01 ether}(1);
assertEq(boomr.tokenURI(0), 'ipfs://alive/0.json');
main.sendBombs(1);
assertEq(boomr.tokenURI(0), 'ipfs://dead/0.json');
}
}