|
|
|
// SPDX-License-Identifier: UNLICENSED
|
|
|
|
pragma solidity ^0.8.13;
|
|
|
|
|
|
|
|
import "forge-std/Test.sol";
|
|
|
|
import {UnaboomerCommon} from "../src/UnaboomerCommon.sol";
|
|
|
|
import {Unaboomer} from "../src/Unaboomer.sol";
|
|
|
|
import {Mailbomb} from "../src/Mailbomb.sol";
|
|
|
|
|
|
|
|
contract UnaboomerTest is Test {
|
|
|
|
UnaboomerCommon public main;
|
|
|
|
Unaboomer public boomr;
|
|
|
|
Mailbomb public bomb;
|
|
|
|
|
|
|
|
function setUp() public {
|
|
|
|
main = new UnaboomerCommon();
|
|
|
|
boomr = new Unaboomer();
|
|
|
|
bomb = new Mailbomb();
|
|
|
|
boomr.setMainContract(address(main));
|
|
|
|
bomb.setMainContract(address(main));
|
|
|
|
main.setUnaboomerContract(address(boomr));
|
|
|
|
main.setMailbombContract(address(bomb));
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
hoax(t1);
|
|
|
|
(bool[] memory res, uint256[] memory killed) = main.sendBombs(60);
|
|
|
|
for (uint256 i; i < res.length; i++) {
|
|
|
|
console.log(res[i]);
|
|
|
|
console.log(killed[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// function testX() public {}
|
|
|
|
|
|
|
|
}
|