|
|
|
@ -10,6 +10,8 @@ contract UnaboomerTest is Test {
|
|
|
|
|
Main public main;
|
|
|
|
|
Unaboomer public boomr;
|
|
|
|
|
Mailbomb public bomb;
|
|
|
|
|
uint256 unaboomerPrice;
|
|
|
|
|
uint256 bombPrice;
|
|
|
|
|
|
|
|
|
|
function setUp() public {
|
|
|
|
|
main = new Main();
|
|
|
|
@ -19,95 +21,60 @@ contract UnaboomerTest is Test {
|
|
|
|
|
bomb.setMainContract(address(main));
|
|
|
|
|
main.setUnaboomerContract(address(boomr));
|
|
|
|
|
main.setMailbombContract(address(bomb));
|
|
|
|
|
unaboomerPrice = main.unaboomerPrice();
|
|
|
|
|
bombPrice = main.bombPrice();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function testBasicMechanics() public {
|
|
|
|
|
address t1 = address(1);
|
|
|
|
|
address t2 = address(2);
|
|
|
|
|
// mint 20 boomers - should have 20 BOOMR and 40 BOMB
|
|
|
|
|
hoax(t1);
|
|
|
|
|
main.radicalizeBoomers{value: .2 ether}(20);
|
|
|
|
|
assertEq(boomr.totalSupply(), 20);
|
|
|
|
|
assertEq(boomr.balanceOf(t1), 20);
|
|
|
|
|
assertEq(bomb.bombsAssembled(), 40);
|
|
|
|
|
assertEq(bomb.balanceOf(t1, 1), 40);
|
|
|
|
|
// mint 20 more bombs - should have 60 BOMB
|
|
|
|
|
hoax(t1);
|
|
|
|
|
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);
|
|
|
|
|
// sending bombs should change supplies and update kill count
|
|
|
|
|
hoax(t1);
|
|
|
|
|
main.sendBombs(40);
|
|
|
|
|
assertEq(bomb.balanceOf(t1, 1), 20);
|
|
|
|
|
assertEq(boomr.totalKillCount() > 0, true);
|
|
|
|
|
console.log(boomr.totalKillCount());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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));
|
|
|
|
|
main.sendBombs(20);
|
|
|
|
|
uint256 ptr = main.leaderboardPointer();
|
|
|
|
|
address leader = main.leaderboard(ptr);
|
|
|
|
|
uint256 killcount = main.killCount(leader);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function testSendingBombsAgain() public {
|
|
|
|
|
hoax(address(1));
|
|
|
|
|
main.radicalizeBoomers{value: 10 ether}(1000);
|
|
|
|
|
hoax(address(1));
|
|
|
|
|
main.sendBombs(10);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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 {
|
|
|
|
|
// ensure only Main can mint/burn/kill
|
|
|
|
|
function testOnlyMain() public {
|
|
|
|
|
address t = address(1);
|
|
|
|
|
startHoax(t);
|
|
|
|
|
vm.expectRevert(bytes("invalid msg sender"));
|
|
|
|
|
boomr.radicalize(t, 10);
|
|
|
|
|
vm.expectRevert(bytes("invalid msg sender"));
|
|
|
|
|
boomr.die(1);
|
|
|
|
|
vm.expectRevert(bytes("invalid msg sender"));
|
|
|
|
|
bomb.create(t, 10);
|
|
|
|
|
vm.expectRevert(bytes("invalid msg sender"));
|
|
|
|
|
bomb.explode(t, 10);
|
|
|
|
|
assertEq(boomr.totalSupply() == 0, true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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');
|
|
|
|
|
// 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));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 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');
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|