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.

81 lines
2.6 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;
2 years ago
uint256 unaboomerPrice;
uint256 bombPrice;
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
unaboomerPrice = main.unaboomerPrice();
bombPrice = main.bombPrice();
}
2 years ago
// ensure only Main can mint/burn/kill
function testOnlyMain() public {
2 years ago
address t = address(1);
startHoax(t);
2 years ago
vm.expectRevert(bytes("invalid msg sender"));
2 years ago
boomr.radicalize(t, 10);
2 years ago
vm.expectRevert(bytes("invalid msg sender"));
2 years ago
boomr.die(1);
2 years ago
vm.expectRevert(bytes("invalid msg sender"));
2 years ago
bomb.create(t, 10);
2 years ago
vm.expectRevert(bytes("invalid msg sender"));
2 years ago
bomb.explode(t, 10);
2 years ago
assertEq(boomr.totalSupply() == 0, true);
2 years ago
}
2 years ago
// ensure killing increments leaderboard
function testLeaderboard() public {
address victim = address(1);
address killer = address(2);
uint256 amt = 20;
hoax(victim);
main.radicalizeBoomers{value: unaboomerPrice * amt}(amt);
startHoax(killer);
main.assembleBombs{value: bombPrice * amt}(amt);
main.sendBombs(3);
main.sendBombs(3);
main.sendBombs(3);
main.sendBombs(3);
main.sendBombs(3);
assertEq(main.leaderboard(main.leaderboardPointer()), killer);
assertEq(main.unaboomersKilled() > 0, true);
console.log(main.killCount(killer));
2 years ago
}
2 years ago
// ensure killing toggles URI
// ensure sending bombs burns bombs
// ensure supply limits enforced
// ensure survivor limit enforced
// ensure only owners can withdraw funds
// ensure withdraw function actuall works
// 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');
// }
}